List Followers for a Ticket
One script reply has been approved by the moderators Verified

Returns any users who follow the ticket.

Availability

The CCs and Followers feature must be enabled in Zendesk Support.

Allowed For

  • Agents
Created by hugo697 793 days ago
Submitted by hugo697 Typescript (fetch-only)
Verified 246 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * List Followers for a Ticket
8
 * Returns any users who follow the ticket.
9

10
#### Availability
11

12
The [CCs and Followers](https://support.zendesk.com/hc/en-us/articles/203690846) feature must be enabled in Zendesk Support.
13

14
#### Allowed For
15

16
* Agents
17
 */
18
export async function main(auth: Zendesk, ticket_id: string) {
19
  const url = new URL(
20
    `https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/followers`
21
  );
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36