With Dialogflow's LINE integration, you can use your Dialogflow agent as a LINE bot.
Limitations
Only the default agent language is supported by this integration.
How it works
This is how the integration works:
- You create a LINE channel.
- You associate your Dialogflow agent with that channel, so that they communicate with each other.
- The Dialogflow integration sends messages to the end-user by using the LINE Messaging API.
- The Dialogflow integration receives messages from the end-user by acting as the LINE Webhook.
Setup
To set up the integration:
- Follow the steps to create a LINE channel: Getting started with the Messaging API.
- Get the LINE webhook URL from the Dialogflow Console:
- Go to the Dialogflow ES console.
- Click Integrations in the left sidebar menu.
- Click LINE.
- Copy the Webhook URL value. You will need this to configure your LINE webhook.
- Configure a LINE webhook:
- Follow the steps to configure a LINE webhook for your channel: LINE Receiving messages (webhooks).
- Provide the LINE webhook configuration with the webhook URL copied above.
- Copy the Channel ID, Channel secret, and Channel access token values. You will need these values to configure your Dialogflow integration.
- Configure the Dialogflow integration:
- Go to the Dialogflow ES console.
- Click Integrations in the left sidebar menu.
- Click LINE.
- Paste the Channel ID, Channel secret, and Channel access token into the respective fields.
- Choose an environment, as applicable.
- Click START.
Webhook signature verification
Dialogflow ES validates the X-Line-Signature HTTP request header on every
incoming webhook request using your LINE Channel secret.
To verify request authenticity, Dialogflow ES computes a base64-encoded
HMAC-SHA256 digest of the raw HTTP POST request body with your channel secret
and compares it against the X-Line-Signature header. For details about how
LINE signs webhook payloads, see the
LINE signature validation documentation.
If a webhook request has a missing, duplicate, or invalid X-Line-Signature
header, Dialogflow ES rejects the request with an HTTP 400 Bad Request
status code.
To keep webhook signature verification working:
- Make sure the Channel secret configured in the Dialogflow ES console matches the active Channel secret in your LINE Messaging API channel settings. If you rotate or reissue your channel secret for your LINE channel, update it in the Dialogflow ES console and restart the integration.
- If you route webhook traffic through a proxy, API gateway, or middleware
service before forwarding it to Dialogflow ES, forward the
X-Line-Signatureheader unmodified and send the exact raw request body bytes without re-serializing or altering whitespace. - Don't send unsigned requests directly to the Dialogflow ES LINE webhook URL.
Testing
To test your agent, tap on the three horizontal dots on the main screen of the LINE app. Then tap the QR code icon and scan the QR code on the settings page of your bot. This adds your bot to the list of conversations.
Rich response messages
The following rich response messages are supported.
Image responses
A Dialogflow image response type is sent to LINE as a LINE image message type.
The supported formats and sizes are as follows:
- jpeg
- 1 MB max size
- 240 x 240 max dimensions
Card responses
A Dialogflow card response type is sent to LINE as a LINE template message type.
Quick reply responses
A Dialogflow quick reply response type is sent to LINE as a LINE template message type.
Custom payload responses
You can send most LINE message types with a custom payload response.
For example, the following custom payload provides a LINE template message:
{ "type": "template", "altText": "this is a buttons template", "template": { "type": "buttons", "thumbnailImageUrl": "https://example.com/bot/images/image.jpg", "title": "Menu", "text": "Please select", "actions": [ { "type": "postback", "label": "Buy", "data": "action=buy&itemid=123" }, { "type": "postback", "label": "Add to cart", "data": "action=add&itemid=123" }, { "type": "uri", "label": "View detail", "uri": "http://example.com/page/123" } ] } }