Skip to main content

Twilio Integration

Send WhatsApp messages programmatically with Twilio integration for both free-form and template-based messaging.


Timbal integrates with Twilio to enable sending WhatsApp messages programmatically.

This integration allows you to send both free-form and template-based WhatsApp messages directly from your Timbal workflows.

Prerequisites

Before using the Twilio integration, you'll need:

  1. A Twilio account – Sign up here
  2. A WhatsApp-enabled Twilio phone number
  3. Your Twilio Account SID, Auth Token, and WhatsApp From number
  4. Store your credentials in environment variables: TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_PHONE_NUMBER

Send WhatsApp Message

Description

The send_whatsapp_message step allows you to send a free-form WhatsApp message to a user.

Example

from timbal.steps.twilio.whatsapp import send_whatsapp_message
await send_whatsapp_message(
to="+1234567890",
message="Hello from Timbal!"
)

Parameters

ParameterTypeDescriptionRequired
tostrThe WhatsApp account to send the message to in E.164 formatYes
messagestrThe message to send (max 1600 characters; longer messages will be split)Yes

Send WhatsApp Template

Description

The send_whatsapp_template step allows you to send a pre-approved WhatsApp template message to a user, with parameters.

Example

from timbal.steps.twilio.whatsapp import send_whatsapp_template
await send_whatsapp_template(
to="+1234567890",
template_sid="your-template-sid",
template_params={"name": "John"}
)

Parameters

ParameterTypeDescriptionRequired
tostrThe WhatsApp account to send the message to in E.164 formatYes
template_sidstrThe template SID to send the message withYes
template_paramsdictParameters to fill in the template (must match template definition)Yes

Agent Integration Example

from timbal.steps.twilio.whatsapp import send_whatsapp_message
from timbal import Agent
agent = Agent(
tools=[send_whatsapp_message]
)
response = await agent.complete(
prompt={
"to": "+1234567890",
"message": "Hello from Agent!"
}
)

Notes