node-zendesk • Docs
node-zendesk / clients/core/triggers / Triggers
Class: Triggers
Client for interacting with the Zendesk Triggers API.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/
Extends
Constructors
new Triggers()
new Triggers(
options
):Triggers
Parameters
• options: any
Returns
Overrides
Defined in
clients/core/triggers.d.ts:6
Properties
_transporter
_transporter:
Transporter
Inherited from
Defined in
clients/client.d.ts:42
eventTarget
eventTarget:
CustomEventTarget
Event target to handle custom events.
Inherited from
Defined in
clients/client.d.ts:40
jsonAPINames
jsonAPINames:
string
[]
Array to hold names used in the JSON API.
Overrides
Defined in
clients/core/triggers.d.ts:7
options
options:
ZendeskClientOptions
&object
Configuration options for the client.
Type declaration
get()
get: (
key
) =>any
Parameters
• key: string
Returns
any
Inherited from
Defined in
clients/client.d.ts:34
sideLoad
sideLoad:
any
[]
Array to handle side-loaded resources.
Inherited from
Defined in
clients/client.d.ts:37
useDotJson
useDotJson:
boolean
Flag to indicate if the API endpoint should use '.json' ending.
Inherited from
Defined in
clients/client.d.ts:39
Accessors
transporter
Get Signature
get transporter():
Transporter
Returns
Transporter for making requests.
Inherited from
Defined in
clients/client.d.ts:41
Methods
_rawRequest()
_rawRequest(
method
,uri
, ...arguments_
):Promise
<object
>
Parameters
• method: any
• uri: any
• ...arguments_: any
[]
Returns
Promise
<object
>
response
response:
any
result
result:
object
Inherited from
Defined in
clients/client.d.ts:78
bulkDelete()
bulkDelete(
triggerIDs
):Promise
<object
>
Deletes multiple triggers based on their IDs.
Parameters
• triggerIDs: number
[]
An array of trigger IDs to be deleted.
Returns
Promise
<object
>
The response from the deletion request.
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:139
create()
create(
trigger
):Promise
<object
>
Creates a new trigger.
Parameters
• trigger: object
The trigger object to be created.
Returns
Promise
<object
>
The created trigger.
response
response:
object
result
result:
object
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.
Throws
Throws an error if the request fails.
See
Example
const definitions = await client.triggers.definitions();
Defined in
clients/core/triggers.d.ts:27
delete()
delete(
triggerID
):Promise
<object
>
Deletes a specified trigger.
Parameters
• triggerID: number
The ID of the trigger to be deleted.
Returns
Promise
<object
>
The response from the deletion request.
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:130
emit()
emit(
eventType
,eventData
):void
Parameters
• eventType: any
• eventData: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:43
get()
get(
resource
):Promise
<NodeModule
>
Parameters
• resource: any
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:62
getAll()
getAll(
resource
):Promise
<any
[]>
Parameters
• resource: any
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:77
list()
list(
options
?):Promise
<object
>
Lists all triggers, with optional filtering and sorting.
Parameters
• options?
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.
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.
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:55
listRevisions()
listRevisions(
triggerID
):Promise
<object
>
Lists the revisions associated with a trigger.
Parameters
• triggerID: number
The ID of the trigger.
Returns
Promise
<object
>
A list of revisions for the specified trigger.
Throws
Throws an error if the request fails.
See
Example
const revisions = await client.triggers.listRevisions(12345);
Defined in
clients/core/triggers.d.ts:157
on()
on(
eventType
,callback
):void
Parameters
• eventType: any
• callback: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:44
patch()
patch(...
arguments_
):Promise
<void
|object
>
Patches a resource.
Parameters
• ...arguments_: 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:68
post()
post(
resource
,body
):Promise
<NodeModule
>
Parameters
• resource: any
• body: any
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:70
put()
put(
resource
,body
):Promise
<NodeModule
>
Parameters
• resource: any
• body: any
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:69
reorder()
reorder(
triggerIDs
):Promise
<object
>
Reorders the triggers based on the provided trigger IDs.
Parameters
• triggerIDs: number
[]
An array of trigger IDs in the desired order.
Returns
Promise
<object
>
The response from the reorder request.
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:148
request()
request<
T
>(method
,uri
, ...arguments_
):Promise
<NodeModule
>
Request method that handles various HTTP methods.
Type Parameters
• T
Parameters
• method: string
HTTP method (e.g., 'GET', 'POST').
• uri: string
The URI for the request.
• ...arguments_: any
[]
Additional arguments for the request.
Returns
Promise
<NodeModule
>
- The API response.
Inherited from
Defined in
clients/client.d.ts:96
requestAll()
requestAll(
method
,uri
, ...arguments_
):Promise
<any
[]>
Parameters
• method: any
• uri: any
• ...arguments_: any
[]
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:97
requestUpload()
requestUpload(
uri
,file
):Promise
<any
>
Parameters
• uri: any
• file: any
Returns
Promise
<any
>
Inherited from
Defined in
clients/client.d.ts:98
search()
search(
searchTerm
):Promise
<object
>
Searches for triggers based on the provided search term.
Parameters
• searchTerm: string
The term to search for.
Returns
Promise
<object
>
The search results.
response
response:
object
result
result:
object
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:16
setSideLoad()
setSideLoad(
array
):void
Parameters
• array: any
Returns
void
Inherited from
Defined in
clients/client.d.ts:61
show()
show(
triggerID
):Promise
<object
>
Retrieves details of a specific trigger.
Parameters
• triggerID: number
The ID of the trigger.
Returns
Promise
<object
>
Details of the specified trigger.
response
response:
object
result
result:
object
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:64
showRevision()
showRevision(
triggerID
,revisionID
):Promise
<object
>
Fetches a specific revision associated with a trigger.
Parameters
• triggerID: number
The ID of the trigger.
• revisionID: number
The ID of the revision.
Returns
Promise
<object
>
Details of the specified trigger revision.
response
response:
object
result
result:
object
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:167
update()
update(
triggerID
,trigger
):Promise
<object
>
Updates an existing trigger.
Parameters
• triggerID: number
The ID of the trigger to be updated.
• trigger: object
The updated trigger object.
Returns
Promise
<object
>
The updated trigger.
response
response:
object
result
result:
object
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:101
updateMany()
updateMany(
triggers
):Promise
<object
>
Updates multiple triggers.
Parameters
• triggers: object
[]
An array of trigger objects to be updated.
Returns
Promise
<object
>
The response from the update request.
response
response:
object
result
result:
object
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:118