Hooks
Rules Engine can trigger external actions when:
- Event received
- Flow progress incremented
- Flow completed
- Event did not satisfy flow rules
Each flow can include up to 5 hooks.
When hook is triggered, it provides the following fields to the target service:
Field | Type | Description |
---|---|---|
clientId | String | client identifier (e.g. INCROWD ). |
flowIf | String | Parent flow identifier. |
hookId | String? | Optional hook identifier. |
authId | Integer? | User identifier, blank for non-user events. |
data | Object | Any additional data associated with the hook. |
event | Event | The event associated with the hook. |
status | Condition | The condition of the hook. |
hookId
can be specified to avoid duplicate hook events. This could happen if Rules Engine encounters internal error and retries flow execution.Please note that deduplication is not implemented by drivers, target service is responible for rejecting hook triggers if specified
hookId
+authId
combination was processed already.
Drivers
Hooks support different drivers. A driver specifies resource type that Rules Engine sends an event to when the flow execution result matches the hook condition.
Please note that all hook.data
fields with __
prefix will not be passed to the target hook destination
and are intended to be used only for driver configuration.
HTTP
Sends http POST request to the target resource.
Driver accepts the following parameters (specified in hook.data
):
{
"__endpoint": "https://example.com/v1/fanx/hook",
"__method": "POST",
"__authorization": "Basic aGVsbG86d29ybGQ=",
"__headers": {
"User-Agent": "Rules-Engine/1.0",
"X-ENTITY-ID": "12345"
}
}
PROGRESS
Change any flow status.
Driver accepts the following parameters (specified in hook.data
):
{
"__flowId": "218c326a-cc14-48bc-a9cf-d85553dcd1cd",
"__action": "INCREMENT", // SET/INCREMENT/RESET/COMPLETE
"__progress": 1
}
EVENT
Generate new event (supports both user an non-user event types).
Driver accepts the following parameters (specified in hook.data
):
{
"__sourceSystem": "custom-service",
"__sourceSystemId": "event-type",
"__userEvent": true,
"__data": {
"hello": "world",
"value": 12.34
}
}
TRANSACTION
Produce Rewards Service transaction.
Driver accepts the following parameters (specified in hook.data
):
{
"__parentId": "9e9f8f63-8b3b-4635-acad-4e3cb249bffd",
"__groupId": "496e0d37-408b-4f9c-9d5b-8b90a57f05b9",
"__sourceSystem": "rules-engine",
"__type": "POINTS",
"__operation": "CREDIT",
"__data": {
"amount": 50
},
"__isComparable": true,
}
KAFKA
not implemented yet