Search code examples
facebook-messenger-bot

How to use attachment_id from new Upload API?


According the docs for the Messenger Platform 1.4, the Upload API returns an attachment_id for the uploaded attachment:

{
   "attachment_id":"1854626884821032"
}

How do we use this attachment_id to send attachments? Or does simply sending another message with an attachment from the same URL result in messenger using the uploaded attachment?


Solution

  • You should use

    $imageAttachment = array('type' => 'image'``, 'payload' =>   array('attachment_id' =>  '1854626884821032'));
    
    $params = array('message' => array('attachment' => $imageAttachment), "recipient" => array("id" => $senderId));
    

    and the make a Curl as specified here

    https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment