List Trigger Action and Condition Definitions

Returns the definitions of the actions a trigger can perform and the definitions of the conditions under which a trigger can execute. The definition of the action includes a title ("Status"), a type ("list"), and possible values. The definition of the condition includes the same fields as well as the possible operators. For a list of supported actions, see the Actions reference For a list of supported conditions, see the Conditions reference #### 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
 * List Trigger Action and Condition Definitions
8
 * Returns the definitions of the actions a trigger can perform and the
9
definitions of the conditions under which a trigger can execute. The
10
definition of the action includes a title ("Status"), a type ("list"), and
11
possible values. The definition of the condition includes the same fields
12
as well as the possible operators.
13

14
For a list of supported actions, see the Actions reference
15
For a list of supported conditions, see the Conditions reference
16

17
#### Allowed For
18

19
* Agents
20

21
 */
22
export async function main(auth: Zendesk) {
23
  const url = new URL(
24
    `https://${auth.subdomain}.zendesk.com/api/v2/triggers/definitions`
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