Setting the home URL for Facebook chat extension - facebook

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.

Related

Saving a list of a public Github repo contributors using curl

I'm trying to get a list of contributors to a public GitHub repo, saved as a text file.
curl -H "Authorization: token mytoken" https://api.github.com/repos/v2fly/v2ray-core/contributors&per_page=100 >> output.txt
I get the output in the terminal, but not to the file. Also, the request doesn't seem to close. What am I doing wrong?
I guess the API URL is incorrect. That per_page querystring needs to be passed after putting "?" after URL, You can try this
curl -H "Authorization: token mytoken" https://api.github.com/repos/v2fly/v2ray-core/contributors?per_page=100 >> output.txt

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.

Cant set greeting message or 'Get Started' button for facebook chatbot after once set

I am trying to edit the Greeting message for my FB Chatbot, the commands are resulting success but the welcome message does not change.
Also, the Get Started button: i could set it successfully for the first time but after once deleting, button is not appearing even though the command results success everytime.
code to set greeting message:
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"
for deleting the greeting Message
curl -X DELETE -H "Content-Type: application/json" -d '{
"setting_type":"greeting"
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
for adding GetStarted Button
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=PAGE_ACCESS_TOKEN"
for deleting GetStarted button:
curl -X DELETE -H "Content-Type: application/json" -d '{
"fields":[
"get_started"
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=PAGE_ACCESS_TOKEN"
I am using Terminal to run these commands.
I could solve it, I had not updated the page access token on the server. So, facebook could return success everytime i updated the greeting message but server was communicating with the old token.
Then why could i still chat with my chatbot when the server has old token. A bit confusing for me.

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

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

Https Error in Postman when Send push notification via Rest

I'm fairly new To Parse with Rest Api
I wanna test samples in Their Webistes's ( Here ) in Postman But every time I Post it gives me following Authentication error :
I Wanna test following code in Postman ( see origin here )
curl -X POST \
-H "X-Parse-Application-Id: 0VoIZO8cgmnyfiuklLLkKkxOX7r" \
-H "X-Parse-REST-API-Key: UjU5eb5zjic75mPZVdHExYqnneT" \
-H "Content-Type: application/json" \
-d '{
"deviceType": "ios",
"deviceToken": "0123456789abcdef0123456789cdef0123456789abcdef",
"channels": [
""
]
}' \
https://api.parse.com/1/installations
How Can I resolve this issue ? What is that ? And What is required ?
You are reqeuesting GET request and api doc says its POST request.
1) Enter correct url and select POST request method. Add required headers as per the doc.
2) Enter raw JSON data in your request body.
3) You will receive your output. Since api key and application id is not valid so that I received unauthorized error.