Search code examples
unificationengine

How to send a message from unificationengine to fbmessenger?


I have added a fbmessenger to my app using facebook app id and secret.

How to send a message from unificationengine to fbmessenger?


Solution

  • For sending message to fbmessenger you need a pageScopeId (sender id). It is the address (sender id) between the Facebook user and page.

    Replace the following parameters


    PAGE_SCOPE_ID: replace PAGE_SCOPE_ID

    MESSAGE_CONTENT: replace MESSAGE_CONTENT with actual message content

    MESSAGE_CONTENT_SIZE: character length of the MESSAGE_CONTENT including space

    IMAGE_LINK: replace IMAGE_LINK with an image link (eg: http://www.velior.ru/wp-content/uploads/2009/05/Test-Computer-Key-by-Stuart-Miles.jpg)

    IMAGE_LINK_SIZE: character length of the IMAGE_LINK

    Command


    curl -XPOST https://apiv2.unificationengine.com/v2/message/send --data "{ \"message\": { \"receivers\": [{\"name\": \"Page\", \"address\": \"PAGE_SCOPE_ID\" , \"Connector\": \"boschFbmessenger\" }],\"parts\": [{\"id\": \"1\",\"contentType\": \"text/plain\", \"data\":\"MESSAGE_CONTENT\" ,\"size\": MESSAGE_CONTENT_SIZE,\"type\": \"body\",\"sort\":0},{\"id\": \"0\", \"contentType\": \"text/plain\" , \"size\": IMAGE_LINK_SIZE,\"type\": \"image_link\", \"name\":\"file name\",\"data\":\"IMAGE_LINK\",\"sort\":1}]}}" -u USER_ACCESSKEY:USER_ACCESSSECRET -k