Skip to main content
LangChain is an open-source framework for building AI agents. The langchain-plivo-tools package gives a LangChain agent two Plivo tools: one sends an SMS and one places a voice call. The agent’s model decides when to use each tool. This is a tool-use integration over Plivo REST APIs.

Prerequisites

Quick start: send an SMS from an agent

Create a project and add the packages:
Set your credentials:
Create agent.py and give the agent the Plivo tools:
Run it:
The agent calls plivo_send_message, which sends the SMS and returns the Plivo message UUID. The message also shows in the Plivo console logs. If it fails, look up the error in Messaging error codes.

Available tools

Both tools also accept auth_id, auth_token, and from_number as arguments in place of the environment variables.
Both tools send billable messages and calls to numbers the model picks. The package has no allowlist or rate limit, so consider human-in-the-loop review.

Send an SMS with PlivoSendMessage

Use the SMS tool on its own, without an agent:

Place a call with PlivoMakeCall

When the call connects, Plivo fetches the Answer URL and runs the Plivo XML it returns. Pass the XML to the Plivo-hosted Answer URL in its xml query parameter, so you don’t host anything:
The tool returns the call’s request UUID, and the phone rings and plays the message when answered. If the call fails, look up its hangup cause. The Answer URL wraps the XML in <Response>. To use your own endpoint instead, pass its URL as answer_url. The call tool adds its message argument to it as a message query parameter, which the Plivo-hosted Answer URL ignores.

Troubleshooting

langchain-plivo-tools

Source and release notes for the package.

LangChain agents

How to build and run an agent with tools.

Plivo Messages API

Send an SMS with the Plivo API.

Plivo Voice API

Make a call with the Plivo API.