Agentmail
Guide to use Agentmail tool on your AI agent using Vity Toolkit
List and invoke AgentMail automation pipelines programmatically.
Details
Supported Auth Type
AuthType.API_KEYQuick Start
1
Install the package.
npm install vity-toolkit langchain @langchain/openai2
Initialize Vity Toolkit and Langchain.
import { ChatOpenAI } from "@langchain/openai";
import { App, LangchainToolkit } from "vity-toolkit";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
const P = (globalThis as any).process;
const model = new ChatOpenAI({ model: "gpt-4o" });
const toolKit = new LangchainToolkit({
userPrivateKey: P?.env?.SOLANA_PRIVATE_KEY,
appPrivateKey: P?.env?.SOLANA_PRIVATE_KEY,
});Make sure that you already have integrated and connected the app.
3
Add the tool.
const tools = toolKit.getTools({ apps: [App.AGENTMAIL] });4
Define the Agent.
const prompt = ChatPromptTemplate.fromMessages([
["system", `You are an AI agent using AgentMail MCP tools. Use the provided tools to list available AgentMail capabilities and execute them as requested.`],
["placeholder", "{chat_history}"],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({ llm: model, tools, prompt });
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: false,
});5
Execute the Agent.
const response = await agentExecutor.invoke({ input: "Send an email to apneduniya.dontdisturb@gmail.com. Subject: 'Quick check-in from Vity Toolkit'. Body: 'Hi there, this is a quick test email sent via AgentMail through Vity Toolkit. If you received this, the integration works! Thanks.' If a send email tool is available, please send it now; otherwise, draft it and show me the exact steps you'd use to send" });
console.log(response);Supported Actions
Action
Description
Action.AGENTMAIL_LIST_TOOLSList available AgentMail MCP tools (optionally filter by names).
Action.AGENTMAIL_EXECUTEExecute a specific AgentMail MCP tool by name with parameters.
Last updated