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
webhookTriggers
Custom matcher functions that the assistant can use to self-trigger TRIGGER_EVENT_SUCCESS
events.
Return true
from a WherebyWebhookTriggers
callback to fire this event or false
to ignore the incoming webhook.
Methods
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);
});
TRIGGER_EVENT_SUCCESS
Trigger has met the required custom conditions in a webhook trigger matcher function (matcher function returned true
).
Last updated
Was this helpful?