Skip to content

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

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Triggers(options): Triggers

Parameters

NameType
optionsany

Returns

Triggers

Overrides

Client.constructor

Defined in

clients/core/triggers.d.ts:6

Properties

_transporter

_transporter: Transporter

Inherited from

Client._transporter

Defined in

clients/client.d.ts:94


eventTarget

eventTarget: CustomEventTarget

Event target to handle custom events.

Inherited from

Client.eventTarget

Defined in

clients/client.d.ts:92


jsonAPINames

jsonAPINames: string[]

Array to hold names used in the JSON API.

Overrides

Client.jsonAPINames

Defined in

clients/core/triggers.d.ts:7


options

options: ClientOptions & { get: (key: string) => any }

Configuration options for the client.

Inherited from

Client.options

Defined in

clients/client.d.ts:86


sideLoad

sideLoad: any[]

Array to handle side-loaded resources.

Inherited from

Client.sideLoad

Defined in

clients/client.d.ts:89


useDotJson

useDotJson: boolean

Flag to indicate if the API endpoint should use '.json' ending.

Inherited from

Client.useDotJson

Defined in

clients/client.d.ts:91

Accessors

transporter

get transporter(): Transporter

Transporter for making requests.

Returns

Transporter

Inherited from

Client.transporter

Defined in

clients/client.d.ts:93

Methods

_rawRequest

_rawRequest(method, uri, ...args): Promise<{ response: any ; result: {} }>

Parameters

NameType
methodany
uriany
...argsany[]

Returns

Promise<{ response: any ; result: {} }>

Inherited from

Client._rawRequest

Defined in

clients/client.d.ts:130


bulkDelete

bulkDelete(triggerIDs): Promise<object>

Deletes multiple triggers based on their IDs.

Parameters

NameTypeDescription
triggerIDsnumber[]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

ts
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

NameTypeDescription
triggerobjectThe 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

ts
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

https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-trigger-action-and-condition-definitions

Example

ts
const definitions = await client.triggers.definitions();

Defined in

clients/core/triggers.d.ts:26


delete

delete(triggerID): Promise<object>

Deletes a specified trigger.

Parameters

NameTypeDescription
triggerIDnumberThe 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

ts
const response = await client.triggers.delete(12345);

Overrides

Client.delete

Defined in

clients/core/triggers.d.ts:124


emit

emit(eventType, eventData): void

Parameters

NameType
eventTypeany
eventDataany

Returns

void

Inherited from

Client.emit

Defined in

clients/client.d.ts:95


get

get(resource): Promise<NodeModule>

Parameters

NameType
resourceany

Returns

Promise<NodeModule>

Inherited from

Client.get

Defined in

clients/client.d.ts:114


getAll

getAll(resource): Promise<any[]>

Parameters

NameType
resourceany

Returns

Promise<any[]>

Inherited from

Client.getAll

Defined in

clients/client.d.ts:129


list

list(options?): Promise<object>

Lists all triggers, with optional filtering and sorting.

Parameters

NameTypeDescription
options?ObjectOptional parameters for listing triggers.
options.active?booleanFilter by active triggers if true or inactive triggers if false.
options.category_id?stringFilter triggers by category ID.
options.sort_by?stringPossible values are "alphabetical", "created_at", "updated_at", "usage_1h", "usage_24h", or "usage_7d". Defaults to "position".
options.sort_order?stringOne 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

ts
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

ts
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

NameTypeDescription
triggerIDnumberThe 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

https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-trigger-revisions

Example

ts
const revisions = await client.triggers.listRevisions(12345);

Defined in

clients/core/triggers.d.ts:154


on

on(eventType, callback): void

Parameters

NameType
eventTypeany
callbackany

Returns

void

Inherited from

Client.on

Defined in

clients/client.d.ts:96


patch

patch(...args): Promise<void | object>

Patches a resource.

Parameters

NameTypeDescription
...argsany[]The resources or parts of the resource path followed by the body.

Returns

Promise<void | object>

  • Either void or response object

Inherited from

Client.patch

Defined in

clients/client.d.ts:120


post

post(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.post

Defined in

clients/client.d.ts:122


put

put(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.put

Defined in

clients/client.d.ts:121


reorder

reorder(triggerIDs): Promise<object>

Reorders the triggers based on the provided trigger IDs.

Parameters

NameTypeDescription
triggerIDsnumber[]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

ts
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

NameTypeDescription
methodstringHTTP method (e.g., 'GET', 'POST').
uristringThe URI for the request.
...argsany[]Additional arguments for the request.

Returns

Promise<NodeModule>

  • The API response.

Inherited from

Client.request

Defined in

clients/client.d.ts:148


requestAll

requestAll(method, uri, ...args): Promise<any[]>

Parameters

NameType
methodany
uriany
...argsany[]

Returns

Promise<any[]>

Inherited from

Client.requestAll

Defined in

clients/client.d.ts:149


requestUpload

requestUpload(uri, file): Promise<any>

Parameters

NameType
uriany
fileany

Returns

Promise<any>

Inherited from

Client.requestUpload

Defined in

clients/client.d.ts:150


search(searchTerm): Promise<object>

Searches for triggers based on the provided search term.

Parameters

NameTypeDescription
searchTermstringThe 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

ts
const results = await client.triggers.search('exampleTerm');

Defined in

clients/core/triggers.d.ts:17


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


show

show(triggerID): Promise<object>

Retrieves details of a specific trigger.

Parameters

NameTypeDescription
triggerIDnumberThe 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

ts
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

NameTypeDescription
triggerIDnumberThe ID of the trigger.
revisionIDnumberThe 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

ts
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

NameTypeDescription
triggerIDnumberThe ID of the trigger to be updated.
triggerobjectThe 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

ts
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

NameTypeDescription
triggersobject[]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

ts
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

Released under the MIT License.