Ticket Related Information

The request returns a data object with the following properties: | Name | Type | Comment | ------------------- | ------- | ------- | topic_id | string | Related topic in the Web portal (deprecated feature) | followup_source_ids | array | Sources to follow up | from_archive | boolean | Is true if the current ticket is archived | incidents | integer | A count of related incident occurrences | twitter | object | Twitter information associated with the ticket #### Allowed For * Agents.

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Ticket Related Information
8
 * The request returns a data object with the following properties:
9

10
| Name                | Type    | Comment
11
| ------------------- | ------- | -------
12
| topic_id            | string  | Related topic in the Web portal (deprecated feature)
13
| followup_source_ids | array   | Sources to follow up
14
| from_archive        | boolean | Is true if the current ticket is archived
15
| incidents           | integer | A count of related incident occurrences
16
| twitter             | object  | Twitter information associated with the ticket
17

18
#### Allowed For
19

20
* Agents.
21
 */
22
export async function main(auth: Zendesk, ticket_id: string) {
23
  const url = new URL(
24
    `https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/related`
25
  );
26

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