//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Detach a contact from a group conversation
* You can add participants who are contacts to a conversation, on behalf of either another contact or an admin.
{% admonition type="attention" name="Contacts without an email" %}
If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`.
{% /admonition %}
*/
export async function main(
auth: Intercom,
conversation_id: string,
contact_id: string,
body: { admin_id: string }
) {
const url = new URL(
`https://api.intercom.io/conversations/${conversation_id}/customers/${contact_id}`
)
const response = await fetch(url, {
method: 'DELETE',
headers: {
'Intercom-Version': auth.apiVersion,
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago