Rules integration#
The optional webhooks_rules submodule lets Rules react to incoming requests
and send configured outgoing webhooks.
Installation#
Install Rules 4.0.1 or later and enable the integration:
1 2 | |
Configure reactions at Configuration > Workflow > Rules
(/admin/config/workflow/rules). The integration adds events and actions in
the Webhooks category.
Incoming events#
- Incoming webhook received (
webhooks_rules.received) fires after the request passes its configured authentication checks. An endpoint without authentication requirements also reaches this event. - Incoming webhook verification failed
(
webhooks_rules.verification_failed) fires when signature or token verification fails. It does not turn the rejected request into an accepted one.
Both events expose these Rules variables:
| Variable | Value |
|---|---|
config_id |
Incoming webhook configuration ID |
delivery_id |
Received or generated delivery identifier |
event_id |
Event identifier supplied by the sender, or an empty string |
attempt_id |
Attempt identifier supplied by the sender, or an empty string |
event_name |
Incoming event name |
content_type |
Request content type |
payload |
Decoded request payload |
raw_body |
Exact request body before decoding |
headers |
Original lowercase header names, each containing a list of values |
The failure event also exposes error_type (signature_mismatch or
token_mismatch) and a generic error_message. It does not expose the
configuration object, configured secrets, or the verification exception.
The payload and headers contain data supplied by the sender.
Use the standard Data comparison condition on config_id to select a
specific incoming configuration. Comparison is against the complete ID.
For non-blocking incoming configurations, the received event runs when the queue worker processes the request. Original body and header values travel with the queued webhook; they do not depend on the current HTTP request. Older queue items lack the original header snapshot and expose the normalized headers retained by those items instead. Queue retries may execute a reaction again; use a suitable business identifier for idempotent updates.
Mapping incoming values#
Payloads and headers can have arbitrary keys. The Get a webhook data value
action (webhooks_rules_get_value) reads a value using a JSON Pointer:
| Input variable | Pointer | Selected value |
|---|---|---|
payload |
/order/id |
Nested order ID |
payload |
/items/0/title |
Title of the first item |
headers |
/x-custom-header/0 |
First custom header value |
An empty pointer selects the whole input. In keys, use ~1 for / and ~0
for ~. The action provides value and the boolean found, distinguishing
missing keys from keys whose value is null, false, or zero. Rename the
provided variables when using multiple lookup actions.
For example, to create content from an incoming request:
- Add a reaction for Incoming webhook received.
- Compare
config_idwith the intended incoming configuration ID. - Read
/order/titlefrompayloadand name the provided valueorder_title. - Use Rules' entity creation and data assignment actions to populate the
desired content type, selecting
order_titleas the title value. - Save the entity using Rules' entity save action.
To apply conditions to extracted values, place the lookup before a nested Rules rule or conditional expression that uses the provided value.
Sending outgoing webhooks#
The Send a configured webhook action (webhooks_rules_send) takes:
webhook_id: an active outgoing configuration, selected from the options.payload: an array selected from Rules data, or JSON object/array text.event_name: an optional event name, defaulting torules.send.
The action provides delivery_id. This identifies the delivery; it is not
confirmation that the remote system processed the request.
For example, add the send action to a content-update reaction and choose an
outgoing configuration. Supply a JSON object as its payload, or select an
array already available in the reaction. To forward an incoming order,
extract /order from payload and select the resulting value as the outgoing
payload.
Missing, inactive, and incoming configurations are rejected at execution time, including when a previously valid destination has been disabled. Malformed JSON and scalar payloads are rejected before dispatch.
Sending uses webhooks.service; the integration does not implement a second
HTTP client, queue, or retry mechanism. The existing delivery service controls
authentication, serialization, timeouts, queueing, and retries according to
the capabilities and settings of the installed Webhooks version.
For incoming requests, decoding errors, unknown endpoints, and activation pings do not emit either of the integration's events unless the underlying receiver dispatches the corresponding Webhooks event.