Skip to main content

Example: WhatsApp Images

This article shows how to build a Custom Tool in Frontline that sends an image message using the WhatsApp Cloud API.

Alvaro Vargas avatar
Written by Alvaro Vargas
Updated over a week ago

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

  1. Go to Platform → Tools → Create Tool.

  2. Name: Send WhatsApp Image.

  3. Tool type: Custom Tool.

  4. When to use: e.g., send product photo or receipt.

2) Configure the API request (image URL)

  • Method: POST

  • URL: https://graph.facebook.com/v21.0/{PHONE_NUMBER_ID}/messages

  • Headers:

    • 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_id for reliability when sending the same image frequently.

  • Always include a short caption to give context.


🔍 Troubleshooting

  • 400 Bad Request: Check type = image and that either image.link or image.id is 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_id exists and is linked to your WABA.


Still have questions?

Reach out through the Help button in Frontline or contact your CSM for assistance.

Did this answer your question?