Example: WhatsApp Images
This article shows how to build a Custom Tool in Frontline that sends an image message using the WhatsApp Cloud API. You can use an image link (URL) or a previously uploaded media ID.
Notes:
Session rule: Free‑form image messages require the user to be within the 24‑hour service window. For outside‑window use cases, send a template with media.
Media hosting: If you don’t have a media ID, use a public, HTTPS image URL.
⚙️ What you’ll need
Phone Number ID (Cloud API).
A valid Access Token.
Recipient phone in E.164 format.
One of: an image URL or a media ID (uploaded via Graph API’s media endpoint).
🚀 Step‑by‑step in Frontline
1) Create the Custom Tool
Go to Platform → Tools → Create Tool.
Name: Send WhatsApp Image.
Tool type: Custom Tool.
When to use: e.g., send product photo or receipt.
2) Configure the API request (image URL)
Method:
POSTURL:
https://graph.facebook.com/v21.0/{PHONE_NUMBER_ID}/messagesHeaders:
Authorization: Bearer {ACCESS_TOKEN}Content-Type: application/json
Request Body (URL example):
{ "messaging_product": "whatsapp", "to": "{phone}", "type": "image", "image": { "link": "https://example.com/images/product-123.jpg", "caption": "Here is your product image" } }Alternative: Using a media ID
If you have already uploaded the file and obtained a media_id, use:
{ "messaging_product": "whatsapp", "to": "{phone}", "type": "image", "image": { "id": "{media_id}", "caption": "Invoice #12345" } }3) Add data inputs
Create inputs like phone, and optionally image_url or media_id, so your Agent can dynamically populate them.
4) Test and save
Use Test Response and confirm the image arrives on the device. Then Save Tool.
✅ Best practices
Use optimized images (≤ 2–3 MB) to reduce delivery time.
Prefer
media_idfor reliability when sending the same image frequently.Always include a short caption to give context.
🔍 Troubleshooting
400 Bad Request: Check
type = imageand that eitherimage.linkorimage.idis present (not both).401/403: Verify token and permissions for your Phone Number ID.
Image not showing: Ensure the URL is publicly reachable via HTTPS or the
media_idexists and is linked to your WABA.
Still have questions?
Reach out through the Help button in Frontline or contact your CSM for assistance.
