langchain-plivo-tools
Plivo SMS and voice tools for LangChain agents. An agent sends text messages and places phone calls through Plivo.
| Capability | Detail |
|---|---|
| Send SMS | An agent sends a text message and receives the Plivo message UUID |
| Place calls | An agent dials a number, with optional text spoken when the call connects |
| Toolkit | PlivoToolkit returns every tool the current configuration supports |
| Credentials | Read from the environment or passed to the constructor, held as SecretStr |
Requirements
| Requirement | Detail |
|---|---|
| Python | 3.10 or later |
| Plivo account | Auth ID and Auth Token from the Plivo console |
| Plivo number | In E.164 format, enabled for SMS, voice, or both |
| Answer URL | Required by PlivoMakeCall only. An endpoint returning Plivo XML, described under The Answer URL contract |
Installation
pip install langchain-plivo-tools
Upgrading from 0.1.0
The two tool classes lost their Tool suffix in 0.2.0 to match the naming used
across LangChain tool packages.
| 0.1.0 | 0.2.0 |
|---|---|
PlivoSendMessageTool |
PlivoSendMessage |
PlivoMakeCallTool |
PlivoMakeCall |
The old names still import and resolve to the renamed classes, raising a
DeprecationWarning. They are scheduled for removal in 0.3.0. The tool names
the model sees, plivo_send_message and plivo_make_call, are unchanged, so
agent behaviour does not shift on upgrade.
Setup
Set the Plivo credentials as environment variables, or pass them to the tool directly.
export PLIVO_AUTH_ID="your-auth-id"
export PLIVO_AUTH_TOKEN="your-auth-token"
export PLIVO_FROM_NUMBER="+14155551234"
The Auth ID and Auth Token are on the Plivo console dashboard. The from number must be a Plivo phone number in E.164 format, enabled for SMS, voice, or both.
Send an SMS
from langchain_plivo_tools import PlivoSendMessage
tool = PlivoSendMessage()
tool.invoke({"body": "Your order has shipped.", "to": "+14155551234"})
Credentials can also be passed in code instead of the environment.
tool = PlivoSendMessage(
auth_id="your-auth-id",
auth_token="your-auth-token",
from_number="+14155551234",
)
The tool returns the Plivo message UUID on success. Numbers use E.164 format.
Make a call
PlivoMakeCall places a phone call. Plivo answers the call by fetching an Answer URL that returns Plivo XML, so that endpoint has to be hosted separately. Its address goes in PLIVO_ANSWER_URL, alongside the credentials above, or is passed as answer_url to the tool.
from langchain_plivo_tools import PlivoMakeCall
tool = PlivoMakeCall()
tool.invoke({"to": "+14155551234", "message": "Your monitor is down."})
The Answer URL contract
When the call connects, Plivo fetches the Answer URL and expects a Plivo XML document in response. The URL is fetched with GET by default, because the optional message argument is appended to it as a message query parameter. The endpoint reads that parameter and returns XML that speaks it. A minimal response looks like this.
<Response><Speak>{message}</Speak></Response>
Invoking the tool with message="Your monitor is down." makes Plivo request the Answer URL with ?message=Your+monitor+is+down., and the endpoint returns this.
<Response><Speak>Your monitor is down.</Speak></Response>
To receive the parameters as a POST body instead, set the answer method to POST, either through the environment or on the tool.
export PLIVO_ANSWER_METHOD="POST"
tool = PlivoMakeCall(answer_method="POST")
The tool returns the Plivo request UUID on success.
Configuration
Every setting reads from an environment variable, and any of them can be overridden by passing the matching argument to the tool constructor.
| Environment variable | Constructor argument | Used by | Purpose |
|---|---|---|---|
PLIVO_AUTH_ID |
auth_id |
both tools | Plivo account Auth ID |
PLIVO_AUTH_TOKEN |
auth_token |
both tools | Plivo account Auth Token |
PLIVO_FROM_NUMBER |
from_number |
both tools | Plivo number that sends the SMS or places the call |
PLIVO_ANSWER_URL |
answer_url |
PlivoMakeCall |
Endpoint that returns Plivo XML when the call connects |
PLIVO_ANSWER_METHOD |
answer_method |
PlivoMakeCall |
HTTP method Plivo uses to fetch the Answer URL, defaults to GET |
Using the tools with a LangChain agent
Both tools are standard LangChain tools, so they can be bound to a chat model or handed to an agent.
from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_react_agent
from langchain_plivo_tools import PlivoMakeCall, PlivoSendMessage
tools = [PlivoSendMessage(), PlivoMakeCall()]
model = init_chat_model("claude-sonnet-4-5-20250929", model_provider="anthropic")
agent = create_react_agent(model, tools)
result = agent.invoke(
{
"messages": [
{
"role": "user",
"content": "Text +14155551234 to let them know their order shipped.",
}
]
}
)
print(result["messages"][-1].content)
Every tool at once with the toolkit
PlivoToolkit hands an agent all of the Plivo tools in one call, which keeps the
agent setup unchanged as more tools are added to the package.
from langchain_plivo_tools import PlivoToolkit
agent = create_react_agent(model, PlivoToolkit().get_tools())
The toolkit reads the same environment variables as the individual tools, and any argument passed to it is forwarded to every tool that accepts one.
toolkit = PlivoToolkit(
auth_id="your-auth-id",
auth_token="your-auth-token",
from_number="+14155551234",
answer_url="https://example.com/answer",
)
A tool whose configuration is incomplete is left out of the returned list rather than raising, because an account that only sends SMS has no reason to set an Answer URL. Each omission raises a warning naming the missing setting, so a tool absent from an agent stays traceable. Nothing being configurable is an error.
# With credentials set but no PLIVO_ANSWER_URL:
PlivoToolkit().get_tools()
# UserWarning: Some Plivo tools are missing from the toolkit.
# PlivoMakeCall (Missing Plivo settings: PLIVO_ANSWER_URL. ...)
# -> [PlivoSendMessage()]
Security
- The Auth Token is held as a
SecretStr, keeping it out ofrepr()and log output - Credentials are read from the environment or passed to the constructor, and this package writes neither to disk
- Both tools perform billable actions against a number the model supplies. No destination allowlist or rate limit is applied here, so those controls belong in the host application or in Plivo spend limits
- The
messageargument reaches the Answer URL as a query parameter. An endpoint placing it into XML has to escape it first, because unescaped input can alter the XML document
Limitations
- SMS only. MMS and WhatsApp are not covered
- Number lookup and Verify are not included
PlivoMakeCallneeds a separately hosted Answer URL, because Plivo does not speak text handed straight to the call API
Development
make install
make test
make lint
Integration tests place a real API call and run only when PLIVO_AUTH_ID, PLIVO_AUTH_TOKEN, PLIVO_FROM_NUMBER and PLIVO_TO_NUMBER are set. Calls also need PLIVO_ANSWER_URL.
make integration_test
License
This project is licensed under the MIT License. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_plivo_tools-0.2.0.tar.gz.
File metadata
- Download URL: langchain_plivo_tools-0.2.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd1f25c6e70f79a23acb9e22aa0ad6a59ccc8c68aa3094449ea98995315258cf
|
|
| MD5 |
e8588f537332961afc2adb67e20963c0
|
|
| BLAKE2b-256 |
6b1e4ec81e01c36e359623c4e388621b65bd40e62b85fb9939fa82b018c0395c
|
Provenance
The following attestation bundles were made for langchain_plivo_tools-0.2.0.tar.gz:
Publisher:
release.yml on plivo-dev/langchain-plivo-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_plivo_tools-0.2.0.tar.gz -
Subject digest:
fd1f25c6e70f79a23acb9e22aa0ad6a59ccc8c68aa3094449ea98995315258cf - Sigstore transparency entry: 2756179220
- Sigstore integration time:
-
Permalink:
plivo-dev/langchain-plivo-tools@502f790998a3ec9a6f468127e2696e5d245d9d36 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/plivo-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@502f790998a3ec9a6f468127e2696e5d245d9d36 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langchain_plivo_tools-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_plivo_tools-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f5bd5b9b6dbddc42df41ec826faa811d1ac89d2a529695ba79af8908973e9a9
|
|
| MD5 |
b7d16f8f2a490c6509772d18d758b48a
|
|
| BLAKE2b-256 |
6313a56a2549c6dc5995919cc5603f137d05d69493f80d5fc29e6ca81b06b13a
|
Provenance
The following attestation bundles were made for langchain_plivo_tools-0.2.0-py3-none-any.whl:
Publisher:
release.yml on plivo-dev/langchain-plivo-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_plivo_tools-0.2.0-py3-none-any.whl -
Subject digest:
5f5bd5b9b6dbddc42df41ec826faa811d1ac89d2a529695ba79af8908973e9a9 - Sigstore transparency entry: 2756179358
- Sigstore integration time:
-
Permalink:
plivo-dev/langchain-plivo-tools@502f790998a3ec9a6f468127e2696e5d245d9d36 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/plivo-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@502f790998a3ec9a6f468127e2696e5d245d9d36 -
Trigger Event:
release
-
Statement type: