Skip to content

Commit

Permalink
Detailed using the Twilio tool to send messages with 3rd party apps i…
Browse files Browse the repository at this point in the history
…ncl. WhatsApp (#6562)

Everything needed to support sending messages over WhatsApp Business
Platform (GA), Facebook Messenger (Public Beta) and Google Business
Messages (Private Beta) was present. Just added some details on
leveraging it.
  • Loading branch information
movaid7 authored Jun 22, 2023
1 parent b8d7842 commit ae81b96
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
62 changes: 60 additions & 2 deletions docs/extras/modules/agents/tools/integrations/twilio.ipynb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{
"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 text message."
"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": {},
Expand All @@ -31,6 +35,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f7e883ae",
"metadata": {},
Expand All @@ -41,11 +46,12 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "36c133be",
"metadata": {},
"source": [
"## Sending a message"
"## Sending an SMS"
]
},
{
Expand Down Expand Up @@ -81,6 +87,58 @@
"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.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": {
Expand Down
2 changes: 1 addition & 1 deletion langchain/utilities/twilio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class TwilioAPIWrapper(BaseModel):
"""Sms Client using Twilio.
"""Messaging Client using Twilio.
To use, you should have the ``twilio`` python package installed,
and the environment variables ``TWILIO_ACCOUNT_SID``, ``TWILIO_AUTH_TOKEN``, and
Expand Down

1 comment on commit ae81b96

@vercel
Copy link

@vercel vercel bot commented on ae81b96 Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

langchain – ./

langchain-langchain.vercel.app
langchain-git-master-langchain.vercel.app
python.langchain.com

Please sign in to comment.