0

Run Assignment Rules on a conversation

by
Published Dec 20, 2024

You can let a conversation be automatically assigned following assignment rules. {% admonition type="attention" name="When using workflows" %} It is not possible to use this endpoint with Workflows. {% /admonition %}

Script intercom Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Intercom = {
3
	apiVersion: string
4
	token: string
5
}
6
/**
7
 * Run Assignment Rules on a conversation
8
 * You can let a conversation be automatically assigned following assignment rules.
9
{% admonition type="attention" name="When using workflows" %}
10
It is not possible to use this endpoint with Workflows.
11
{% /admonition %}
12

13
 */
14
export async function main(auth: Intercom, id: string) {
15
	const url = new URL(`https://api.intercom.io/conversations/${id}/run_assignment_rules`)
16

17
	const response = await fetch(url, {
18
		method: 'POST',
19
		headers: {
20
			'Intercom-Version': auth.apiVersion,
21
			Authorization: 'Bearer ' + auth.token
22
		},
23
		body: undefined
24
	})
25
	if (!response.ok) {
26
		const text = await response.text()
27
		throw new Error(`${response.status} ${text}`)
28
	}
29
	return await response.json()
30
}
31