Question Details

Answered
Cannot send flex message with property 'flex' with dialogflow

Line bot cannot send flex message that contains property "flex", for example

I can send this flex message:

{
  "type": "bubble",
  "body": {
    "type": "box",
    "layout": "horizontal",
    "contents": [
      {
        "type": "text",
        "text": "hello"
      },
      {
        "type": "text",
        "text": "world"
      }
    ]
  }
}

but, cannot send this flex message:

{
  "type": "bubble",
  "body": {
    "type": "box",
    "layout": "horizontal",
    "contents": [
      {
        "type": "text",
        "text": "hello",
        "flex": 1
      },
      {
        "type": "text",
        "text": "world",
        "flex": 1
      }
    ]
  }
}

previously just working fine,it is a bug, or line just update their flex message but not update their ducumentation yet?

I am using Dialogflow and sending custom payload message which is I am just copying from flex simulator. In the simulator, the flex property is working fine. but when sending flex message that contains "flex" property, line application not displaying the message. previously it works fine.

image working without "flex": https://imgur.com/a/0JE7moN image error using "flex" property: https://imgur.com/a/hA8QUwf

0
Edited: 2 months ago
Profile picture
arizal

Answers

4
Profile picture
okue
Posted: 2 months ago

Hi, arizal.

Thank you for your report. Could you please share the complete code which reproduces this result?

Profile picture
arizal
Posted: 2 months ago

Hi Okue, I am using Dialogflow and sending custom payload message which is I am just copying from flex simulator. In the simulator, the flex property is working fine. but when sending flex message that contains "flex" property, line application not displaying the message. previously it works fine.

image working without flex: https://imgur.com/a/0JE7moN image error using "flex" property: https://imgur.com/a/hA8QUwf

Profile picture
okue
Posted: 2 months ago

mmm, I could succeed in sending that flex message JSON.

This is my script:

curl -XPOST https://api.line.me/v2/bot/message/push \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {MyToken}' \
-d '{
  "to": "{MyUserId}",
  "messages": [
    {
      "type": "flex",
      "altText": "this is a flex message",
      "contents": {
        "type": "bubble",
        "body": {
          "type": "box",
          "layout": "vertical",
          "contents": [
            {
              "type": "text",
              "text": "hello",
              "flex": 1
            },
            {
              "type": "text",
              "text": "world",
              "flex": 1
            }
          ]
        }
      }
    }
  ]
}'

So, the flex message JSON you showed is not wrong. Can you check the response status code and response body of the failure request?

The failure response body perhaps contains any error reason like:

{"message":"The request body has 2 error(s)","details":[{"message":"May not be empty","property":"messages"},{"message":"May not be empty","property":"to"}]
Profile picture
arizal
Posted: 2 months ago

you was right, I already try push and reply api,turn out it works, probably error on dialogflow side, thankyou for your response

Are you sure? question.vm