Voice agents
Let a phone agent take a message and save it as an email draft that a person reads.
On this page
Before you start
A caller is a stranger. If a voice agent can read mail, a caller can ask it to read mail. So both guides give the agent one action, writing a draft, and no reading.
-
Create an API key under Agents & API > API keys with Read and
draft, limited to one mailbox, such as
frontdesk@harborlight.example. - Get that mailbox's ID:
curl https://api.postyard.dev/v1/mailboxes -H "Authorization: Bearer $POSTYARD_API_KEY"
export POSTYARD_MAILBOX_ID=...Drafts appear in the web inbox with the key's name, and in the Drafts folder of any mail app. Nothing is sent to the caller.
LiveKit Agents
Install MCP support with uv add "livekit-agents[mcp]~=1.8". LiveKit picks Streamable
HTTP by itself, because the URL ends in /mcp
(LiveKit's MCP docs).
allowed_tools hides every other tool from the model:
import os
from livekit.agents import Agent, mcp
class FrontDesk(Agent):
def __init__(self) -> None:
super().__init__(
instructions=(
"Take a message: ask for the caller's name, email address and question, "
"read them back, then call create_draft with "
f"mailbox_id {os.environ['POSTYARD_MAILBOX_ID']} and "
"to frontdesk@harborlight.example. Nothing is sent to the caller."
),
tools=[
mcp.MCPToolset(
id="postyard",
mcp_server=mcp.MCPServerHTTP(
"https://api.postyard.dev/mcp",
headers={"Authorization": f"Bearer {os.environ['POSTYARD_API_KEY']}"},
allowed_tools=["create_draft"],
),
)
],
)The recipient here is only an instruction, so a caller could talk the model into another address. Check To before you send. To fix it in code, call the REST API from your own function tool.
Pass FrontDesk() to your agent session as usual. The Node.js SDK has the same pieces:
llm.MCPToolset, llm.MCPServerHTTP and allowedTools.
Vapi
Vapi's MCP tool adds every tool the server lists and has no setting to leave some out. So use an API Request tool for calls from outside. It makes one request, and you fix the recipient.
- In Vapi, create a custom credential of type Bearer Token with your Postyard key. Keep Include Bearer Prefix on.
- Create the tool:
curl -X POST https://api.vapi.ai/tool \
-H "Authorization: Bearer $VAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "apiRequest",
"name": "takeMessage",
"description": "Saves the caller'\''s message as an email draft for the team. Use only after the caller confirms their name, email address and message. Nothing is sent to the caller.",
"method": "POST",
"url": "https://api.postyard.dev/v1/mailboxes/MAILBOX_ID/drafts",
"credentialId": "YOUR_CREDENTIAL_ID",
"body": {
"type": "object",
"properties": {
"subject": { "type": "string", "description": "A short subject with the caller name." },
"text": { "type": "string", "description": "The message, with the caller name and email address." }
},
"required": ["subject", "text"],
"additionalProperties": false
},
"parameters": [
{ "key": "to", "value": ["frontdesk@harborlight.example"] }
]
}'- Add the returned tool ID to your assistant's
model.toolIdsand publish it.
Values in parameters are merged on Vapi's side and override what the model writes, so a
caller can't change who the draft is for.
For an assistant only you can call, the MCP tool works too: set server.url to
https://api.postyard.dev/mcp and server.credentialId to the same credential.
The model sees all 13 tools with a prefix, such as postyard-create_draft. Vapi supports
the OAuth client credentials grant only, so the Postyard sign-in doesn't work there; use a key.
If it doesn't work
See troubleshooting, or write to support.