1

I am integrating DialogFlow and LINE using fulfillment webhook. I am able to successfully reply the message to user's LINE when the text is in the speech field of the response.

{
  "speech": "your number is 1234"
}

However, if I follow the document and add the LINE specific response, it does not work, meaning it simply replies nothing.

{
  "data": {
    "line": {
      "replyToken": "e4050bccd34b52...b119069d27bb5",
      "messages": [
        {
          "text": "Hi",
          "type": "text"
        }
      ]
    }
  }
}

This means that I can only reply with a single text message, but not other rich messages.

Am I doing something wrong or it is DialogFlow's problem?

Andy
  • 1,231
  • 1
  • 15
  • 27
  • it can be possible that line does not support the rich messages like rich messages are not supported for web demo. – Nikhil Savaliya Mar 27 '18 at 04:26
  • It has a set of rich messages defined: https://developers.line.me/en/docs/messaging-api/reference/#message-objects. At any rate, even if I tried using the 'text' type, it is still not working. – Andy Mar 27 '18 at 08:41
  • 1
    can you share your code snippet? – Nikhil Savaliya Mar 28 '18 at 13:05

1 Answers1

1

I finally figured out how to do it! The response format in the question is not correct. The correct format is something like:

{
 'messages': [
   <message object>,
   <message object>
 ]
}

You can refer to message object for what types can be used. One thing to note is with type 4, you can simply use the payload specified in LINE.

For example,

{
    'messages': [
        {
            'type': 0,
            'speech': 'ABC'
        },
        {
            "type": 4,
            "payload": {
                "line": {
                    "type": "template",                                                                                                                                                                                                                           "altText": "This is a buttons template",
                    "template": {
                        "type": "buttons",
                        "thumbnailImageUrl": "https://images.justlanded.com/event_images/Tets/photo/events_original_45195_42919.jpg",
                        "imageAspectRatio": "rectangle",
                        "imageSize": "cover",
                        "imageBackgroundColor": "#FFFFFF",
                        "title": "Menu",
                        "text": "Please select",
                        "defaultAction": {
                            "type": "uri",
                            "label": "View detail",
                            "uri": "http://example.com/page/123"
                        },
                        "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"
                            }
                        ]
                    }
                }
            }
        }

    ]
}
Andy
  • 1,231
  • 1
  • 15
  • 27