18

I'm getting a weird error while configuring welcome message for my Messenger bot. I've been using the same code (as shown below) and it has just been working fine until last night. I tried it with both cURL and Postman. Neither of them works.

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"call_to_actions",
  "thread_state":"new_thread",
  "call_to_actions":[
    {
      "message":{
        "text":"Welcome to My Company!"
      }
    }
  ]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"

Error message when executing the code above:

{"error":{"message":"(#100) Invalid keys \"message\" were found in param \"call_to_actions[0]\".","type":"OAuthException","code":100,"fbtrace_id":"Hn42Wa+hapI"}}%

I can confirm both PAGE_ID and PAGE_ACCESS_TOKEN are correct as trying to delete the welcome message with the following code works fine.

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"call_to_actions",
  "thread_state":"new_thread",
  "call_to_actions":[
    {
      "message":{
        "text":"Welcome to My Company!"
      }
    }
  ]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"

Also, the code I'm using is exactly the same as shown on the Facebook official API doc. I don't understand why it's saying "message" is not a valid key. Is anyone experiencing the same problem? Did Facebook change their api?

Any help will be much appreciated!

lei he
  • 259
  • 3
  • 8
  • 1
    Been trying to solve this for hours. Glad to see people having the same problem, in a way that we can confirm this error is not caused by us. Maybe an undocumented API change? – ericls Jun 29 '16 at 18:51
  • 1
    @ericls I would reckon it's an undocumented API change. Hope further notification will be given soon. – lei he Jun 29 '16 at 19:32
  • 1
    Bug has been reported here: https://developers.facebook.com/bugs/1751749508372552/ – sigmus Jun 29 '16 at 20:47

4 Answers4

7

The docs are now updated, you need to define your payload in payload parameter now (a UTF-8 encoded string), eg:

"call_to_actions":[
    {
      "payload":"USER_DEFINED_PAYLOAD"
    }
]
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • The updated doc doesn't work either. I got the following error: `{"error":{"message":"(#3) App must be on whitelist","type":"OAuthException","code":3,"fbtrace_id":"FiDgnEghdY\/"}}` – lei he Jun 30 '16 at 16:26
  • The same for me - the "thread_settings" endpoint worked fine just 2 days ago. Now after using "payload" I am getting the whitelist error. – andy250 Jun 30 '16 at 16:46
  • 1
    te@leihe, you sure your app isnt in sandbox (testing) mode? – Sahil Mittal Jul 01 '16 at 05:43
1

Docs updated:

https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text

Example:

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"greeting",
  "greeting":{
    "text":"Welcome to My Company!"
  }
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
Ladislau
  • 11
  • 2
1

I get the same issue and fix it. I think your json of request is

let messageData = {
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
  {
    "payload":"welcome_payload"
  }
]
}
request({
    url: 'https://graph.facebook.com/v2.6/me/thread_settings',
    qs: {access_token:token},
    method: 'POST',
    json: {
        messageData
    }
}

but it will not work and log will say you have no "setting_type" = =a try this one

  request({
        url: 'https://graph.facebook.com/v2.6/me/thread_settings',
        qs: {access_token:token},
        method: 'POST',
        json: {
            setting_type:"call_to_actions",
            thread_state:"new_thread",
             call_to_actions:[
              {
                "payload":"welcome_payload"
              }
             ]
        }
    }

it work for me.

Ymow Wu
  • 193
  • 2
  • 2
  • 14
-1

This error was due to an API change.

New call:

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"call_to_actions",
  "thread_state":"new_thread",
  "call_to_actions":[{
    "payload":"START"
  }]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_TOKEN>"

Just add a payload like {"payload":"START"}

If a user press the "Getting started" button, you receive this payload in your messageHandler (webhook). Check if $incomingMessage == "START" and send back your structured message, or whatever you want.

Messages like before are not supported anymore.

Bug report: https://developers.facebook.com/bugs/1751749508372552/

phips28
  • 232
  • 2
  • 14