Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

Twilio

This notebook goes over how to use theTwilio API wrapper to send a message through SMS orTwilio Messaging Channels.

Twilio Messaging Channels facilitates integrations with 3rd party messaging apps and lets you send messages through WhatsApp Business Platform (GA), Facebook Messenger (Public Beta) and Google Business Messages (Private Beta).

Setup

To use this tool you need to install the Python Twilio packagetwilio

%pip install--upgrade--quiet  twilio

You'll also need to set up a Twilio account and get your credentials. You'll need your Account String Identifier (SID) and your Auth Token. You'll also need a number to send messages from.

You can either pass these in to the TwilioAPIWrapper as named parametersaccount_sid,auth_token,from_number, or you can set the environment variablesTWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN,TWILIO_FROM_NUMBER.

Sending an SMS

from langchain_community.utilities.twilioimport TwilioAPIWrapper
API Reference:TwilioAPIWrapper
twilio= TwilioAPIWrapper(
# account_sid="foo",
# auth_token="bar",
# from_number="baz,"
)
twilio.run("hello world","+16162904619")

Sending a WhatsApp Message

You'll need to link your WhatsApp Business Account with Twilio. You'll also need to make sure that the number to send messages from is configured as a WhatsApp Enabled Sender on Twilio and registered with WhatsApp.

from langchain_community.utilities.twilioimport TwilioAPIWrapper
API Reference:TwilioAPIWrapper
twilio= TwilioAPIWrapper(
# account_sid="foo",
# auth_token="bar",
# from_number="whatsapp: baz,"
)
twilio.run("hello world","whatsapp: +16162904619")

Related


[8]ページ先頭

©2009-2025 Movatter.jp