Create Agent Inbox
Create and configure hosted Agent Inboxes for AI workflows.
Pattern 1: Agent with Dedicated Inbox
Each agent gets its own inbox for isolated communication:
const inbox = await client.inboxes.create({
display_name: "Customer Support Agent",
});
// Agent sends emails from its inbox
await client.inboxes.messages.create(inbox.id, {
to: ["customer@example.com"],
subject: "Re: Your request",
text_body: agentResponse,
from_: inbox.id,
});Pattern 2: Webhook-Driven Agent Loop
Use webhooks to create an autonomous email loop:
- Agent receives webhook when email arrives
- Agent processes the email content
- Agent sends a reply
app.post("/webhook", async (req, res) => {
const { data: message } = req.body;
// Generate response using your AI model
const response = await generateResponse(message.text_body);
// Reply to the sender
await client.inboxes.messages.replyAll(
message.inbox_id,
message.id,
{ text_body: response }
);
res.status(200).send("OK");
});Pattern 3: Semantic Search for Context
Use semantic search to find relevant past conversations:
POST /agent/v0/search
{
"query": "shipping delay refund policy",
"limit": 5
}This returns the most semantically similar messages, which agents can use as context for generating responses.
SDK Compatibility
Agentry is API-compatible with the AgentMail SDK. Point it at the Agentry API:
import AgentMail from "agentmail";
const client = new AgentMail({
apiKey: process.env.AGENTRY_API_KEY,
baseUrl: "https://api.agentry.to",
});