Files
langchain/docs/versioned_docs/version-0.2.x/integrations/tools/twilio.ipynb
Jacob Lee aff771923a Jacob/new docs (#20570)
Use docusaurus versioning with a callout, merged master as well

@hwchase17 @baskaryan

---------

Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
Signed-off-by: Rahul Tripathi <rauhl.psit.ec@gmail.com>
Co-authored-by: Leonid Ganeline <leo.gan.57@gmail.com>
Co-authored-by: Leonid Kuligin <lkuligin@yandex.ru>
Co-authored-by: Averi Kitsch <akitsch@google.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
Co-authored-by: Nuno Campos <nuno@langchain.dev>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Co-authored-by: Martín Gotelli Ferenaz <martingotelliferenaz@gmail.com>
Co-authored-by: Fayfox <admin@fayfox.com>
Co-authored-by: Eugene Yurtsev <eugene@langchain.dev>
Co-authored-by: Dawson Bauer <105886620+djbauer2@users.noreply.github.com>
Co-authored-by: Ravindu Somawansa <ravindu.somawansa@gmail.com>
Co-authored-by: Dhruv Chawla <43818888+Dominastorm@users.noreply.github.com>
Co-authored-by: ccurme <chester.curme@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
Co-authored-by: WeichenXu <weichen.xu@databricks.com>
Co-authored-by: Benito Geordie <89472452+benitoThree@users.noreply.github.com>
Co-authored-by: kartikTAI <129414343+kartikTAI@users.noreply.github.com>
Co-authored-by: Kartik Sarangmath <kartik@thirdai.com>
Co-authored-by: Sevin F. Varoglu <sfvaroglu@octoml.ai>
Co-authored-by: MacanPN <martin.triska@gmail.com>
Co-authored-by: Prashanth Rao <35005448+prrao87@users.noreply.github.com>
Co-authored-by: Hyeongchan Kim <kozistr@gmail.com>
Co-authored-by: sdan <git@sdan.io>
Co-authored-by: Guangdong Liu <liugddx@gmail.com>
Co-authored-by: Rahul Triptahi <rahul.psit.ec@gmail.com>
Co-authored-by: Rahul Tripathi <rauhl.psit.ec@gmail.com>
Co-authored-by: pjb157 <84070455+pjb157@users.noreply.github.com>
Co-authored-by: Eun Hye Kim <ehkim1440@gmail.com>
Co-authored-by: kaijietti <43436010+kaijietti@users.noreply.github.com>
Co-authored-by: Pengcheng Liu <pcliu.fd@gmail.com>
Co-authored-by: Tomer Cagan <tomer@tomercagan.com>
Co-authored-by: Christophe Bornet <cbornet@hotmail.com>
2024-04-18 11:10:55 -07:00

166 lines
4.0 KiB
Plaintext

{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "dc23c48e",
"metadata": {},
"source": [
"# Twilio\n",
"\n",
"This notebook goes over how to use the [Twilio](https://www.twilio.com) API wrapper to send a message through SMS or [Twilio Messaging Channels](https://www.twilio.com/docs/messaging/channels).\n",
"\n",
"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)."
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c1a33b13",
"metadata": {},
"source": [
"## Setup\n",
"\n",
"To use this tool you need to install the Python Twilio package `twilio`"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "98b544b9",
"metadata": {},
"outputs": [],
"source": [
"%pip install --upgrade --quiet twilio"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f7e883ae",
"metadata": {},
"source": [
"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.\n",
"\n",
"You can either pass these in to the TwilioAPIWrapper as named parameters `account_sid`, `auth_token`, `from_number`, or you can set the environment variables `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN`, `TWILIO_FROM_NUMBER`."
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "36c133be",
"metadata": {},
"source": [
"## Sending an SMS"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "54bf5afd",
"metadata": {},
"outputs": [],
"source": [
"from langchain_community.utilities.twilio import TwilioAPIWrapper"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "31f8f382",
"metadata": {},
"outputs": [],
"source": [
"twilio = TwilioAPIWrapper(\n",
" # account_sid=\"foo\",\n",
" # auth_token=\"bar\",\n",
" # from_number=\"baz,\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5009d763",
"metadata": {},
"outputs": [],
"source": [
"twilio.run(\"hello world\", \"+16162904619\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "de022dc9",
"metadata": {},
"source": [
"## Sending a WhatsApp Message"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "a594d0bc",
"metadata": {},
"source": [
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "94508aa0",
"metadata": {},
"outputs": [],
"source": [
"from langchain_community.utilities.twilio import TwilioAPIWrapper"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e4b81750",
"metadata": {},
"outputs": [],
"source": [
"twilio = TwilioAPIWrapper(\n",
" # account_sid=\"foo\",\n",
" # auth_token=\"bar\",\n",
" # from_number=\"whatsapp: baz,\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1181041b",
"metadata": {},
"outputs": [],
"source": [
"twilio.run(\"hello world\", \"whatsapp: +16162904619\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}