AgentSkillsCN

agentmail-toolkit

借助流行的框架,为 AI 智能体增添邮件功能。提供适用于 TypeScript 和 Python 框架的预构建工具,包括 Vercel AI SDK、LangChain、Clawdbot、OpenAI Agents SDK 以及 LiveKit Agents。当您将 AgentMail 集成到需要邮件收发功能的智能体框架中时,可选用此技能。

SKILL.md
--- frontmatter
name: agentmail-toolkit
description: Add email capabilities to AI agents using popular frameworks. Provides pre-built tools for TypeScript and Python frameworks including Vercel AI SDK, LangChain, Clawdbot, OpenAI Agents SDK, and LiveKit Agents. Use when integrating AgentMail with agent frameworks that need email send/receive tools.

AgentMail Toolkit

Pre-built email tools for popular agent frameworks. Instantly add inbox management, sending, receiving, and email automation to your agents.

Installation

bash
# TypeScript/Node
npm install agentmail-toolkit

# Python
pip install agentmail-toolkit

Configuration

Set your API key as an environment variable:

bash
export AGENTMAIL_API_KEY=your-api-key

Get your API key from console.agentmail.to.


TypeScript Frameworks

Vercel AI SDK

typescript
import { AgentMailToolkit } from "agentmail-toolkit/ai-sdk";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";

const toolkit = new AgentMailToolkit();

const result = await streamText({
  model: openai("gpt-4o"),
  messages,
  system: "You are an email agent that can send and receive emails.",
  tools: toolkit.getTools(),
});

LangChain

typescript
import { createAgent, HumanMessage, AIMessage } from "langchain";
import { AgentMailToolkit } from "agentmail-toolkit/langchain";

const agent = createAgent({
  model: "openai:gpt-4o",
  tools: new AgentMailToolkit().getTools(),
  systemPrompt: "You are an email agent that can send and receive emails.",
});

const result = await agent.stream({ messages }, { streamMode: "messages" });

Clawdbot (Pi Agent)

For Clawdbot/Pi Agent integration.

typescript
import { AgentMailToolkit } from "agentmail-toolkit/clawdbot";

const toolkit = new AgentMailToolkit();
const tools = toolkit.getTools();

// Each tool has: name, label, description, parameters, execute
for (const tool of tools) {
  agent.registerTool(tool);
}

Python Frameworks

OpenAI Agents SDK

python
from agentmail_toolkit.openai import AgentMailToolkit
from agents import Agent

agent = Agent(
    name="Email Agent",
    instructions="You can send, receive, and manage emails.",
    tools=AgentMailToolkit().get_tools(),
)

LangChain

python
from langchain.agents import create_agent
from agentmail_toolkit.langchain import AgentMailToolkit

agent = create_agent(
    model="gpt-4o",
    system_prompt="You are an email agent that can send and receive emails.",
    tools=AgentMailToolkit().get_tools(),
)

result = agent.stream({"messages": messages}, stream_mode="messages")

LiveKit Agents

For voice AI agents with email capabilities.

python
from livekit.agents import Agent
from agentmail_toolkit.livekit import AgentMailToolkit

agent = Agent(
    name="Voice Email Agent",
    tools=AgentMailToolkit().get_tools(),
)

Available Tools

All frameworks get access to these tools:

ToolDescription
create_inboxCreate a new email inbox
list_inboxesList all inboxes
get_inboxGet inbox details
delete_inboxDelete an inbox
send_messageSend an email
reply_to_messageReply to an email
list_threadsList email threads
get_threadGet thread details
get_attachmentDownload an attachment
update_messageUpdate message labels

Custom Configuration

Custom API Key

typescript
// TypeScript
const toolkit = new AgentMailToolkit({ apiKey: "your-api-key" });
python
# Python
toolkit = AgentMailToolkit(api_key="your-api-key")

Custom Client

python
# Python - use existing AgentMail client
from agentmail import AgentMail
from agentmail_toolkit.openai import AgentMailToolkit

client = AgentMail(api_key="your-api-key")
toolkit = AgentMailToolkit(client=client)

Framework Summary

FrameworkTypeScript ImportPython Import
Vercel AI SDKfrom 'agentmail-toolkit/ai-sdk'-
LangChainfrom 'agentmail-toolkit/langchain'from agentmail_toolkit.langchain import AgentMailToolkit
Clawdbotfrom 'agentmail-toolkit/clawdbot'-
OpenAI Agents SDK-from agentmail_toolkit.openai import AgentMailToolkit
LiveKit Agents-from agentmail_toolkit.livekit import AgentMailToolkit