Skip to main content

Slack, Teams, mail and calendar triggers

These triggers let a saved workflow react to the places where people already work. Someone mentions your Slack app in a channel, or a Teams outgoing webhook in a Teams channel, and the workflow starts with their message. A new mail lands in an Outlook or Gmail mailbox, or an Outlook or Google calendar changes, and the workflow starts with what changed.

They are webhook triggers with a sender picked from five services. The gateway checks each delivery the way that service signs it, answers the service's setup handshake for you, and then checks who sent the event and where it came from against a mapping you keep on the trigger. Anyone not in the mapping, and any channel, mailbox or calendar not in it, is refused before the workflow sees anything, and nothing of the refused message is kept.

They need the same database, license features (workflow_runner and workflow_triggers) and general_settings.workflow_triggers.inbound_webhooks: true setting as any webhook trigger, plus a public HTTPS address for the gateway in PROXY_BASE_URL, because each service calls the gateway from the internet.

Scenario​

An operations team wants to type @helper summarise the open incidents in its #ops Slack channel and get a summary from a saved workflow. Only the three people on the on-call rota may start it, and only from #ops, so a mention in another channel or from a guest account does nothing. The workflow runs as the team lead's key with a one dollar budget per run, and the fire history shows every refused mention with the reason.

Steps​

  1. Save the summary workflow as a definition whose input contract has trigger and payload as object fields, or plan an input mapping such as {"request": "payload.event.text", "asked_by": "payload.source.end_user_id"}.

  2. In Slack, create an app, give it the app_mentions:read bot scope, install it to your workspace and copy the Signing Secret from Basic Information. Note your workspace id (it starts with T), the channel id of #ops (it starts with C) and the member id of each on-call person (it starts with U).

  3. In the Admin UI open Workflow Runs under Agentic, switch to Triggers and click New trigger. Keep Signed webhook, set Who sends it to Slack mentions, fill in the Slack workspace id, map each Slack member id to their gateway user id under Who may start it, list #ops with the gateway users who may read it under Where it listens, and paste the Slack secret into Signing secret from the service. Pick the saved workflow, the key it runs as and the run budget, and click Create trigger. From the API the same trigger looks like this.

    curl -X POST http://localhost:4000/v1/triggers/new \
    -H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
    -d '{
    "name": "ops helper",
    "source": {
    "kind": "webhook",
    "scheme": "slack",
    "access": {
    "workspace": "T012AB3C4",
    "people": {"U012AB3CD": "alice", "U045EF6GH": "bob"},
    "readers": {"C0123456789": ["alice", "bob"]}
    }
    },
    "provider_secret": "8f742231b10e8888abcd99yyyzzz85a5",
    "definition_id": "def-incident-summary",
    "definition_version": 2,
    "actor_key": "sk-my-key",
    "run_budget_usd": 1.0
    }'
  4. Open the new trigger and copy its Webhook URL.

  5. In Slack, turn on Event Subscriptions, paste the webhook URL as the Request URL and subscribe to the app_mention bot event. Slack sends a signed check, the gateway answers it, and Slack shows Verified. Save the change.

  6. Mention the app in #ops. To try the gateway without Slack, sign a delivery yourself the way Slack does.

    SECRET="8f742231b10e8888abcd99yyyzzz85a5"; TS=$(date +%s)
    BODY='{"type":"event_callback","team_id":"T012AB3C4","event_id":"Ev0001","event":{"type":"app_mention","user":"U012AB3CD","channel":"C0123456789","text":"<@U0HELPER> summarise the open incidents","ts":"1700000000.000100"}}'
    SIG="v0=$(printf 'v0:%s:%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')"
    curl -X POST "http://localhost:4000/v1/triggers/webhook/$TRIGGER_ID" -H "Content-Type: application/json" \
    -H "X-Slack-Request-Timestamp: $TS" -H "X-Slack-Signature: $SIG" -d "$BODY"
  7. Watch Fire history on the trigger. A mention from someone on the rota shows started with a Run link, and a mention from anyone else shows refused with the outcome source_denied.

Expected result​

The create call answers 200 with the trigger and "signing_secret": null, because Slack issued the secret and the gateway never shows it again. A mention from a mapped person answers 200 with a pending fire.

{"fire_id": "fire_01J...", "status": "pending", "run_id": null}

A mention from anyone else, or from another channel or workspace, also answers 200 so Slack does not retry it, but with "status": "refused", and no run starts. Slack's own retries of the same event (X-Slack-Retry-Num) return the first fire instead of a second run.

What each service needs​

Pick the service under Who sends it in the Admin UI, or set source.scheme through the API. Every one needs source.access, described in who may start it.

ServiceschemeWhat starts itHow the gateway checks itWhat you give the gateway
SlackslackA mention of your app (app_mention)X-Slack-Signature over v0:<timestamp>:<body> with the app's signing secret, the timestamp within five minutes, and Slack's url_verification check answered with its challengeThe app's signing secret as provider_secret, the workspace id as access.workspace
Microsoft TeamsteamsA message that mentions an outgoing webhook in a channelThe Authorization: HMAC <signature> header, an HMAC-SHA256 of the body with the security token, and the message timestamp within five minutesThe security token Teams showed when you created the outgoing webhook as provider_secret, the Microsoft tenant id as access.workspace
Outlook mail and calendarmicrosoft_graphA new or changed mail message or calendar event in a mailbox, through a Microsoft Graph change notification subscriptionGraph's validationToken check answered in plain text, then clientState on every notification compared with the trigger's secretThe Microsoft tenant id as access.workspace. The gateway gives you a secret once, which you send as clientState when you create the subscription
GmailgmailA change in a mailbox, through Gmail's users.watch and a Google Cloud Pub/Sub push subscriptionThe Google-signed token in Authorization: Bearer, its issuer, its audience, its lifetime, and that it was issued for your push service account with a verified emailThe push subscription as access.workspace, the push audience and the push service_account
Google Calendargoogle_calendarA change in a calendar, through an events.watch push channelX-Goog-Channel-Token compared with the trigger's secret. The first sync message is acknowledged without a fireThe gateway gives you a secret once, which you send as the channel token when you call events.watch. access.workspace is optional

Each service then gets the answer it expects. Slack, Gmail and Google Calendar get 200 with the fire, Teams gets a short message that shows in the channel ("Got it, the workflow is starting." or "This workflow is not open to you here."), and Microsoft Graph gets 202. The run itself starts in the background, so the reply never waits for the workflow.

Microsoft Teams​

In Teams, open the team, then Manage team, Apps, Create an outgoing webhook. Give it a name, paste the trigger's webhook URL as the callback URL and copy the security token Teams shows once. Create the trigger with "scheme": "teams" and that token as provider_secret. People start the workflow by mentioning the webhook's name in a channel of that team. The sender is matched by their Microsoft Entra object id (from.aadObjectId), and the place by the channel id.

Outlook mail and calendar​

Create the trigger with "scheme": "microsoft_graph", copy the secret it shows once, then create a Microsoft Graph subscription with your Microsoft app's credentials, for example for new mail in one mailbox.

curl -X POST https://graph.microsoft.com/v1.0/subscriptions \
-H "Authorization: Bearer $GRAPH_TOKEN" -H "Content-Type: application/json" \
-d '{
"changeType": "created",
"notificationUrl": "https://gateway.example.com/v1/triggers/webhook/trg_01J...",
"resource": "users/3f2b1c4d-0000-4000-8000-1234567890ab/messages",
"expirationDateTime": "2026-11-27T09:00:00Z",
"clientState": "whsec_..."
}'

Use users/<id>/events for calendar events. Graph checks the address first, and the gateway answers that check. Each notification names the mailbox owner's user id, which is both the sender and the place in the mapping, so list that user id under Who may start it and Where it listens. The workflow gets the notification with its resource and resourceData (never clientState), and can read the message or event itself through a tool that holds Graph access. Graph subscriptions expire after a few days, so renew them before expirationDateTime. Lifecycle notifications such as reauthorizationRequired are acknowledged and start nothing.

Gmail​

Gmail sends mailbox changes to a Google Cloud Pub/Sub topic. Create a push subscription on that topic with the trigger's webhook URL as the endpoint, turn on authentication with a service account, and set the audience, usually to the webhook URL. Create the trigger with "scheme": "gmail", the subscription path (projects/<project>/subscriptions/<name>) as access.workspace, and the same values as audience and service_account. Then call users.watch for each mailbox with that topic. Gmail triggers keep no secret, because Google signs every push, so Rotate signing secret is not offered for them. The sender and the place are the mailbox address, and the workflow gets email_address, history_id and message_id, which a tool with Gmail access can use to read what changed.

