Charca / bootbot

Facebook Messenger Bot Framework for Node.js
MIT License
970 stars 252 forks source link

sendListTemplate : Error PostBack Buttons #163

Open Guivers opened 5 years ago

Guivers commented 5 years ago

Hello everyone,

I'm coming to you because I have a problem recovering the postBack when I use the sendListTemplate function.

When I click on a button I have an error message on facebook that tells me that there is a problem with the bot.

Here is my code, I hope you will be able to enlighten me.

> `bot.hear('begin', (payload, chat) => {
>   var elements = [
> 
>   {
>     "title" : "tilte",
>     "subtitle" : "subtitle",
>     "image_url" : "https://avatars1.githubusercontent.com/u/32040672?s=88&v=4",
>     "buttons" :    [ { type: 'postback', title: 'Settings', payload: 'HELP_SETTINGS' }] 
>   },
> 
>   {
>     "title" : "tilte",
>     "subtitle" : "subtitle",
>     "image_url" : "https://avatars1.githubusercontent.com/u/32040672?s=88&v=4",
>     "buttons" :  [ { type: 'postback', title: 'Settings', payload: 'HELP_SETTINGS_2' } ]
>   },
>     {
>     "title" : "tilte",
>     "subtitle" : "subtitle",
>     "image_url" : "https://avatars1.githubusercontent.com/u/32040672?s=88&v=4",
>     "buttons" :  [ { type: 'postback', title: 'Settings', payload: 'HELP_SETTINGS_3' } ]
>   },
>   {
>     "title" : "tilte",
>     "subtitle" : "subtitle",
>     "image_url" : "https://avatars1.githubusercontent.com/u/32040672?s=88&v=4",
>     "buttons" :   [ { type: 'postback', title: 'Settings', payload: 'HELP_SETTINGS_4' } ]
>   },
> 
> 
> 
> 
>   ];
> 
> 
>   chat.sendListTemplate(elements, [{ "title": "MORE", "type": "postback", "payload": "SET_SIGNE_MORE" }] );`

"PostBack Listener"

Test 1

> bot.on('postback:HELP_SETTINGS', (payload, chat, data) => {
>   chat.say(`Here are your settings: ...`);
>   console.log(1);
>   //Do something
> });

TEST 2

> bot.on('postback', (payload, chat, data) => {
>     const pb_payload = JSON.parse(payload.postback.payload);
> 
>         console.log(pb_payload);
>     
> });

TEST 3

> bot.on('list:SET_SIGNE_MORE', (payload, chat) => {
>   console.log(1);
> });
> 
zaidfadhil commented 5 years ago

same, did you find a way to fix it ?