More Facebook message formats
In this section, we will explore other Facebook message formats besides text. In the previous example, we programmed the chatbot to send text responses back to the user. However, Facebook has more formats that can be used to provide a richer experience to the user. You can do this by changing the content of the message
element in the POST
request in the sendTextMessage()
method in the index.js
file.
Content types
Besides text, other content types such as images, audio and video clips, and files can be sent to users.
Image attachments
Images in JPEG, PNG, and GIF formats can be sent to the user using the following format for message content:
"message":{
"attachment":{
"type":"image",
"payload":{
"url":"https://myimagelibrary.com/ijustwannadrawsomething.jpg"
}
}
}
Audio attachments
Audio clips can be sent to the user using the following message
element:
"message":{
"attachment":{
"type":"audio",
"payload":{
...