Facebook Messenger "Get Started" button not sending the user defined payload - facebook

I have setup a "get started" button on my page:
curl -X POST -H "Content-Type: application/json" -d '{
"get_started":{
"payload":"GET_STARTED_PAYLOAD"
}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=token"
This works fine and responds with {"result":"success"}
If I check the data:
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=get_started&access_token=token
I've got a good answer: {"data":[{"get_started":{"payload":"GET_STARTED_PAYLOAD"}}]}
However when I receive the postback webhook, I've got this payload:
{
"object": "page",
"entry": [
{
"id": "id1",
"time": 1501688073860,
"standby": [
{
"recipient": {
"id": "id1"
},
"timestamp": 1501688073860,
"sender": {
"id": "id2"
},
"postback": {
"title": "Get Started"
}
}
]
}
]
}
There is now way I can get the payload I defined (GET_STARTED_PAYLOAD) in the webhook.
On this page the doc says
payload parameter that was defined with the button. This is only visible to the app that send the original template message.
This message is kind of confusing. Any ideas ?

Putting this answer here in case anyone needs it.
The standby prop indicates you're using the handover protocol, and that the app doesn't have thread control. This causes you not to receive the expected postback event, since the receiving app is not the same as the app that sent the postback.

Related

"Get Started" button not working in Facebook Page

I recently setup the "Get Started" button using the following POST method using Postman:
https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<my token>
With the raw text:
{
"get_started": {"payload": "<postback_payload>"}
}
It returns:
{
"result": "success"
}
But nothing show up in my Messenger (deleted the chat already)
If I send the raw data to setup the greeting text, it works normally and showed up:
{
"greeting": [
{
"locale":"default",
"text":"Hello!"
}, {
"locale":"en_US",
"text":"Timeless apparel for the masses."
}
]
}
Can somebody help me, thanks!

FIWARE Orion: notification responses

In Orion I can create subscription:
curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' \
-d #- <<EOF
{
"description": "A subscription to get info about Room1",
"subject": {
"entities": [
{
"id": "Room1",
"type": "Room"
}
],
"condition": {
"attrs": [
"pressure"
]
}
},
"notification": {
"http": {
"url": "http://localhost:1028/accumulate"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
In this example, Orion will perform POST request on the server http://localhost:1028/accumulate. Is there a way to retrieve the response from the POST received by Orion? i.e. 200, 404...
In my use case the notifications perform POST requests to create some resources on another server. The POSTs returns the location of the created resources. It would be useful to retrieve those locations.
Orion doesn't record the responses to notifications it sends. It implements a "fire and forget" approach and pays little attention to the response of notification requests. Actually, Orion looks to the response of the last notification and uses it to set lastFailure or lastSuccess timestamp (depending the case) and setting status to failed if the response has an error code.
A workaround for your case could be achieved using a system in the middle. I mean, some bridging software that receives the notification from Orion, forwards to the final system, gets the response and does whatever processing should be do with such response (e.g. storing the location of the just created resource).

Facebook Instant game bot message often results in "Cannot send Instant Game message to user at this time"

I'm making a Facebook instant game, and am sending myself test messages via the associated bot.
It works. But not always, why?
Very often I get this:
{
"error": {
"message": "(#100) Cannot send Instant Game message to user at this time.",
"type": "OAuthException",
"code": 100,
"error_subcode": 2018144,
"fbtrace_id": "DNZhKZlP83D"
}
}
This error code is not listed in the error code documentation.
I suppose it could be some message sending limit, but I would assume that as the listed developer of the app I would be exempt from any limits.
More details just in case they are relevant
I have subscribed to the webhooks, and created a page associated with my instant game app and have the access token for it. The user I am trying to message is me, listed as the developer.
When I receive a game_play event such as:
{
"object": "page",
"entry": [{
"id": "189899011738553",
"time": 1521899151513,
"messaging": [{
"recipient": {
"id": "189899011738553"
},
"timestamp": 1521899151513,
"sender": {
"id": "1647209385355472"
},
"game_play": {
"game_id": "176650212970169",
"player_id": "1293384810761815"
}
}]
}]
}
I find the sender ID, and send a response like so:
{
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"buttons": [{
"type": "game_play",
"title": "Play"
}],
"title": "Hello World"
}]
}
}
},
"recipient": {
"id": "1647209385355472"
}
}
Here's the cURL version:
curl -X POST \
'https://graph.facebook.com/me/messages?access_token=MY_ACCESS_TOKEN' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{"message": {"attachment": {"type": "template", "payload": {"template_type": "generic", "elements": [{"buttons": [{"type": "game_play", "title": "HELLO"}], "title": "HELLO WORLD"}]}}}, "recipient": {"id": "1647209385355472"}}'
And just to show the access token is valid, despite the "OAuthException", and that it does really sometimes work:
We've ensured that this error is now documented.
This message indicates that the number of messages or time window in which messages are sent to the user of an Instant Game exceeds the Instant Games bot policy.
This applies to developers and administrators as well as users of the app. Playing the game or communicating with the bot should reset these limits.

Error "Empty speech response"

