> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.agentphone.to/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.agentphone.to/_mcp/server.

# LangChain

> Give your LangChain agent phone numbers, voice calls, and messaging with AgentPhone

Give your [LangChain](https://python.langchain.com/) agent a real phone number. Make calls, send messages, buy numbers, and manage voice agents — all through the `langchain-agentphone` package.

> **Info**
>
> Get your API key from [agentphone.ai/settings](https://agentphone.ai/settings). Tool calls and hosted voice do not require your own webhook server. For real-time inbound handling in your application, configure a [webhook endpoint](/documentation/guides/webhooks).

## Installation

```bash
pip install "langchain-agentphone==0.1.0" "langchain>=0.3,<0.4" "langgraph>=0.6,<0.7" "langchain-anthropic>=0.3,<0.4"
```

Set your API key as an environment variable:

```bash
export AGENTPHONE_API_KEY="your_api_key_here"
```

`langchain-agentphone` 0.1.0 requires `langchain-core<1`. The example uses the compatible 0.3-era LangChain stack; it is not a LangChain 1.x example. For a project on current LangChain, connect the [hosted MCP server](/mcp) using [LangChain’s MCP integration](https://docs.langchain.com/oss/python/langchain/mcp) instead of forcing incompatible dependency versions.

Configure credentials for the model provider separately (the example uses `ANTHROPIC_API_KEY`).

## Setup

### Using the toolkit

The `AgentPhoneToolkit` gives your agent access to all 12 LangChain tools at once. Use `selected_tools` to expose only the capabilities you need.

```python
from langchain_agentphone import AgentPhoneToolkit
from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_react_agent

model = init_chat_model(
    model="claude-sonnet-4-6",
    model_provider="anthropic",
)

# All 12 tools
toolkit = AgentPhoneToolkit()
agent = create_react_agent(model, toolkit.get_tools())

response = agent.invoke({
    "messages": [
        ("user", "List my agents and phone numbers without changing anything.")
    ]
})
```

### Selecting specific tools

```python
# Only messaging
toolkit = AgentPhoneToolkit(selected_tools=["send_sms"])

# Calls and transcripts
toolkit = AgentPhoneToolkit(
    selected_tools=["make_call", "get_transcript", "list_calls"]
)
```

### Importing individual tools

```python
from langchain_agentphone import AgentPhoneSendSMS, AgentPhoneMakeCall

send_sms = AgentPhoneSendSMS()
make_call = AgentPhoneMakeCall()

agent = create_react_agent(model, [send_sms, make_call])
```

## Use cases

* **Autonomous phone calls** — have your agent call a number and hold a full AI conversation, then retrieve the transcript after the call ends
* **SMS messaging** — send and receive texts, manage conversation threads across multiple numbers
* **Phone number management** — provision numbers with specific area codes, assign them to agents
* **AI voice agents** — create agents with configurable voices, system prompts, and model tiers that handle calls autonomously
* **Appointment reminders** — pull schedules from a calendar API and text or call customers with reminders
* **Lead qualification** — call new leads within seconds, qualify interest, and book meetings automatically

## Available tools

The package provides 12 LangChain tools:

| Tool                          | Description                                  |
| ----------------------------- | -------------------------------------------- |
| `AgentPhoneSendSMS`           | Send a message to a phone number             |
| `AgentPhoneMakeCall`          | Make an AI-powered phone call                |
| `AgentPhoneGetTranscript`     | Get the transcript for a completed call      |
| `AgentPhoneListCalls`         | List recent calls                            |
| `AgentPhoneListConversations` | List SMS conversation threads                |
| `AgentPhoneGetConversation`   | Get messages in a conversation               |
| `AgentPhoneBuyNumber`         | Buy a phone number with a specific area code |
| `AgentPhoneListNumbers`       | List your phone numbers                      |
| `AgentPhoneCreateAgent`       | Create an AI phone agent                     |
| `AgentPhoneListAgents`        | List your phone agents                       |
| `AgentPhoneCreateContact`     | Create a contact                             |
| `AgentPhoneListContacts`      | List your contacts                           |

Every tool has a full Pydantic schema so your LLM knows exactly what arguments to pass.

## Resources

* [langchain-agentphone on PyPI](https://pypi.org/project/langchain-agentphone/)
* [LangChain integration docs](https://python.langchain.com/docs/integrations/tools/agentphone/)
* [API Reference](/api-reference)