Is there any python code examples and docs for livekit agents sending sms?
LiveKit Agents doesn’t provide native SMS functionality, but it’s straightforward to implement using a function tool that calls Twilio’s API.
from twilio.rest import Client
from livekit.agents import function_tool, RunContext
@function_tool
async def send_sms(context: RunContext, to: str, message: str):
"""Send an SMS to the given phone number."""
client = Client(account_sid, auth_token)
client.messages.create(
body=message,
from_=twilio_number,
to=to,
)
return f"SMS sent to {to}"
Once this tool is added to your agent’s tool list, the agent can invoke it whenever it determines that an SMS should be sent.
Reference: