context
Facts about the current run.
Use this module to find out what started the script and, when a webhook payload is available, to read the request body and whether the sender was verified.
Usage Examples#
Reading the trigger#
import context from "context";
console.log(context.trigger);
Reading a webhook delivery#
import context from "context";
if (context.delivery) {
const payload = context.delivery.json();
console.log(payload);
}
Constants
context
Facts about the current run.
context.trigger is "schedule", "manual", or "webhook".
context.delivery is the payload for a webhook delivery or a manual test
payload. It is null for scheduled runs and manual runs without a payload.
Enums
TriggerTypes
The trigger types reported by context.trigger.
| Member | Description |
|---|---|
Schedule |
A schedule started the run. |
Manual |
A person started the run. |
Webhook |
An inbound webhook delivery started the run. |
Types
Delivery
The data from a webhook delivery or a manual test payload.
Properties
| Name | Type | Description |
|---|---|---|
id |
string |
The delivery ID supplied by the sender, or a generated ID when the source does not supply one. |
timestamp |
number | null |
Unix timestamp in seconds, or null when the source does not sign a timestamp. |
verified |
boolean |
Whether the endpoint verified the sender. False for unverified capability URLs and manual test payloads. |
body |
string |
The raw request body. |
json |
function |
Parses the body and returns a new object on
every call. Throws a |
RunContext
Facts about the current run.
Properties
| Name | Type | Description |
|---|---|---|
trigger |
string |
One of the |
delivery |
Delivery | null |
The payload for a webhook or manual test run; null when the run has no payload. |