Google Calendar​

Create the trigger with "scheme": "google_calendar", copy the secret it shows once, and call events.watch on the calendar with the webhook URL as the channel address and the secret as the channel token. Watch the calendar by its address, such as alice@example.com, rather than primary, because the gateway reads the calendar id from the notification's resource address and matches it against the mapping. The workflow gets calendar_id, channel_id, resource_id, resource_state and message_number. Channels expire, so renew them on Google's schedule.

Who may start it​

The access mapping on the trigger decides which events reach the workflow. It helps you keep a workflow that runs with one person's key from acting for anyone who happens to be in the same Slack workspace or can send mail to the mailbox.

FieldWhat it holds
workspaceThe Slack workspace id, the Microsoft tenant id or the Pub/Sub subscription. Required for every service except Google Calendar. An event from anywhere else is refused, so the same app installed in another workspace cannot start your workflow
peopleEach sender in the service mapped to a gateway user id: a Slack member id, a Microsoft Entra object id, or a mailbox or calendar address. 1 to 500 entries
readersEach channel, chat, mailbox or calendar the trigger listens to, with the gateway user ids allowed to read what arrives there. 1 to 200 places, each with 1 to 500 users

Every check fails closed, in this order. The event must come from workspace, from a place listed in readers, from a sender listed in people, and the mapped gateway user must be one of that place's readers, must still exist on the gateway, and must be able to see the trigger (its owner for a private trigger, a member of its team for a team trigger, a member of its organization for an organization trigger). Ids are compared without regard to upper and lower case, and the same id listed twice that way is refused when you save.

A refused event still leaves one fire in the history, with the outcome source_denied and the reason, so the trigger's owner can see who tried. The fire keeps none of the message, the event is never passed to the workflow, and refusals never count toward auto-disable, so a stranger mentioning the app cannot switch the trigger off.

The run still uses the trigger's own key and budget. The mapping only decides whether the event may start it, and the workflow learns who asked from payload.source.end_user_id.

What the workflow receives​

Every fire's payload has the same two parts, so one input mapping works for every service.

{
"source": {
"provider": "slack_mention",
"workspace": "T012AB3C4",
"container": "C0123456789",
"sender": "U012AB3CD",
"end_user_id": "alice"
},
"event": {"type": "app_mention", "user": "U012AB3CD", "channel": "C0123456789", "text": "<@U0HELPER> summarise the open incidents", "ts": "1700000000.000100"}
}

provider is one of slack_mention, teams_message, outlook_mail, outlook_calendar, gmail and google_calendar. event is the Slack event, the Teams activity, the Graph notification without clientState, the Gmail notice or the calendar notice described above. Map fields onto the workflow's own inputs with paths such as payload.event.text and payload.source.end_user_id.

Secrets​

Slack and Teams issue their own secret, so you paste it as provider_secret when you create the trigger. The gateway stores it encrypted, shows only its last four characters as the hint, never writes it to the audit log or the trigger's settings, and never shows it again. When Slack gives you a new signing secret or you recreate the Teams webhook, open the trigger and use Replace the secret from the service, or call the API.

curl -X POST http://localhost:4000/v1/triggers/rotate_secret \
-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
-d '{"trigger_id": "trg_01J...", "provider_secret": "0123456789abcdef0123456789abcdef", "grace_seconds": 3600}'

The old secret keeps verifying for grace_seconds, so deliveries already on their way still arrive. Outlook and Google Calendar triggers use a gateway secret, rotated with Rotate signing secret like any webhook. A trigger's sender cannot change after it is made, and provider_secret cannot be changed through update, so create a new trigger to move to another service.

Admin UI​

On the Triggers tab of Workflow Runs, New trigger with Signed webhook shows Who sends it. Picking a service adds these controls, each with help text under it.

ControlWhat it does
Who sends itThe service, or the plain Standard Webhooks and X-Hub-Signature-256 schemes. It cannot change after the trigger is made.
Slack workspace id, Microsoft tenant id or Pub/Sub subscriptionThe workspace the events must come from. Not shown for Google Calendar.
Who may start it (JSON: sender id to gateway user id)The people mapping. It starts with an example to replace.
Where it listens (JSON: channel, mailbox or calendar id to the gateway users who may read it)The readers mapping.
Signing secret from the serviceSlack and Teams only, and only when creating. A password field, so the secret is not shown on screen.
Push audience and Push service accountGmail only.

For Outlook and Google Calendar, the form says that the secret shown once after you save is the clientState or channel token. On a Slack or Teams trigger's sheet, Manage shows Replace the secret from the service and Replace secret instead of Rotate signing secret, and a Gmail trigger shows neither. Only the person whose key the trigger runs as, or a proxy admin, sees them.

Errors​

StatusMessage or bodyWhat it meansFix
401{"error": "invalid signature"}The service signature, clientState, channel token or Google token did not match, the delivery is older than five minutes, or the trigger is unknown or off. A Graph batch with one wrong clientState is refused whole.Check the secret on the trigger, replace it if the service changed it, and check the gateway clock. For Gmail check the push audience and service account.
400{"error": "the delivery is not in the expected shape"}The signature verified, but the body or headers are not what that service sends, for example a Gmail push without a mailbox address or a calendar notice without a calendar address.Check that the trigger's sender matches the service that calls it.
429{"error": "too many requests"}More events than the trigger's Most fires per minute arrived. Events already accepted in the same Graph batch are kept, and when the service retries, those events return their first fire without counting against the limit again, so the rest go through once the minute rolls over.Raise the limit or narrow the subscription.
200 with "status": "refused", or the Teams reply "This workflow is not open to you here."Fire outcome source_deniedThe sender, place or workspace is not in the mapping, the mapped user may not read that place, no longer exists or cannot see the trigger.Read the reason in Fire history and add the person or place to the mapping if they should be allowed.
422A slack trigger needs provider_secret, A teams trigger needs provider_secretThe trigger was created without the service's secret.Paste the secret from Slack or Teams.
422provider_secret must be 16 to 512 visible characters, provider_secret cannot contain spaces, provider_secret must be the base64 security token Teams showed for the outgoing webhookThe pasted secret cannot be the one the service signs with.Copy the secret again without spaces.
422provider_secret applies to slack and teams triggers onlyA secret was sent for another kind of trigger.Leave it out, the gateway issues its own.
422a slack trigger needs access: the people and places it accepts events from, a slack trigger needs access.workspace, access applies to slack, teams, microsoft_graph, gmail and google_calendar triggers, audience and service_account are both required for gmail triggers and only for them, ... is listed twice when upper and lower case are ignoredThe source is incomplete for its service.Fill in the field the message names.
422A webhook's sender cannot change; create a new trigger, Change provider_secret with rotate_secret, not updateAn update tried to change the service or the secret.Create a new trigger, or use Replace secret.
422Gmail triggers are checked by Google's signed token, no secretA Gmail trigger was asked to rotate a secret it does not have.Nothing to rotate. Change the push service account on the trigger instead.

Logs​

LevelLineMeaningAction needed
INFOworkflow trigger <trigger id> refused a <provider> event: <reason>An event from someone or somewhere outside the mapping was refused. The line names no person and carries no message text.None, unless a person who should be allowed is refused. Then add them to the mapping.

Refused deliveries before a fire is written are counted in spanway_workflow_trigger_webhook_rejected_total by reason (signature, timestamp, missing_headers, unreadable, rate_limited, too_large and not_json), and refused mappings in spanway_workflow_trigger_fires_total{kind="webhook",status="refused"}. The log reference lists every workflow line, and the Prometheus page lists both counters.

With OpenTelemetry turned on, every delivery is a workflow_trigger webhook span with spanway.workflow_trigger.id, spanway.workflow_trigger.scheme (for example slack or microsoft_graph, unknown for a trigger id that does not exist) and the HTTP status the sender got. It carries no message text and no sender ids. The run a fire starts has its own trace. Fires are not a source on the Query page or in Explore, because a fire row keeps the sealed input that started it until the run begins. Use Fire history on the trigger, the counters above and the audit log instead.

The access mapping is personal data. It pairs outside identities, such as Slack or Teams member ids and mailbox or calendar addresses, with gateway users. A data subject export lists the entries that name a user, and an erasure removes them, see retention and data subject requests.