Before you start
You need these before you connect Devin:- Admin access in Devin: you create a secret, a managed webhook and an automation in your Devin organization
- Devin connected to your code: connect Devin to your repositories and any other tools you use
Steps
1
Create the connected agent
In Plain, go to Agents → Connected agents → Add. Or your AI agent can do this step for you through Plain’s MCP server, following Connected agent set up. Name the agent Devin and pick the Internal Agent template. Note the agent’s ID: it starts with
mu_.2
Create its API key
Plain opens the API key step with the template’s permissions already selected. Create the key, then in Devin go to Settings → Secrets → Organization and add it as
PLAIN_API_KEY. Skip the webhook step for now: you add it in step 5.3
Create a managed webhook in Devin
In Devin, go to Settings → Managed webhooks → New managed webhook and fill in:
Click Create webhook. Devin shows the
- Name:
Plain - Authentication: Custom header, with the header name
X-Webhook-Secret - Secret lifetime: Never expires. If the secret expires, Plain’s deliveries start failing
- Delivery ID: the
Plain-Event-Idheader. Plain sends the same ID on every retry, so Devin drops duplicates - Sample payload: paste the sample payload below, a
discussion.message_createdevent
Sample payload
Sample payload
X-Webhook-Secret once, so save it. Note the webhook’s endpoint URL too.4
Create the automation
In Devin, go to Automations and create an automation. Or your AI agent can do this step for you through Devin’s MCP server. Fill in:
Click Create automation.
- Automation name:
Plain - Triggers: Add trigger → Plain (Managed)
- Add Preflight check: pick Run a script, choose Node, and paste the Preflight script below. It lets an event through only when a user writes in a discussion with Devin, so no session starts for anything else. Replace
your_agent_id_herewith the agent’s ID from step 1 - Agent type: Start new session. Don’t pick Message existing session: every discussion in your workspace would pile into the same Devin session
- Instructions: paste Devin’s prompt below. It calls Plain’s API with the
PLAIN_API_KEYsecret from step 2 - Advanced → Network policy: click Add domain and add
core-api.uk.plain.com. The policy starts with onlygit-manager.devin.ai, so without it Devin can’t reach Plain’s API
Preflight script
Preflight script
Devin's prompt
Devin's prompt
5
Add the webhook in Plain
On the Devin agent’s Webhooks tab, add a webhook with the managed webhook’s endpoint from step 3 as the URL and the
discussion.message_created event. Under Custom headers, click Add header and add X-Webhook-Secret with the secret from step 3, so Devin accepts Plain’s requests.6
Send discussions to Devin
On a thread, open Ask Agent and pick Devin. Or add a workflow with a Start Agent discussion step that picks Devin. Devin shows as working, posts its answer in the discussion, then goes idle.If no answer arrives, check the automation ran in Devin. Your AI agent can check the agent’s API key and webhook through Plain’s MCP server.

