TwilioTools enables an Agent to interact with Twilio services, such as sending SMS, retrieving call details, and listing messages.

Prerequisites

The following examples require the twilio library and appropriate Twilio credentials, which can be obtained from here.

pip install twilio

Set the following environment variables:

export TWILIO_ACCOUNT_SID=***
export TWILIO_AUTH_TOKEN=***

Example

The following agent will send an SMS message using Twilio:

from agno.agent import Agent
from agno.tools.twilio import TwilioTools

agent = Agent(
    instructions=[
        "Use your tools to send SMS using Twilio.",
    ],
    tools=[TwilioTools(debug=True)],
    show_tool_calls=True,
)

agent.print_response("Send an SMS to +1234567890", markdown=True)

Toolkit Params

NameTypeDefaultDescription
account_sidOptional[str]NoneTwilio Account SID for authentication.
auth_tokenOptional[str]NoneTwilio Auth Token for authentication.
api_keyOptional[str]NoneTwilio API Key for alternative authentication.
api_secretOptional[str]NoneTwilio API Secret for alternative authentication.
regionOptional[str]NoneOptional Twilio region (e.g., au1).
edgeOptional[str]NoneOptional Twilio edge location (e.g., sydney).
debugboolFalseEnable debug logging for troubleshooting.

Toolkit Functions

FunctionDescription
send_smsSends an SMS to a recipient. Takes recipient phone number, sender number (Twilio), and message body. Returns message SID if successful or error message if failed.
get_call_detailsRetrieves details of a call using its SID. Takes the call SID and returns a dictionary with call details (e.g., status, duration).
list_messagesLists recent SMS messages. Takes a limit for the number of messages to return (default 20). Returns a list of message details (e.g., SID, sender, recipient, body, status).

Developer Resources