We would like to integrate with Facebook Payments. We have a Buy Button being sent to Messenger and all that great stuff, but how can we hook into the messaging_payments webhook? Seems like the bot builder fb webhook endpoint might be eating these up?
Bump? This is a big item for us.
FB payments is a beta feature and is not currently supported by the Bot Framework. The best we can do now is investigate the feasibility of passing the payment object that FB sends to the webhook back to your bot via channeldata. Would that work for you?
Thanks. It's Beta but certainly something we've seen interest in.
There are two callbacks we would be interested in:
Your proposed solution would perhaps allows us to handle 1 but not 2.
Another option, as I see it, is for us to host our own Messenger webhooks handler service. If it is one of these Beta web hooks we handle it by ourselves. Otherwise, we act as a proxy and send it to the FB Messenger bot framework endpoint. Thoughts?
After some investigation it appears that we can pass the objects sent to the various payment callbacks via channeldata back to your bot. We also have plans for a new Invoke activity type that will allow bots to send a status code and custom response back to the channel which should enable both of the callbacks that you mention above.
I'll update this thread once we have more details about when this will be available for testing.
FYI - The code has been checked in and will go live with our next deployment - probably sometime this week.
We now forward calls from Facebook to the Pre-Checkout (messaging_pre_checkouts), Checkout Update (messaging_checkout_updates) and Payment (messaging_payments) webhooks as a new Invoke action to your bot. This action is sent synchronously to your bot and the response code and payload from your bot is returned directly to back Facebook in response to the webhook call.
Code is live in production. Please let us know if you run into any issues with it
Do you have a sample you could share. We are in the process of getting beta approved, but would love to see how this flows in and out of the bot on the c# side
Here's an example of what you need to send in ChannelData to get a payment button to show up in Messenger:
{
"type": "message",
"timestamp": "2017-01-24T22:16:43.2121637Z",
"serviceUrl": "*",
"channelId": "facebook",
"from": {
"id": "*",
"name": "*"
},
"conversation": {
"id": "*"
},
"recipient": {
"id": "*",
"name": "*"
},
"text": "",
"channelData": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Classic White T-Shirt",
"image_url": "http://petersapparel.parseapp.com/img/item100-thumb.png",
"subtitle": "Soft white cotton t-shirt is back in style",
"buttons": [
{
"type": "payment",
"title": "buy",
"payload": "DEVELOPER_DEFINED_PAYLOAD",
"payment_summary": {
"currency": "USD",
"payment_type": "FIXED_AMOUNT",
"is_test_payment": true,
"merchant_name": "Peters Apparel",
"requested_user_info": [
"contact_name",
"contact_phone",
"contact_email"
],
"price_list": [
{
"label": "Subtotal",
"amount": "29.99"
},
{
"label": "Taxes",
"amount": "2.47"
}
]
}
}
]
}
]
}
}
},
"replyToId": "*"
}
When the user completes the payment dialog your bot should receive an activity message like this:
{
"type": "invoke",
"id": "*",
"timestamp": "2017-01-24T22:11:56.0410931Z",
"from": {
"id": "*",
"name": "*"
},
"conversation": {
"isGroup": false,
"id": "*"
},
"recipient": {
"id": "*",
"name": "*"
},
"value": {
"sender": {
"id": "*"
},
"recipient": {
"id": "*"
},
"timestamp": 1485295916095,
"payment": {
"payload": "DEVELOPER_DEFINED_PAYLOAD",
"requested_user_info": {
"contact_name": "",
"contact_email": "",
"contact_phone": ""
},
"amount": {
"currency": "USD",
"amount": "32.46"
},
"payment_credential": {
"provider_type": "paypal",
"charge_id": "test_charge_id_12345",
"fb_payment_id": "test_payment_id_12345",
"payment_method": {
"card_type": "visa",
"last_four_digits": "*",
"zip_code": "*"
}
}
}
},
"name": "facebook/payment"
}
Notice that the type is 'invoke', name is 'facebook/payment' and value contains the message sent to the messaging_payments webhook. Since it's an Invoke activity your bot should reply synchronously and your response code and payload will be returned to Facebook in response to the webhook.
forgive my ignorance when you say reply synchronously how is that done from the c# side. PostAsync? or directly from the HttpPost in the MessageController so we can send a 200?
The BF will post the above invoke message to your bot and you should directly return a status code/payload as a response to that message. Whatever you return will get proxied directly back to Facebook. You should return a 200 to accept the payment or presumably some error code to reject it. Details here
Most helpful comment
After some investigation it appears that we can pass the objects sent to the various payment callbacks via channeldata back to your bot. We also have plans for a new Invoke activity type that will allow bots to send a status code and custom response back to the channel which should enable both of the callbacks that you mention above.
I'll update this thread once we have more details about when this will be available for testing.