Trigger
The Trigger
API lets you run an express
server that listens for Whereby webhooks and, based on your rules, returns a TRIGGER_EVENT_SUCCESS
event if the conditions of your trigger are met.
Constructor
const trigger = new Trigger(options: TriggerOptions)
TriggerOptions
Parameter
Type
Default
Description
port
number
4999
Port for the HTTP server
Methods
Method
Parameters
Returns
Description
start
void
Starts the Express server and begins accepting webhooks
Events
The Trigger
API extends EventEmitter
and emits lifecycle events after your trigger predicate returns true.
import { TRIGGER_EVENT_SUCCESS, Trigger } from "@whereby.com/assistant";
let hasJoined = false;
const trigger = new Trigger({
webhookTriggers: {
"room.client.joined": () => !hasJoined,
},
port: 4999,
});
trigger.on(TRIGGER_EVENT_SUCCESS, ({ roomUrl }) => {
console.log("Trigger successful for room: ", roomUrl);
});
Event
Payload
Emitted when
TRIGGER_EVENT_SUCCESS
{ roomUrl:string; triggerWebhook:
WherebyWebhookType
Trigger has met the required conditions
Last updated
Was this helpful?