Declare a connection with defineConnection
A connection is how a workspace or a person signs in to the service. There are two kinds.visibility is workspace, user or both and chooses who may make a connection. Credentials are encrypted at rest and shown back only as a masked hint. In server code, ctx.connection() returns the connection in use.
A connection test in server code gives people an immediate “it works” or a clear error when they connect. If the service refuses the credentials, ctx.reportAuthFailure() makes Devias ask people to reconnect.
Declare a variable with defineVariable
A variable is a setting the module’s code reads, such as a region or an OAuth app’s client id.secret keeps it write-only, required makes the module ask for it, and defaultValue gives it a value when nobody sets one. Admins set variables on the module’s page in Settings → Modules.
ctx.variables[id] is the value in effect: the workspace’s own, else the default. A variable that nobody set and that has no default is absent.
Declare events with defineEvent
An event is something the service reports, such asinvoice.paid. Workflows can start from the declared events.
-
Declare the events.
Give each event an id and its name as the service writes it:
-
Handle the webhook.
In server code, add a
webhookwith aparsefunction. It verifies the delivery’s signature using the connection and returns the events the delivery carries. ThrowWebhookRejectedfor a bad signature or an unreadable body. Returning an empty array acknowledges the delivery with a success response and stores nothing. -
Give the service the address.
Each connection has its own webhook address, shown on the module’s Events tab.
webhookHelpin the manifest tells people where to paste it in the service.
externalId. It then announces the event to workflows that listen for it. A module can ship such a workflow itself, which is how the Stripe module records a payment when Stripe reports one.
Related
- Workflows in a module: react to events in the background.
- Install and connect modules: what users see.
- Actions and server code: the handler context.