[Node, FB Messenger] Buy Buttons and List Templates using SourceEvent return 400 error
Bot Info
- SDK Platform: Node.js
- SDK Version: 3.15.2
- Active Channels: Facebook
- Deployment Environment: Azure Bot Service
Issue Description
Not all Source Events seem to be supported for Facebook Messenger. Specifically, Buy Buttons and List Templates. Sending these messages return 400 'Bad Request' errors.
Code Example
Working (generic template):
let msg = new builder.Message(session).sourceEvent({
facebook: {
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [
{
title: "Microsoft Bot Framework",
subtitle: "Check it out!",
image_url: "http://static.panoramio.com/photos/large/72318690.jpg",
buttons: [
{
type: "element_share"
}
]
}
]
}
}
}
});
session.send(msg);
session.endDialog();
Not working (generic template w/ buy button):
let msg = new builder.Message(session).sourceEvent({
facebook: {
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [ {
title: "Microsoft Bot Framework",
subtitle: "Check it out!",
image_url: "http://static.panoramio.com/photos/large/72318690.jpg",
buttons: [
{
type: "payment",
title: "Buy Now",
payload: "CUSTOM_PAYLOAD",
payment_summary: {
currency: "USD",
payment_type: "FIXED_AMOUNT",
is_test_payment: true,
merchant_name: "Microsoft",
requested_user_info: [
"shipping_address",
"contact_name",
"contact_phone",
"contact_email"
],
price_list: [
{
label: "Regular",
amount: "49.99"
}
]
}
}
]
}
]
}
}
}
});
session.send(msg);
session.endDialog();
Not working (list template):
let msg = new builder.Message(session).sourceEvent({
facebook:{
attachment: {
type: "template",
payload: {
template_type: "list",
top_element_style: "compact",
elements: [
{
title: "Microsoft Bot Framework",
subtitle: "Check it out!",
image_url: "http://static.panoramio.com/photos/large/72318690.jpg",
buttons: [
{
type: "phone_number",
title: "Call Now",
payload: "+18001234567"
}
]
}
]
}
}
}
});
session.send(msg);
session.endDialog();
Reproduction Steps
- sourceEvent() using generic template with a standard button (url, share, phone) works as intended.
- Replacing buttons with a buy button returns 400 error.
- sourceEvent() using list template also returns 400 error.
Actual Results
Error: POST to 'https://facebook.botframework.com/v3/conversations/xxxx/activities/mid.%xxxx' failed: [400] Bad Request
at Request._callback (D:\home\site\wwwroot\node_modules\botbuilder\lib\bots\ChatConnector.js:647:46)
at Request.self.callback (D:\home\site\wwwroot\node_modules\request\request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.
Hi @jhaala,
Unfortunately, the Facebook buy buttons aren't supported in Botbuilder at this time, primarily as it is still in beta. There is a solution that may possibly work for you which utilizes routing calls via channelData and webhooks.
You can reference the solution here. Additional information on setting up channelData can be found here.
As for the list, technically, you have the code formed correctly. It fails because it has only one item in the list. In order to avoid the error include 2 or more items.
Why does the framework need to filter or modify SourceEvent data? Is there a reason why channel-specific data can't be passed directly to Facebook? This seems to defeat the purpose of SourceEvent.
Thank you for opening an issue against the Bot Framework SDK v3. As part of the Bot Framework v4 release, we’ve moved all v3 work to a new repo located at https://github.com/microsoft/botbuilder-v3. We will continue to support and offer maintenance updates to v3 via this new repo.
From now on, https://github.com/microsoft/botbuilder repo will be used as hub, with pointers to all the different SDK languages, tools and samples repos.
As part of this restructuring, we are closing all tickets in this repo.
For defects or feature requests, please create a new issue in the new Bot Framework v3 repo found here: https://github.com/microsoft/botbuilder-v3/issues
For Azure Bot Service Channel specific defects or feature requests (e.g. Facebook, Twilio, Teams, Slack, etc.), please create a new issue in the new Bot Framework Channel repo found here: https://github.com/microsoft/botframework-services/issues
For product behavior, how-to, or general understanding questions, please use Stackoverflow. https://stackoverflow.com/search?q=bot+framework
Thank you.
The Bot Framework Team