Search code examples
facebookfacebook-messengerfacebook-messenger-bot

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?


Solution

  • 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.