Facebook Messenger bot welcome message: 100 The parameter setting_type is required - facebook

I'm trying to set a welcome message for a Facebook Messenger bot using the code provided in the documentation - with my own page ID and page access token
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[{
"message":{
"text":"Hello! This is a Messenger bot!"
}
}]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
This returns the following:
{"error":{"message":"(#100) The parameter setting_type is required","type":"OAuthException","code":100,"fbtrace_id":"B0DKyn9O2KB"}}
Any ideas on how to solve this? Thanks.

I had the same problem! Some strange copy/paste error with the cURL command from fb...
It didn't work with cURL, but then I used "Advanced REST client" (Chrome plugin) and I was able to set the Welcome Message.

I've tried those exact params with my own page and they worked fine.
Can you try these steps?
Get your page ID and a fresh access token from the Facebook developer console
Make the request from https://developers.facebook.com/tools/explorer to make sure it isn't a problem with cURL

I was having the same issue and the reason was just stupid:
I made copy paste from FB doc and some quotes were wrong. They were ” instead of ".
Open your file in vi or something and search for all quotes so that u can easily understand which are wrong.

I had the same issue, i solved it be calling the URL by postman.check image

There seems to be a problem with windows cmd interpreting the commands. Can you try the same code using Cygwin. It worked well for me. Cheers

this is what works for me
curl --location --request POST 'https://graph.facebook.com/v13.0/your_api_id/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your_App_Token' \
--data-raw '{
"messaging_product": "whatsapp",
"preview_url": false,
"recipient_type": "individual",
"to": "33732473829",
"type": "text",
"text": {
"body": "Hello,"
}
}'
I had to specify the access token in the header

Related

Curl command not working for Zapier REST hook

I am making a Zapier App that will contain a basic trigger. I am using REST hook in API configuration. I followed the instructed steps and everything is fine. At the End i get a Webhook URL, when i am creating a Zap.
As per my understanding, i will be using this URL to send POST request. So i use curl terminal command.
curl -X POST -H 'Content-type: application/json' --data '{ message: 'lemon', id: 'abc', season: 'summerTime' }' https://hooks.zapier.com/hooks/catch/7459492/XXXXXX/
I get response
{"id": "8e5bc4fb-a54c-4860-a22f-8896fadc95a1", "request_id": "5eb3c0c0-9a44-4543-81ba-87cd1a0793b0", "attempt": "5eb3c0c0-9a44-4543-81ba-87cd1a0793b0", "status": "success"}
But nothing happens.
This trigger is suppose to print message and season in some slack channel, i.e Zap i created.
Even in task log, no log is generated.
PS: when i do the same POST request with POSTMAN application, it works just
fine. Can anyone tell me what am i doing wrong.
I am new to these stuff.
I believe you're missing quotes around your keys in the data. Try this:
curl -X POST -H 'Content-type: application/json' --data '{ "message": "lemon", "id": "abc", "season": "summerTime" }' https://hooks.zapier.com/hooks/catch/7459492/XXXXXX/
Note that you can "copy as curl" from postman and emulate exactly what it's doing.

Why do i get 400 using AutoML Rest API?

I trained a custom model using Google Cloud AutoML.
Now i am trying to access it, using the script provided by Google.
I tried to vary "content" in any kind of ways.
I also had a look at the information provided here. Surely i did provide the correct path to the key file. Also i checked on the project ID and model ID.
I do have a service account. Billing is enabled too.
export GOOGLE_APPLICATION_CREDENTIALS={key-file-path}
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json" \
https://automl.googleapis.com/v1beta1/projects/{my-project-ID}/locations/us-central1/models/{my-model-id}:predict \
-d '{
"payload" : {
"textSnippet": {
"content": "happy",
"mime_type": "text/plain"
},
}
}'
I expect the result to be the prediction.
My result looks like this:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Expected a value.\n“happy”,\n \n^",
"status": "INVALID_ARGUMENT"}
Thanks for your comments, John Hanley and Phillipp Möhler!
Actually I can't really tell what happened here.
I followed Johns advice to use a whole sentence. Doing that enabled me to successfully predict something!
Afterwards I was able to use both, single words and sentences.
Deleting the commas seems to have no effect at all.

how to change/modify title of an issue when you learn more about the issue/underlying issue itself.

I made a generic title while making a github issue. While trying to explain the issue, I discovered some more details underneath which I could add to the title to explain to the developer better.
I tried to change the title but wasn't able to do that, can modify the body of the message but not the title apparently :(
I tried using [github] modify title or modify heading and few other keywords but couldn't find anything in stackoverflow.com
I even re-read https://guides.github.com/features/issues/ just to see if I missed something when I had read it few years ago.
Looking to know.
Update 2021: you can also use the GitHub CLI gh, instead of curl.
2018:
Considering the GitHub API for Issues does include an "edit issue" which does allow for the title to be modified, this should be possible.
Try (using an OAuth token as shown here):
curl -H 'Authorization: Bearer <your OAuth token>' \
-H "Content-Type: application/json-patch+json" \
-H "Accept: application/json" \
-X PATCH \
https://api.github.com/repos/:owner/:repo/issues/:number \
--data '[{ "title": "a new title" }]'
Or:
curl --request PATCH -H "Authorization: token OAUTH-TOKEN" \
https://api.github.com/repos/:owner/:repo/issues/:number \
--data '[{ "title": "a new title" }]'

Setting the home URL for Facebook chat extension

According to Facebook docs https://developers.facebook.com/docs/messenger-platform/guides/chat-extensions#drawer "To allow your bot to appear in the drawer for people who have added it, you must set its home URL."
I am following the docs https://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting for setting domain white list and then setting the home URL
# add domain to whitelist
curl -X POST -H "Content-Type: application/json" -d '{
"whitelisted_domains":[
$URL
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=$ACCESS_TOKEN"
# set domain as home URL
curl -X POST -H "Content-Type: application/json" -d '{
"home_url" : {
"url": $URL,
"webview_height_ratio": "tall",
"in_test":true
}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=$ACCESS_TOKEN"
for which both return a success message
{
"result":"success"
}
But when I check what is set for the whitelisted domains and the home URL by running
# get home URL
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=home_url&access_token=$ACCESS_TOKEN"
# get existing whitelist domains
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=whitelisted_domains&access_token=$ACCESS_TOKEN"
I am getting a weird response
{"data":[]}%
Am I missing a step or is the response for the get whitelisted domains and Home URL broken?
Turns out the response was not being shown properly in my terminal. I made the same request via postman and it shows the whitelisted domains correctly. Took me a while to figure this out so hopefully this helps anybody with the same issue.

How should I do with CURL in Facebook Messenger Platform(Chatbot)?

I'm working on Facebook chatbot, and I found some difficulties while reading Facebook's official Messenger Platform tutorial.
The frustrating part is here:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"greeting",
"greeting":{
"text":"Timeless apparel for the masses."
}
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
I'm using a Node.js and Heroku. How should I use the code above to make it work?
If you're on OSX you can use the terminal to run the command. On windows you could use Git Bash.
Copy & paste your curl command, replace PAGE_ACCESS_TOKEN with your token from your Facebook Developer App and run it by pressing the enter key.
Hope that helps.