Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Triggers

triggers: defines the connector’s trigger node (connector.<id>_trigger). Each entry is one trigger event the user can choose, of kind poll or webhook.

Poll triggers

A poll trigger requests a list from the API on a schedule and starts the workflow with the entries it has not emitted before.

triggers:
  new_row:
    kind: poll
    display_name: New row
    description: Starts the workflow for each row added to a sheet.
    params:
      - { name: spreadsheet, type: resource_locator, lookup: spreadsheets, required: true }
      - { name: sheet, type: options, lookup: sheets, depends_on: [spreadsheet], required: true }
    request:
      method: GET
      path: "/spreadsheets/{{ params.spreadsheet }}/values/{{ a1_range(params.sheet, 'A' ~ ((trigger.cursor or 1) + 1) ~ ':ZZ') | urlencode }}"
    output: { select: "$.values", split: true, map: { row: "{{ item }}" } }
    dedupe_key: "{{ item.row | json | sha256 }}"
    cursor: "{{ (previous or 1) + (items | length) }}"
    emit_on_first_poll: false
KeyDescription
request, paginate, outputAs for operations.
dedupe_keyTemplate over item. Entries whose key was already emitted are skipped. The last keys are kept in static data (bounded).
cursorTemplate evaluated after a poll with items (all fetched entries), previous (the last cursor) and trigger.now. The result is stored and available to the next poll as trigger.cursor. A null or empty result keeps the previous cursor.
emit_on_first_pollfalse (default): the first poll after activation only records state. true: emit what the first poll finds.

The request can use trigger.cursor, trigger.last_poll_at (RFC 3339), trigger.last_poll_unix, trigger.first_poll and trigger.now.

The poll interval is the trigger node’s poll-times setting. In HA mode only the leader process polls, so each poll happens once across the cluster.

Running the trigger manually in the editor fetches once and shows the result without changing the stored state.

Choosing a cursor

  • APIs with a “modified since” or “created after” filter: store the newest timestamp seen, and ask for entries after it. Use dedupe_key too, because timestamps are often second-granular and inclusive.
  • APIs that only list newest first: no cursor; rely on dedupe_key with a page size large enough to cover the poll interval.
  • APIs with event logs or change feeds: store the feed’s own position token.

Webhook triggers

A webhook trigger receives HTTP requests from the vendor at the node’s webhook URL.

triggers:
  issue_event:
    kind: webhook
    display_name: Repository event
    params:
      - { name: owner, type: string, required: true }
      - { name: repo, type: string, required: true }
      - name: events
        type: multi_options
        required: true
        options: [issues, issue_comment, pull_request, push, release]
      - { name: secret, type: string, description: Leave empty to generate one. }
    lifecycle:
      check:
        request: { method: GET, path: "/repos/{{ params.owner }}/{{ params.repo }}/hooks/{{ static.hook_id }}" }
        exists_when: "{{ response.status == 200 and response.body.config.url == webhook_url }}"
      create:
        request:
          method: POST
          path: "/repos/{{ params.owner }}/{{ params.repo }}/hooks"
          body:
            encoder: json
            fields:
              name: web
              active: true
              events: "{{ params.events }}"
              config:
                url: "{{ webhook_url }}"
                content_type: json
                secret: "{{ params.secret }}"
        store:
          hook_id: "{{ response.body.id }}"
      delete:
        request: { method: DELETE, path: "/repos/{{ params.owner }}/{{ params.repo }}/hooks/{{ static.hook_id }}" }
    verify:
      scheme: hmac_sha256
      header: X-Hub-Signature-256
      prefix: "sha256="
      secret: "{{ params.secret }}"
    respond: []
    filter: "{{ request.headers['x-github-event'] in params.events }}"
    output: { select: "$", split: false }

This follows the shape of GitHub’s repository webhooks (X-Hub-Signature-256 is an HMAC-SHA256 of the raw body, prefixed with sha256=).

Lifecycle

HookWhenNotes
checkActivation, when static data already has a registrationIf exists_when (default: status below 400) is truthy, nothing else happens.
createActivation, when there is no live registrationValues in store are saved to static data, for example the registration ID and a signing secret the vendor generated.
deleteDeactivation404 and 410 count as success. Static data is cleared afterwards.

webhook_url is the production URL of this node (<TAPPET_PUBLIC_URL>/webhook/<webhook id>, where the webhook ID is the node’s stable webhookId, or its node ID); activation fails with a clear error if TAPPET_PUBLIC_URL is not set. For services where users paste the URL themselves, omit lifecycle; the node shows the URL to copy.

Processing an incoming request

For each request, in order:

  1. respond: each rule’s when is evaluated over request. The first match is answered with its status (default 200), body (a string is sent as text/plain, anything else as JSON) and optional content_type, and the workflow does not start. Use it for URL-verification challenges. Rules run before signature verification, because some services send the challenge before a secret exists, so match them narrowly.
  2. verify: the signature is checked. On failure Tappet answers 401 and does not start the workflow; the reason is written to the execution log, not to the response.
  3. filter: if falsy, Tappet answers 200 with an empty body and does not start the workflow.
  4. output: the body (or output.value) is turned into items. If there are none, Tappet answers 200; otherwise the workflow starts, and the response follows the node’s response mode.

request has method, path, headers (lowercase names), query, body (parsed JSON, or a form object; a form whose only field payload holds JSON is unwrapped) and raw_body.

Signature verification

verify:
  scheme: hmac_sha256          # hmac_sha1 | hmac_sha256 | hmac_sha512 | token
  header: X-Signature
  prefix: "v1="                # stripped from the header value
  encoding: hex                # hex (case-insensitive) | base64
  secret: "{{ static.signing_secret }}"    # scope: credential, params, static
  payload: "v0:{{ timestamp }}:{{ body }}" # default: the raw body
  timestamp_header: X-Request-Timestamp
  tolerance_secs: 300
  • token compares the header with the secret directly (for services that send a shared token).
  • payload builds the signed string from body (the raw body as text) and timestamp (the value of timestamp_header). With a timestamp header, requests older or newer than tolerance_secs (default 300) are rejected, which blocks replays.
  • All comparisons are constant time. An empty secret fails verification rather than accepting every request.

Static data

Triggers keep their state in the workflow’s static data under the node’s name: registration IDs, secrets returned by the vendor, the poll cursor, recently seen dedupe keys and the time of the last poll. It is persisted with the workflow and survives restarts. Deactivating a webhook trigger clears its registration state.