If you just want to chat about support data with a local agent, our MCP server is the fastest way to get a model talking to Plain. This guide is about building autonomous agents within Plain.
What an agent looks like in Plain
An agent in Plain is made of three pieces:A machine user
The agent’s identity in Plain. Has a public name, an avatar, and one or more API keys.
A webhook listener
A public HTTPS endpoint that receives Plain events like new threads, incoming messages, and assignment changes.
A GraphQL client
Makes calls back to Plain to read threads, reply, change assignment, add labels, create notes, and more.
The journey
Create a machine user
A machine user is the agent’s identity in Plain. Give it a public name (what customers see) and create an API key with the right permissions.Set up a machine user →
Stand up a webhook endpoint
Plain delivers events as HTTP POST requests. Use the
@team-plain/webhooks package to verify and parse them with full type safety.Receive events from Plain →Decide when your agent should act
You can filter events in code, or use Plain’s built-in workflows to assign specific threads to the machine user and only react to those.Route threads to your agent →
Read the thread
If your agent needs the conversation context, query the thread and pull its content as LLM-ready text.Read thread content →
Search your knowledge
If your agent answers questions, search your help center articles and indexed documents to ground its replies in real content.Search knowledge sources →
Act on the thread
Use the
@team-plain/graphql SDK to do whatever your agent does: reply, label, change status, create a note, hand off to a human, or anything else.Act on the thread →A minimal example
Here’s one possible shape: an agent that replies to every new thread. It uses Express, but the same shape works with any HTTP framework. Your own agent will likely do something different in the handler.generateReply with whatever AI library you prefer, like the Vercel AI SDK, Anthropic SDK, OpenAI SDK, or your own.
What’s next
Machine users
Create the agent’s identity and API key.
Receiving events
Listen for the events that matter to your agent.
Routing to your agent
Use workflows and assignment to control when the agent acts.
Reading threads
Fetch thread context as LLM-ready text.
Searching knowledge
Ground replies in your help center and indexed documents.
Acting on threads
Reply, suggest replies, post notes, add labels, and reassign threads.

