Edits history of script submission #11176 for ' Run Assignment Rules on a conversation (intercom)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Intercom = {
    	apiVersion: string
    	token: string
    }
    /**
     * Run Assignment Rules on a conversation
     * 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 %}
    
     */
    export async function main(auth: Intercom, id: string) {
    	const url = new URL(`https://api.intercom.io/conversations/${id}/run_assignment_rules`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Intercom-Version': auth.apiVersion,
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 536 days ago