2. About Linebot
The Messaging API allows for data to be passed between the
server of your bot application and the LINE Platform.
When a user sends your bot a message, a webhook is triggered
and the LINE Platform sends a request to your webhook URL.
Your server then sends a request to the LINE Platform to respond
to the user. Requests are sent over HTTPS in JSON format.
3. Messaging API
1. Send reply messages :一問一答 (Free plan)
2. Send push messages: 主動PUSH(Developer trial)
3. Send various message types: Choose from
various types of messages to send to users
including text, stickers, images, videos, audio,
location, imagemaps, and template messages.
4. Message Server Channel Gateway
LINE Platform
Line webhook send
HTTPS POST request
NGROK Tunnel
NGROK
https://xxxx.ngrok.io/webhook
./ngrok http 3080
http
node sample.js 3080
/webhook
Demo: Linebot網路實作架構
5. 準備工作
1. 為了使用Messaging API, 你必須有LINE@帳號. LINE@
就是你LINE 帳戶中LINE bot
2. To start building a bot with the Messaging API,
follow these steps:
1) Create a channel
2) Building a bot
3. HTTPS Server (node.js express)
4. 但我們利用NGROK tunnel service 一次解決3個問題
? your server is behind NAT (NAT Traversal)
? 建立HTTPS伺服器須要有有一個CA(Certificate Authority(CA) 憑證
? Domain Name
7. Install ngrok
Download a single binary file
? https://ngrok.com/download
? Raspberry pi 要下載 Linux (ARM) 版本
Unzip :
unzip ngrok.zip
Start your ngrok tunnel
./ngrok http <port>
? it will return a random URL each time a tunnel
is started.
Note: https://dashboard.ngrok.com/billing/plan