0

Get Actor

by
Published today

Retrieve a conversation actor (agent A-..., visitor V-..., bot B-...) by its actor ID, as found on messages.

Script hubspot Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
/**
4
 * Get Actor
5
 * Retrieve a conversation actor (agent A-..., visitor V-..., bot B-...) by its actor ID, as found on messages. Requires conversations.read.
6
 */
7
export async function main(auth: RT.Hubspot, actor_id: string) {
8
  const url = new URL(
9
    `https://api.hubapi.com/conversations/v3/conversations/actors/${actor_id}`
10
  )
11

12
  const response = await fetch(url, {
13
    headers: {
14
      Authorization: `Bearer ${auth.token}`,
15
      Accept: "application/json",
16
    },
17
  })
18

19
  if (!response.ok) {
20
    throw new Error(`${response.status} ${await response.text()}`)
21
  }
22

23
  return await response.json()
24
}
25