Tuesday, 4 April 2017

messenger_extensions throw error 400

I'm trying to launch a FB Messenger webview from bot framework using the following code. Pressing the button must open the webview:

var msg = new BotBuilder.Message(session)
        .sourceEvent({ 
            facebook: { 
                attachment: { 
                    type: 'template', 
                    payload: { 
                        template_type: 'generic',
                        image_aspect_ratio: 'square',
                        elements: [{ 
                            title: 'Onboarding', 
                            image_url: 'myimage_url', 
                            buttons: [{ 
                                type: 'web_url', 
                                title: 'Jugar',
                                url: 'my_url',
                                webview_height_ratio: 'full',
                                webview_share_button: 'hide',
                                messenger_extensions: 'true'
                            }]
                        }] 
                    } 
                } 
            } 
        }); 

My problem is that this code provoques the following error:

Request to 'https://facebook.botframework.com/v3/conversations/1506643442711231-752831934884481/activities/mid.%24cAAKssnxE17phauV8ClbOaAzoQvnQ' failed: [400] Bad Request","name":"Error","constructor":"Error","stack":"Error: Request to 'https://facebook.botframework.com/v3/conversations/1506643442711231-752831934884481/activities/mid.%24cAAKssnxE17phauV8ClbOaAzoQvnQ' failed: [400] Bad Request\n    at Request._callback (C:\\Users\\advl\\Repositories\\botcorn\\node_modules\\botbuilder\\lib\\bots\\ChatConnector.js:413:46)\n    at Request.self.callback (C:\\Users\\advl\\Repositories\\botcorn\\node_modules\\request\\request.js:186:22)\n    at emitTwo (events.js:106:13)\n    at Request.emit (events.js:191:7)\n    at Request.<anonymous> (C:\\Users\\advl\\Repositories\\botcorn\\node_modules\\request\\request.js:1081:10)\n    at emitOne (events.js:96:13)\n    at Request.emit (events.js:188:7)\n    at IncomingMessage.<anonymous> (C:\\Users\\advl\\Repositories\\botcorn\\node_modules\\request\\request.js:1001:12)\n    at IncomingMessage.g (events.js:291:16)\n    at emitNone (events.js:91:20)\n    at IncomingMessage.emit (events.js:185:7)\n    at endReadableNT (_stream_readable.js:974:12)\n    at _combinedTickCallback (internal/process/next_tick.js:74:11)\n    at process._tickDomainCallback (internal/process/next_tick.js:122:9)"},"msg":"Error: Request to 'https://facebook.botframework.com/v3/conversations/1506643442711231-752831934884481/activities/mid.%24cAAKssnxE17phauV8ClbOaAzoQvnQ' failed: [400] Bad Request"}

If I remove the messenger_extensions line, everything Works. I have also tried with messenger_extensions: true and I get the error 400 again. ¿Has anyone the same problem?



via Alberto De Vega

No comments:

Post a Comment