0

Remove tag from a conversation

by
Published Dec 20, 2024

You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation.

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
 * Remove tag from a conversation
8
 * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation.
9
 */
10
export async function main(
11
	auth: Intercom,
12
	conversation_id: string,
13
	id: string,
14
	body: { admin_id: string }
15
) {
16
	const url = new URL(`https://api.intercom.io/conversations/${conversation_id}/tags/${id}`)
17

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