node-zendesk / Exports / clients/core/triggers / Triggers
Class: Triggers
clients/core/triggers.Triggers
Client for interacting with the Zendesk Triggers API.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/
Hierarchy
↳
Triggers
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- bulkDelete
- create
- definitions
- delete
- emit
- get
- getAll
- list
- listActive
- listRevisions
- on
- patch
- post
- put
- reorder
- request
- requestAll
- requestUpload
- search
- setSideLoad
- show
- showRevision
- update
- updateMany
Constructors
constructor
• new Triggers(options
): Triggers
Parameters
Name | Type |
---|---|
options | any |
Returns
Overrides
Defined in
clients/core/triggers.d.ts:6
Properties
_transporter
• _transporter: Transporter
Inherited from
Defined in
clients/client.d.ts:94
eventTarget
• eventTarget: CustomEventTarget
Event target to handle custom events.
Inherited from
Defined in
clients/client.d.ts:92
jsonAPINames
• jsonAPINames: string
[]
Array to hold names used in the JSON API.
Overrides
Defined in
clients/core/triggers.d.ts:7
options
• options: ClientOptions
& { get
: (key
: string
) => any
}
Configuration options for the client.
Inherited from
Defined in
clients/client.d.ts:86
sideLoad
• sideLoad: any
[]
Array to handle side-loaded resources.
Inherited from
Defined in
clients/client.d.ts:89
useDotJson
• useDotJson: boolean
Flag to indicate if the API endpoint should use '.json' ending.
Inherited from
Defined in
clients/client.d.ts:91
Accessors
transporter
• get
transporter(): Transporter
Transporter for making requests.
Returns
Inherited from
Client.transporter
Defined in
clients/client.d.ts:93
Methods
_rawRequest
▸ _rawRequest(method
, uri
, ...args
): Promise
<{ response
: any
; result
: {} }>
Parameters
Name | Type |
---|---|
method | any |
uri | any |
...args | any [] |
Returns
Promise
<{ response
: any
; result
: {} }>
Inherited from
Defined in
clients/client.d.ts:130
bulkDelete
▸ bulkDelete(triggerIDs
): Promise
<object
>
Deletes multiple triggers based on their IDs.
Parameters
Name | Type | Description |
---|---|---|
triggerIDs | number [] | An array of trigger IDs to be deleted. |
Returns
Promise
<object
>
The response from the deletion request.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#bulk-delete-triggers
Example
const response = await client.triggers.bulkDelete([12345, 67890]);
Defined in
clients/core/triggers.d.ts:134
create
▸ create(trigger
): Promise
<object
>
Creates a new trigger.
Parameters
Name | Type | Description |
---|---|---|
trigger | object | The trigger object to be created. |
Returns
Promise
<object
>
The created trigger.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#create-trigger
Example
const newTrigger = {
title: "Example Trigger",
conditions: {...},
actions: [...]
};
const response = await client.triggers.create(newTrigger);
Defined in
clients/core/triggers.d.ts:82
definitions
▸ definitions(): Promise
<object
>
Retrieves trigger definitions.
Returns
Promise
<object
>
The trigger definitions.
Async
Throws
Throws an error if the request fails.
See
Example
const definitions = await client.triggers.definitions();
Defined in
clients/core/triggers.d.ts:26
delete
▸ delete(triggerID
): Promise
<object
>
Deletes a specified trigger.
Parameters
Name | Type | Description |
---|---|---|
triggerID | number | The ID of the trigger to be deleted. |
Returns
Promise
<object
>
The response from the deletion request.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#delete-trigger
Example
const response = await client.triggers.delete(12345);
Overrides
Defined in
clients/core/triggers.d.ts:124
emit
▸ emit(eventType
, eventData
): void
Parameters
Name | Type |
---|---|
eventType | any |
eventData | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:95
get
▸ get(resource
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:114
getAll
▸ getAll(resource
): Promise
<any
[]>
Parameters
Name | Type |
---|---|
resource | any |
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:129
list
▸ list(options?
): Promise
<object
>
Lists all triggers, with optional filtering and sorting.
Parameters
Name | Type | Description |
---|---|---|
options? | Object | Optional parameters for listing triggers. |
options.active? | boolean | Filter by active triggers if true or inactive triggers if false. |
options.category_id? | string | Filter triggers by category ID. |
options.sort_by? | string | Possible values are "alphabetical", "created_at", "updated_at", "usage_1h", "usage_24h", or "usage_7d". Defaults to "position". |
options.sort_order? | string | One of "asc" or "desc". Defaults to "asc" for alphabetical and position sort, "desc" for all others. |
Returns
Promise
<object
>
A list of all triggers.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-triggers
Example
const triggers = await client.triggers.list();
const activeTriggers = await client.triggers.list({ active: true });
Defined in
clients/core/triggers.d.ts:42
listActive
▸ listActive(): Promise
<object
>
Lists all active triggers.
Returns
Promise
<object
>
A list of all active triggers.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-active-triggers
Example
const activeTriggers = await client.triggers.listActive();
Defined in
clients/core/triggers.d.ts:56
listRevisions
▸ listRevisions(triggerID
): Promise
<object
>
Lists the revisions associated with a trigger.
Parameters
Name | Type | Description |
---|---|---|
triggerID | number | The ID of the trigger. |
Returns
Promise
<object
>
A list of revisions for the specified trigger.
Async
Throws
Throws an error if the request fails.
See
Example
const revisions = await client.triggers.listRevisions(12345);
Defined in
clients/core/triggers.d.ts:154
on
▸ on(eventType
, callback
): void
Parameters
Name | Type |
---|---|
eventType | any |
callback | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:96
patch
▸ patch(...args
): Promise
<void
| object
>
Patches a resource.
Parameters
Name | Type | Description |
---|---|---|
...args | any [] | The resources or parts of the resource path followed by the body. |
Returns
Promise
<void
| object
>
- Either void or response object
Inherited from
Defined in
clients/client.d.ts:120
post
▸ post(resource
, body
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
body | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:122
put
▸ put(resource
, body
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
body | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:121
reorder
▸ reorder(triggerIDs
): Promise
<object
>
Reorders the triggers based on the provided trigger IDs.
Parameters
Name | Type | Description |
---|---|---|
triggerIDs | number [] | An array of trigger IDs in the desired order. |
Returns
Promise
<object
>
The response from the reorder request.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#reorder-triggers
Example
const response = await client.triggers.reorder([12345, 67890, 11223]);
Defined in
clients/core/triggers.d.ts:144
request
▸ request<T
>(method
, uri
, ...args
): Promise
<NodeModule
>
Request method that handles various HTTP methods.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
method | string | HTTP method (e.g., 'GET', 'POST'). |
uri | string | The URI for the request. |
...args | any [] | Additional arguments for the request. |
Returns
Promise
<NodeModule
>
- The API response.
Inherited from
Defined in
clients/client.d.ts:148
requestAll
▸ requestAll(method
, uri
, ...args
): Promise
<any
[]>
Parameters
Name | Type |
---|---|
method | any |
uri | any |
...args | any [] |
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:149
requestUpload
▸ requestUpload(uri
, file
): Promise
<any
>
Parameters
Name | Type |
---|---|
uri | any |
file | any |
Returns
Promise
<any
>
Inherited from
Defined in
clients/client.d.ts:150
search
▸ search(searchTerm
): Promise
<object
>
Searches for triggers based on the provided search term.
Parameters
Name | Type | Description |
---|---|---|
searchTerm | string | The term to search for. |
Returns
Promise
<object
>
The search results.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#search-triggers
Example
const results = await client.triggers.search('exampleTerm');
Defined in
clients/core/triggers.d.ts:17
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
show
▸ show(triggerID
): Promise
<object
>
Retrieves details of a specific trigger.
Parameters
Name | Type | Description |
---|---|---|
triggerID | number | The ID of the trigger. |
Returns
Promise
<object
>
Details of the specified trigger.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#show-trigger
Example
const triggerDetails = await client.triggers.show(12345);
Defined in
clients/core/triggers.d.ts:66
showRevision
▸ showRevision(triggerID
, revisionID
): Promise
<object
>
Fetches a specific revision associated with a trigger.
Parameters
Name | Type | Description |
---|---|---|
triggerID | number | The ID of the trigger. |
revisionID | number | The ID of the revision. |
Returns
Promise
<object
>
Details of the specified trigger revision.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#show-trigger-revision
Example
const revisionDetails = await client.triggers.showRevision(12345, 67890);
Defined in
clients/core/triggers.d.ts:165
update
▸ update(triggerID
, trigger
): Promise
<object
>
Updates an existing trigger.
Parameters
Name | Type | Description |
---|---|---|
triggerID | number | The ID of the trigger to be updated. |
trigger | object | The updated trigger object. |
Returns
Promise
<object
>
The updated trigger.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#update-trigger
Example
const updatedTrigger = {
title: "Updated Trigger",
conditions: {...},
actions: [...]
};
const response = await client.triggers.update(12345, updatedTrigger);
Defined in
clients/core/triggers.d.ts:99
updateMany
▸ updateMany(triggers
): Promise
<object
>
Updates multiple triggers.
Parameters
Name | Type | Description |
---|---|---|
triggers | object [] | An array of trigger objects to be updated. |
Returns
Promise
<object
>
The response from the update request.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#update-many-triggers
Example
const triggersToUpdate = [
{id: 12345, position: 3},
{id: 67890, position: 5}
];
const response = await client.triggers.updateMany(triggersToUpdate);
Defined in
clients/core/triggers.d.ts:114