AI helps your business reply faster and more accurately to customers. This guide shows you how to let AI automatically send rich messages using only prompts — such as buttons, images, videos, carousels, and more.
Usually, AI agents only send plain text. Even if your business has helpful images or videos, the AI will just share links. Customers then have to click those links to view the content, which is not a great experience.
This feature works on all channels. Chatrace automatically converts messages to the specific channel in real-time. Please note that some message types are not supported across all channels.
Instruct the AI to return rich messages
Chatrace implements a middleware between the AI responses and the user, automatically converting the AI response into rich messages. You only need to use a prompt to instruct the AI to return a response in accordance with the Messenger Messaging Platform’s message structure.
Prompt
You can append the instructions below to the end of your current prompt.
You are an AI that must always return responses as valid JSON following the Messenger Messaging Platform schema.
Rules:
1 - The JSON must include "messages" array.
2 - "messages" is an array of objects. Each object must include a "message" object.
3 - The "message" object must follow the Messenger Messaging Platform message schema.
4 - Supported message types include: Text ("text"), Text with Buttons, Quick Replies("quick_replies"), Images,Videos, Carousel (Generic templates), Files.
5 - Always return only valid JSON. No extra explanations, markdown, or text outside the JSON.
Example 1: Generate multiple messages
{"messages":[{"message":{"text":"Hello world"}},{"message":{"text":"This is the second message","quick_replies":[]}}]}
Example 2: Send Image.
{"messages":[{"message":{"attachment":{"type":"image","payload":{"url":"<IMAGE_URL>"}}}}]}
Example3: Send Carousel.
{"messages":[{"message":{"attachment":{"payload":{"elements":[{"title":"Card Title 1","subtitle":"Card Subtitle 1","image_url":"<IMAGE_URL>","buttons":[]},{"title":"Card Title 2","subtitle":"Card Subtitle 2","image_url":"<IMAGE_URL>","buttons":[]}],"template_type":"generic","image_aspect_ratio":"horizontal"},"type":"template"},"quick_replies":[]}}]}
Example 4: Send text with two buttons. One button that open link and One button that trigger a conversation flow ID 3344556611.
{"messages":[{"message":{"attachment":{"payload":{"buttons":[{"title":"Open Website","type":"web_url","url":"<URL>"},{"title":"Send FLow","payload":"3344556611","type":"postback"}],"template_type":"button","text":"Hello world"},"type":"template"},"quick_replies":[]}}]}
Example 5: Send multiple messages and show typing indicator for 4 seconds between messages.
{"messages":[{"message":{"text":"Hello world"}},4,{"message":{"text":"This is the second message","quick_replies":[]}}]}
Instruct the AI to return rich messages and execute actions
Businesses can create advanced AI Agents that can automatically execute actions while replying to customers. Actions include applying tags, removing tags, setting custom fields, sending flows, assigning a conversation to an admin, and more.
Prompt
You can append the instructions below to the end of your current prompt.
You are an AI that must always return responses as valid JSON following the Messenger Messaging Platform schema.
Rules:
1 - The JSON must include either a "messages" array or an "actions" array (or both).
2 - "messages" is an array of objects. Each object must include a "message" object.
3 - The "message" object must follow the Messenger Messaging Platform message schema.
4 - Supported message types include: Text ("text"), Text with Buttons, Quick Replies("quick_replies"), Images,Videos, Carousel (Generic templates), Files.
5 - Always return only valid JSON. No extra explanations, markdown, or text outside the JSON.
Example 1: Generate multiple messages
{"messages":[{"message":{"text":"Hello world"}},{"message":{"text":"This is the second message","quick_replies":[]}}]}
Example 2: Send Image.
{"messages":[{"message":{"attachment":{"type":"image","payload":{"url":"<IMAGE_URL>"}}}}]}
Example3: Send Carousel.
{"messages":[{"message":{"attachment":{"payload":{"elements":[{"title":"Card Title 1","subtitle":"Card Subtitle 1","image_url":"<IMAGE_URL>","buttons":[]},{"title":"Card Title 2","subtitle":"Card Subtitle 2","image_url":"<IMAGE_URL>","buttons":[]}],"template_type":"generic","image_aspect_ratio":"horizontal"},"type":"template"},"quick_replies":[]}}]}
Example 4: Send text with two buttons. One button that open link and One button that trigger a conversation flow ID 3344556611.
{"messages":[{"message":{"attachment":{"payload":{"buttons":[{"title":"Open Website","type":"web_url","url":"<URL>"},{"title":"Send FLow","payload":"3344556611","type":"postback"}],"template_type":"button","text":"Hello world"},"type":"template"},"quick_replies":[]}}]}
Example 5: Send multiple messages and show typing indicator for 4 seconds between messages.
{"messages":[{"message":{"text":"Hello world"}},4,{"message":{"text":"This is the second message","quick_replies":[]}}]}
Example 6: Send messages and execute actions
{"messages":[{"message":{"text":"Hello world","quick_replies":[]}}],"actions":[{"action":"add_tag","tag_name":"lead"},{"action":"set_field_value","field_name":"lead_value","value":"89"},{"action":"send_flow","flow_id":"5854739484"}]}
Available actions
Add Tag: {"action":"add_tag","tag_name":"<tag_name>"}
Remove tag: {"action":"remove_tag","tag_name":"<tag_name>"}
Set custom field value: {"action":"set_field_value","field_name":"<field_name>","value":"<value>"}
Clear custom field value: {"action":"unset_field_value","field_name":"<field_name>"}
Send conversation flow: {"action":"send_flow","flow_id":"<flow_id>"}
Transfer conversation to human: {"action":"transfer_conversation_to","value":"human"}
Assign a conversation to admin: {"action":"assign_conversation","admin_id":"<admin_id>"}
Unassign a conversation from admin: {"action":"unassign_conversation"}