7
votes

the bash command I used to connect the bot is: curl -ik -X POST 'https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken'

My error message is:

{"error":{"message":"(#100) The parameter recipient is required","type":"OAuthException","code":100,"fbtrace_id":"EFqWAGq2ABs"}}

Do anyone how to solve it ?

8
Provide the parameter it's told you is required? - jonrsharpe
Actually @jonrsharpe I have the same issue, you get this error even when recipient is available - Dany Y

8 Answers

5
votes

Just in case anyone missed this, I encountered this issue when I accidentally use the wrong content type - I was using application/x-www-form-urlencoded instead of application/json

So my advise overall is,

  • Check if you are indeed passing the parameter
  • Double check the characters and encoding
  • Make sure to use the correct endpoint
  • and Make sure to use the correct content type when posting the JSON Request.
3
votes

You need to send the recipient id param. Try:

curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"YOUR RECIPIENT ID" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=YOUR_ACCESSTOKEN"

Best regards.

1
votes

There is another reason for this error message: when you send incorrect characters (like a -tab-) Facebook return this error as well so check your return text on special chars.

1
votes

Please use the "thread_settings" endpoint "https://graph.facebook.com/v2.6/me/thread_settings" as your API endpoint.

You are using the messages endpoint.

1
votes

It comes down to the logic of your bot. I got this error as well just recently and it took me days to debug it. The problem for me was I called the callSendAPI(messageData) method outside of the function that compiled the messageData object.

Obviously, passing messageData outside of the function that compiles it sends an empty object instead of the compiled one. Thus the error message (#100) The parameter recipient is required. Simply because the empty object doesn't have any receipientId defined.

Please check your code's logic to ensure you didn't do the same mistake as I. Hope this helps :) Happy programming.

1
votes

The endpoint is wrong. Instead of https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken, use this endpoint

https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>

This happens when we do not read the documentation., the info is right here https://developers.facebook.com/docs/messenger-platform/discovery/welcome-screen#, right under the "Setting the Get Started Button Postback".

1
votes

I got similar error some time back. Try using Postman. I tried the same request and replaced the user id and the page access token. It works fine.

Click on the Import button on the top and paste your curl request under raw. Then try running the call. If you get the same error, go to the body and modify it. Make sure you put this in the body part of the Postman request. Replace the recipient id with yours.

{
    "recipient":
    {
        "id":"123456789"
    },
    "message":
    {
        "text":"hello, world!"
    }

}

This is the full cURL call : Change Recipient ID and Page Access Token

curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"1234567" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=PASTETHETOKENHERE"
0
votes

This issue may also occur when you have an error in your code (syntax or logic error). In my case, I had this part in my code in webhook.php (which is my registered callback page in Facebook)

$message = $input['entry'][0]['messaging'][0]['message']['text'];

"message":{
    "text":"Sorry, we currently do not have an article related to "'.$message.'"."
    }

By the time I registered https://domain.com/webhook.php as callback, it wouldn't receive any $message yet so it causes an error and wouldn't accept my callback url.

Check your code and make sure you echo only the challenge.

$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];

if ($verify_token === 'verify_token') {
    echo $challenge;
}