node.js - Facebook Messenger Bot Persistent Menu -


i generating first bot working node.js , heroku finding difficulties understand persistent menu functionalities.

question 1) how can attach event callbacks?

function persistentmenu(sender){  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 : "existing_thread",         call_to_actions:[             {               type:"postback",               title:"faq",               payload:"developer_defined_payload_for_help"             },             {               type:"postback",               title:"i prodotti in offerta",               payload:"developer_defined_payload_for_help"             },             {               type:"web_url",               title:"view website",               url:"https://google.com/"             }           ]     }  }, function(error, response, body) {     console.log(response)     if (error) {         console.log('error sending messages: ', error)     } else if (response.body.error) {         console.log('error: ', response.body.error)     } }) 

}

question 2) way have found empty persistent menu , generating new 1 delete request via terminal ("as facebook documented")m there possibily clear inserting refresh function on app.js file?

curl -x delete -h "content-type: application/json" -d '{"setting_type":"call_to_actions","thread_state":"existing_thread"}' "https://graph.facebook.com/v2.6/me/thread_settingsaccess_token=page_access_token"     

the fb example robot not structured call backs. haven't found way structure example in node callback or promise model. i'm sure node expert can reorg it.

as persistent menu, if send empty call_to_actions array menu disappear. menu seems bit 'sticky' not appear/disappear when message sent.

i incorporated snippet example robot. can see at

https://messenger.com/t/dynamicmemorysolutions

the source at:

https://github.com/matthewericfisher/fb-robot

see add/remove menu commands , functions.

edit: persistent menu api has been updated. see this question more details.


Comments