> For the complete documentation index, see [llms.txt](https://docs.pagerly.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pagerly.io/task-management/assign-tickets-to-current-oncall/assign-intercom-conversations-to-current-oncall.md).

# Assign Intercom Conversations to the Current Oncall

Route Intercom conversations and tickets to the support engineer who is on call right now, and mirror the thread into Slack so they can reply from there.

Support rotas have a sharper version of the queue problem than engineering ones: a conversation sitting unassigned is a customer waiting. Pagerly's Intercom integration covers two halves of this.

* **Assignment** — put the current on-call support engineer on the conversation or ticket, via the Intercom API driven by Pagerly's on-call endpoint.
* **Response** — mirror the Intercom thread into Slack so the on-call can read and reply without opening Intercom.

## Prerequisites

* A Pagerly team with a support schedule.
* [A Pagerly API key](/api-and-developers/generate-api-key.md).
* Intercom connected to Pagerly (Slack: `/pagerly` → **Integrations** → **Intercom** → **Connect**). This authorises Pagerly over OAuth.
* Your on-call users must exist as **admins** (teammates) in Intercom, with the same email they use in Pagerly.

## How assignment works

Intercom assigns to an **admin ID**, not an email. So the flow is three steps:

1. Ask Pagerly who is on call → get an email.
2. Look that email up in Intercom's admin list → get an admin ID.
3. Assign the conversation or ticket to that admin ID.

### Step 1 — who is on call

```bash
curl -s 'https://api.pagerly.io/pagerly/o/currentusers?teamname=support' \
  -H "X-APIKEY: $PAGERLY_API_KEY"
```

```json
[{ "name": "mansi", "email": "mansi@pagerly.io", "id": "U04CTTV5Z6G", "imageurl": null }]
```

### Step 2 — email to Intercom admin ID

```bash
curl -s https://api.intercom.io/admins \
  -H "Authorization: Bearer $INTERCOM_TOKEN" \
  -H "Intercom-Version: 2.13"
```

```json
{
  "type": "admin.list",
  "admins": [
    { "type": "admin", "id": "814860", "name": "Mansi", "email": "mansi@pagerly.io" }
  ]
}
```

The admin list is small and changes rarely — cache it and refresh on a miss rather than calling it per conversation.

### Step 3a — assign a conversation

Assignment on a conversation is a conversation *part*:

```bash
curl -s -X POST \
  "https://api.intercom.io/conversations/$CONVERSATION_ID/parts" \
  -H "Authorization: Bearer $INTERCOM_TOKEN" \
  -H "Intercom-Version: 2.13" \
  -H 'Content-Type: application/json' \
  -d '{
    "message_type": "assignment",
    "type": "admin",
    "admin_id": "<acting-admin-id>",
    "assignee_id": "<oncall-admin-id>"
  }'
```

`admin_id` is the actor performing the assignment — use the admin whose token you are calling with. `assignee_id` is the on-call engineer resolved in step 2.

### Step 3b — assign a ticket

```bash
curl -s -X PUT \
  "https://api.intercom.io/tickets/$TICKET_ID" \
  -H "Authorization: Bearer $INTERCOM_TOKEN" \
  -H "Intercom-Version: 2.13" \
  -H 'Content-Type: application/json' \
  -d '{
    "assignment": {
      "admin_id": "<acting-admin-id>",
      "assignee_id": "<oncall-admin-id>"
    }
  }'
```

### Wiring it to a trigger

Intercom fires webhooks on `conversation.user.created` and `conversation.user.replied`. Point one at a small handler that runs the three steps above, or build the same sequence in Zapier, Make or n8n:

| Step    | Zapier / Make / n8n                                                                                    |
| ------- | ------------------------------------------------------------------------------------------------------ |
| Trigger | Intercom — New Conversation                                                                            |
| 1       | Webhook GET `https://api.pagerly.io/pagerly/o/currentusersformake?teamname=support`, header `X-APIKEY` |
| 2       | Webhook GET `https://api.intercom.io/admins`, filter where `email` matches step 1                      |
| 3       | Webhook POST to `/conversations/{id}/parts` with the assignment body                                   |

{% hint style="info" %}
`/o/currentusersformake` returns the same data wrapped in an `output` array, which Make's iterator consumes directly. Zapier and n8n can use `/o/currentusers`.
{% endhint %}

## Bring the conversation into Slack

Assignment tells you who owns it. The other half is letting them act without a context switch.

Once Intercom is connected, Pagerly can mirror an Intercom conversation into a Slack thread — new customer messages appear in the thread, and the on-call replies in Slack. Pagerly posts the reply back to Intercom as an admin, so the customer sees a normal support response.

This means the on-call support engineer works one surface. New conversation lands, Pagerly assigns it to them and opens a Slack thread, they answer in the thread, the customer gets the reply in the Messenger.

You can also raise an Intercom ticket from Slack directly, with priority and description, and Pagerly keeps the Slack thread and the Intercom ticket linked from then on.

## Handling the gaps

Support rotas have more edges than engineering rotas. Decide these deliberately:

* **Out of hours.** If the schedule has no cover at 03:00, `/o/currentusers` returns `[]`. Assign to an Intercom **team** rather than an admin as the fallback so the conversation still lands somewhere with an SLA.
* **Handover.** A conversation assigned at 17:55 to a shift ending at 18:00 is about to be orphaned. Either reassign open conversations at handover, or set your assignment trigger on customer reply rather than only on creation, so a conversation naturally moves to whoever is on when the customer comes back.
* **Escalations.** An assignment that needs an engineer, not a support agent, should page rather than reassign. Use [escalations](/oncall-and-rotations/escalations.md) for that path.

## Troubleshooting

| Symptom                                    | Cause                                                                | Fix                                                                                 |
| ------------------------------------------ | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| No admin matches the on-call email         | User is on the rota but not a teammate in Intercom                   | Add them in Intercom, or exclude them from the support rota                         |
| `404` on the assignment call               | Conversation ID vs ticket ID mixed up — they use different endpoints | Conversations use `POST /conversations/{id}/parts`, tickets use `PUT /tickets/{id}` |
| Assignment succeeds but nobody is notified | Intercom notification preferences, not an assignment problem         | Mirror the thread into Slack so the ping is where the on-call already is            |
| `401` after months of working              | OAuth token expired or the connection was revoked                    | Reconnect Intercom from `/pagerly` → Integrations                                   |

## Related

* [Assign Bugs & Tickets to the Current Oncall](/task-management/assign-tickets-to-current-oncall.md)
* [Escalations](/oncall-and-rotations/escalations.md)
* [Rotate & Assign Requests](/task-management/rotate-and-assign-requests.md)
