Do Quick Replies Work in Messenger Bot Welcome Message? - facebook

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.

Related

Get date of review request from GitHub API

How do I get the timestamp at which a PR review was request/re-requested? It shows as an event in the conversations tab in a PR so it must exist somewhere.
The pulls API endpoint show who has been requested to review but I can't see when.
"requested_reviewers": [
{
"login": "tamlyn",
...
},
],
Any ideas?
You're looking for the GitHub Timeline API. See the docs for the Timeline API here.
Request:
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/timeline
Response:
...
{
"id": "12345",
...
"actor": {
"login": "user",
...
},
"event": "review_requested",
"created_at": "2022-01-01T01:01:01Z",
...
"review_requester": {
"login": "user",
...
},
"requested_reviewer": {
"login": "user2",
...
},
...
},
...

dynamic_template_data not working when sending dynamic template using curl request - Sendgrid API

I'm making a curl request to send dynamic template with handlebar but it's not working properly.
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header 'Authorization: Bearer SG.xxxxxxxx.v-8xxxxxxxxxxxxI' \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": "mrrobot#mail.com"}]}],"from": {"email": "contact#evilcorp.com"},"dynamic_template_data":{"fname":"elliot"}, "subject": "Hello, World!","content": [{"type": "text/html", "value": "Heya!"}], "template_id" : "d-xxxxxxxxxa1f"}}'
In my dynamic template I've used fname as {{fname}} but it's coming as empty when I make the curl request.
dynamic_template_data should be inside personalizations.
E.g:
{
"personalizations": [
{
"to": [
{
"email": "mrrobot#mail.com"
}
],
"dynamic_template_data": {
"fname": "elliot"
}
}
],
"from": {
"email": "contact#evilcorp.com"
},
"subject": "Hello, World!",
"content": [
{
"type": "text/html",
"value": "Heya!"
}
],
"template_id": "d-xxxxxxxxxa1f"
}

FireStore REST API: How to add a subcollection to a document using REST commands?

Using FireStore's REST API documented at: https://firebase.google.com/docs/firestore/reference/rest
I'm trying to create a new document in "users" that has a subcollection named "subcol1" with an empty doc in it called "subdoc1"
However, the following REST command to create the new document does not work:
curl -X POST
-H "Content-Type: application/json"
-d "{ 'fields': { 'subcol1': [{'subdoc1': { 'fields': {} } }] } }"
"https://firestore.googleapis.com/v1/projects/XXXX/databases/(default)/documents/users"
How does one add a subcollection to a new document (or existing one?) using FireStore's REST API?
I specifically have to use REST for this implementation.
This is the error response I get back:
{ "error": {
"code": 400,
"message": "Invalid value at 'document.fields[0].value' (Map), Cannot have repeated items ('subcol1') within a map.\nInvalid JSON payload received. Unknown name \"\" at 'document.fields[0].value': Proto fields must have a name.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.fields[0].value",
"description": "Invalid value at 'document.fields[0].value' (Map), Cannot have repeated items ('subcol1') within a map."
},
{
"field": "document.fields[0].value",
"description": "Invalid JSON payload received. Unknown name \"\" at 'document.fields[0].value': Proto fields must have a name."
}
]
}
] } }
Thanks!
After more tinkering with this, I found a solution.
The following works:
First create the new document (without the subcollection).
Next create the subdocument using the "not-yet-created" subcollection's URL.
So first create the new "top-level" doc:
curl -X POST
-H "Content-Type: application/json"
-d "{ 'fields': { } }"
"https://firestore.googleapis.com/v1/projects/XXXX/databases/(default)/documents/users"
Then create the subdoc (which "creates" the subcollection):
curl -X POST
-H "Content-Type: application/json"
-d "{ 'fields': { } }"
"https://firestore.googleapis.com/v1/projects/XXXX/databases/(default)/documents/
users/<USER-KEY-FROM-PREVIOUS-JSON-RESPONSE>/subcol1"

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

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.

Orion notification complex payload

I'm trying to use Orion notification to send SMS with Plivo.
This is how I send an SMS directly with Plivo:
curl -X POST https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1/Message/ -L -u MAMDA5ZDJIM:YzhiNDJjODNhNDkxMjhiYTgxZD -H 'Content-Type: application/json' -d #- <<EOF
{
"src": "0039414141414",
"dst": "0039414747111",
"text": "test SMS"
}
EOF
How should I encode it in Orion? I tried:
curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d #- <<EOF
{
"description": "A subscription to get info about WS_UPPA_Sensor2",
"subject": {
"entities": [
{
"id": "Sensor1",
"type": "SensingDevice"
}
],
"condition": {
"attrs": [
"temperature"
]
}
},
"notification": {
"httpCustom": {
"url": "https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1NZVMZD/Message/",
"headers": {
"Authorization": "Basic TUFNREE1WkRKSU1ETTFOWlZNWkQ6WXpoaU5ESmpPRE5oTkRreE1qaGlZVGd4WkRkaE5qYzNPV1ZsTnpZMA=="
},
"payload": "{%22src%22%3A%2200393806412092%22%2C%22dst%22%3A%2200393806412093%22%2C%22text%22%3A%22test%20SMS%20from%20Waziup%22}"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
Is there another way than percent encoding?
URL encoding (I understand is the one you refer by "percent encoding") is the only one which have an special treatment in custom notifications (details described as part of the Orion documentation).
In fact, taking into account the existing one is complete (I mean, any text can be expressed in the terms of URL encoding) there is no need of adding any other.