Skip to main content

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:

FieldTypeDescription
clientIdStringclient identifier (e.g. INCROWD).
flowIfStringParent flow identifier.
hookIdString?Optional hook identifier.
authIdInteger?User identifier, blank for non-user events.
dataObjectAny additional data associated with the hook.
eventEventThe event associated with the hook.
statusConditionThe 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