Skip to main content

Observability and Monitoring

Send a webhook to your systems when a work item finishes

When a workflow item finishes, Thunk.AI can notify an external system with an HTTPS POST to a URL you configure. Use this to send completion events into an observability platform (for example Amplitude or Mixpanel), a custom API, or any endpoint that accepts JSON.

This is an outbound notification from Thunk.AI to your systems. It is separate from the thunk’s inbound webhook, which receives form submissions and other requests into the thunk.

Where to configure it

  1. Open your thunk.

  2. In the left navigation, open Monitor.

  3. Open the Observability tab.

Only thunk admins can edit these settings. The fields are treated as secrets in the UI.

Settings

Webhook URL

The HTTPS endpoint that receives the POST when a work item finishes. Leave this empty if you do not want outbound completion notifications.

Header

Optional HTTP headers for the request, one per line. Use this for authentication or other receiver requirements (for example an Authorization header).

Transform

The request body. This is a template: you write the JSON (or other text) your receiver expects, and insert values from the completion event using template tags such as <%- ... %> and <%= ... %>.

The completion event is available in the template as input.

When the webhook fires

Thunk.AI sends the webhook once per work item, when that work item finishes. The event name in the payload is workflow_completed.

If Webhook URL is empty, nothing is sent.

Values available in Transform

These are the main fields you can reference in the Transform template:

Template path

Meaning

input.event

Event name (workflow_completed)

input.eventId

Unique id for this notification

input.thunkId

Id of the thunk

input.timestamp

When the workflow finished

input.metadata.startTime

When the work item started

input.metadata.elapsedTime

Elapsed time in milliseconds

input.metadata.initiatedBy

User who initiated the run

input.metadata.properties

Object of the work item’s output column values

input.metadata.aiCost

AI cost for the work item, when available

input.metadata.aiTime

AI processing time for the work item, when available

Output column values live under input.metadata.properties.<columnName>, using the column names from your thunk’s workflow outputs.

Example Transform

This example builds a JSON body with completion time, duration, and output columns:

{
  "event": <%- JSON.stringify(input.event) %>,
  "completed_at": <%- JSON.stringify(input.timestamp) %>,
  "started_at": <%- JSON.stringify(input.metadata.startTime) %>,
  "elapsed_ms": <%- JSON.stringify(input.metadata.elapsedTime) %>,
  "outputs": <%- JSON.stringify(input.metadata.properties || {}) %>
}

Tips for reliable templates:

  • Prefer <%- JSON.stringify(…) %> for values — especially dates — so the body stays valid JSON with ISO timestamps.

  • If a field might be missing, guard it (for example input.metadata.properties.someField || null) so the rendered body does not contain the bare token undefined, which breaks most JSON receivers.

  • Match field names and types to what your receiver expects. Extra fields can also be rejected if the receiver uses a strict schema.

If the webhook fails

A failed notification does not fail the workflow. The work item still finishes successfully; only the outbound POST failed.

When delivery fails, Thunk.AI records a message in the thunk’s Automation Log (under Monitor) with details such as the HTTP status or a template-rendering problem. Check:

  1. The Webhook URL (reachable HTTPS endpoint).

  2. The Header (auth and required header names).

  3. The Transform (valid JSON after rendering; field names and types your receiver accepts).

Did this answer your question?