Reputation: 375
I'm building my first messenger bot in js and already can receive and reply to messages and send cards with options, but I've already tried everything to setup a get started button but with no success... Here is what I have done for that:
I don't know what i'm doing wrong or where do i have to call the facebookthreadAPI function. Need advice.
Excerpt from index.js:
function facebookThreadAPI(jsonFile, cmd){
// Start the request
request({
url: 'https://graph.facebook.com/v2.6/me/thread_settings?access_token='+process.env.token,
method: 'POST',
headers: {'Content-Type': 'application/json'},
form: require(jsonFile)
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
// Print out the response body
console.log(cmd+": Updated.");
console.log(body);
} else {
// TODO: Handle errors
console.log(cmd+": Failed. Need to handle errors.");
console.log(body);
}
});}
Excerpt from fb-get-started-button.json:
{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"payload":"action?POSTBACKHERE"
}
]
}
Upvotes: 0
Views: 3074
Reputation: 256
Facebook now offers a new API for setting up the Get started button with many other features such as the greeting text and persistent menu so instead of using the old thread_setting API use the messenger profile API. For example, using curl
curl -X POST -H "Content-Type: application/json" -d '{
"get_started":{
"payload":"GET_STARTED_PAYLOAD"
}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=PAGE_ACCESS_TOKEN"
Replace PAGE_ACCESS_TOKEN with your page access token and GET_STARTED_PAYLOAD with any payload you want. See the complete tutorial here
Upvotes: 2
Reputation: 3
Now, with that new API, I'm trying to set GetStarted button with that request: curl -X POST -H "Content-Type: application/json" -d '{ "get_started":{
"payload":"start"}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=My_Token"
and getting {"result":"success"}
. But that button still doesn't appear in chat. So, I still dont understand, what's the problem here...
Upvotes: 0
Reputation: 63
I have the same problem. Here you can find the documentation.
I have tried to execute the example with no results.
curl -X POST -H "Content-Type: application/json" -d '{ "setting_type":"call_to_actions", "thread_state":"new_thread", "call_to_actions":[ { "payload":"USER_DEFINED_PAYLOAD" } ] }' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
My error is:
Requires pages_messaging permission to manage the object
But my page is not public.
Edit: You can find the solution Here. It doesn't work with the page admin
Upvotes: 0