I tried to connect DialogFlow and Actions on Google, so I created some intents, connected the services, added explicit and implicit invocations etc, but when I try the bot in the simulator https://console.actions.google.com/project/[projectId]/simulator/ it always gives me the error:
"Failed to parse Dialogflow response into AppResponse, exception
thrown with message: Empty speech response"
even tough inputType was "KEYBOARD".
What I tried so far:
I did set "Response from this tab will be sent to the Google Assistant integration" in Dialog Flow (do you have to set it for every single intent?), but I don't see any extra setting for speech.
I disabled the second language, first I had also intents in German
I also turned off the Fullfillment Webhook (implemented in API v1 and then also v2) with no change
I only found this user with the same problem https://productforums.google.com/forum/#!topic/dialogflow/xYjKlz31yW0;context-place=topicsearchin/dialogflow/Empty$20speech$20response but no resolution.
the fulfillment checkbox is checked at the intents
The bot works fine when I use it through "Try it now" on the very right in Dialog Flow or in the Web Demo https://bot.dialogflow.com/994dda8b-4849-4a8a-ab24-c0cd03b5f420
Unfortunately the docs don't say anything about this error. Any ideas?
Here a screenshot of the error on the Actions integration:
This is the full debug output:
{
"agentToAssistantDebug": {
"agentToAssistantJson": {
"message": "Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response",
"apiResponse": {
"id": "c12e1389-e887-49d4-b399-a332188ca946",
"timestamp": "2018-01-27T03:55:30.931Z",
"lang": "en-us",
"result": {},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "1517025330705"
}
}
},
"assistantToAgentDebug": {
"assistantToAgentJson": {
"user": {
"userId": "USER_ID",
"locale": "en-US",
"lastSeen": "2018-01-27T03:55:03Z"
},
"conversation": {
"conversationId": "1517025330705",
"type": "NEW"
},
"inputs": [
{
"intent": "actions.intent.MAIN",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "Talk to Mica, the Hipster Cat Bot"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
]
},
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=TOKEN' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: AUTH_TOKEN' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"USER_ID\",\"locale\":\"en-US\",\"lastSeen\":\"2018-01-27T03:55:03Z\"},\"conversation\":{\"conversationId\":\"1517025330705\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to Mica, the Hipster Cat Bot\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}'"
},
"sharedDebugInfo": [
{
"name": "ResponseValidation",
"subDebugEntry": [
{
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
"name": "UnparseableJsonResponse"
}
]
}
]
}
Also "debugInfo" sounds like an internal problem:
"API Version 2: Failed to parse JSON response string with
'INVALID_ARGUMENT' error: \": Cannot find field.\"."
Here a screenshot of the welcome intent:
ps.
It took me AGES to figure out, what
"Query pattern is missing for custom intent"
means - so I just document it here: In Dialog Flow - Intent - "User says" you have to DOUBLE CLICK on a word in the text input field when you want to set it as query parameter - which seems to be required for Actions on Google.
This happened to me. If this happens for an Intent you just added in the Dialogflow console and you are using Webhook fulfillment for the action, check the intent's fulfillment settings and ensure that the Webhook fulfillment slider is on. Evidently new intents don't automatically get webhook fulfillment: you have to opt each one in piecemeal (or at least, that was my experience).
I experienced this situation too.
My problem was that I used a SimpleResponse in my fulfillment index.js without referencing to it. So the solution for me was to add SimpleResponse like this in index.js:
const {dialogflow, SimpleResponse} = require('actions-on-google');
So, always check if you aren't using any dependencies without including it in your js-file.
Probably not the most common cause of the problem, but it can be.
I got this when running through the codelabs tutorial (https://codelabs.developers.google.com/codelabs/actions-1/index.html#4) and didn't name my intent the same name as it is referenced in the webhook script:
I came across this error when trying to develop my own WebHook. I first verified that my code was called by looking into the Nginx log, after which I knew there was a problem in my JSON output because I based my output on outdated examples.
The (up-to-date) documentation for both V1 and V2 of the API can be found here:
https://dialogflow.com/docs/fulfillment/how-it-works
This example response for v2 of the dialogflow webhook API helped me to resolve this error:
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "this is a simple response"
}
}
]
}
}
}
}
Source: https://github.com/dialogflow/fulfillment-webhook-json/blob/master/responses/v2/ActionsOnGoogle/RichResponses/SimpleResponse.json
You can find more examples in the official github repository linked above.
Another possibility is if you have a text response (even an empty one) like so:
Then you need to click the trash can next to the response to clear it out to use the webhook.
The Actions on Google support helped me fix this problem:
I needed to add a text as Default Response to the intent used for Explicit Invocation.

Do Quick Replies Work in Messenger Bot Welcome Message?

Do quick replies work in Facebook Messenger Bot Welcome Message? This is the message that is displayed after you press the "Get Started" button.
It might not be supported, but if it is, am I doing something wrong?
Here's what I'm trying:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Hi dad",
"subtitle": "Hi mom",
"item_url": "www.google.com",
"image_url": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
}]
}
}
},
"quick_replies":[
{
"content_type":"text",
"title":"option1",
"payload":"option1payload"
},
{
"content_type":"text",
"title":"option2",
"payload":"option2payload"
}
]
}
]
}' "https://graph.facebook.com/v2.6/13333333337/thread_settings?access_token=THISISMYCOOLTOKEN"
The error I'm receiving is:
Invalid Keys \"message, quick_replies\" were found in param \"call_to_actions[0]\"."type":"OAuthException","code":100
Nope. payload is only for string text. see https://developers.facebook.com/docs/messenger-platform/thread-settings/get-started-button
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"payload":"USER_DEFINED_PAYLOAD"
}
]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
call_to_actions is limited to 1 call_to_actions must contain at least
one payload string.
This data will be sent back to you via webhook.