Skip to main content

Hook System

The friendly integration method, also known as hook system, enables seamless communication between our application and external systems. This feature allows us to send notifications or requests to external systems in real-time, without requiring manual intervention.

How it Works

  1. Trigger: A specific event occurs within our application, such as the creation of a new task.
  2. Request Sent: The webhook is triggered and sends an HTTP request to your external system with relevant data.
  3. Response Received: Your external system processes the request and sends back a response to the hook system.

Benefits

The hook system offers several benefits, including:

  • Real-time notifications: Receive instant notifications when events occur within our application.
  • Automated workflows: Integrate with external systems to automate workflows and improve efficiency.
  • Improved user experience: Enhance user experience by providing seamless integration with external services.

Supported Event Type

Event Typedesc (emit when ...)
infer.rulenew infer data from rule service
infer.linknew infer data like ooline/offline status
alert.triggeran alert is triggered
new_data.httpreceive new data from an HTTP source
new_data.mqttreceive new data from an MQTT source
new_data.wsreceive new data from a WebSocket source
new_data.simulatorreceive new data from a Simulator source
rule.state_changedevice field state changes caused by rule
task.createa new task is created
task.acka task is acknowledged
task.closea task marking it as complete or terminated
task.reopenreopen a previously closed task

Hook example

The JSON object represents a hook example. Using syntax like $(some_name) to use Hook Variable to replace the placeholder.

 {
"eventType": "task.create",
"hookType": "webhook",
"name": "test",
"baseURL": "https://some_ext_host.com",
"route": "/route/v1/basic",
"method": "GET",
"params": {
"filter": "extName||$eq||$(extName)}",
"task_id": "$(id)",
"category": "$(category)"
},
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer $(SECRET_JWT_TOKEN)"
},
"data": {
"desc": "this is the body data to send",
"call_back_url": "https://my_example_service.com"
},
"workspace": "e54421dc-5dd4-4b02-b0ea-262c7a8554dd",
}

Below, we will break down each field and provide an explanation.

PropertyTypeDescription
eventTypestringThe type of event that triggered this hook. In this case, it's "task.create", indicating that the hook was created when a new task was added.
hookTypestringThe type of hook being used. In this case, it's "webhook", which means the hook will send an HTTP request to another service.
namestringA human-readable name for the hook.
baseURLstringThe base URL of the external host that will receive the HTTP request from this hook.
routestringThe specific route on the external host that will be targeted by the hook's HTTP request.
methodstringThe HTTP method (e.g., GET, POST, PUT) that will be used when sending the request to the external host.
paramsobjectAn object containing key-value pairs of parameters that will be sent with the hook's HTTP request.
headersobjectAn object containing key-value pairs of HTTP headers that will be sent with the hook's request.
dataobjectAn object containing key-value pairs of data that will be sent with the hook's request.
workspacestringThe ID of the workspace where this hook was created (automatically assigned, not configurable by normal users).

Hook Variable

For EventType alert.trigger

VariableDesc
idUnique identifier of the alert
categoryCategory or type of the alert
deviceIdIdentifier of the device associated with the alert
workspaceWorkspace or context where the alert is being performed
descriptionBrief description of the alert
timestampDate and time when the alert was trigger
titleTitle of the alert
locationLocation of the alert

For EventType task.*

VariableDesc
idUnique identifier of the task
categoryCategory or type of the task
stateStatus or state of the task (e.g., open, closed)
deviceIdIdentifier of the device associated with the task
workspaceWorkspace or context where the task is being performed
descriptionBrief description of the task
openTimeDate and time when the task was opened
openByPerson who opened the task (email address)
ackTimeArray of dates and times when the task was acknowledged
lastAckTimeLast date and time when the task was acknowledged
ackByArray of people who acknowledged the task (email addresses)
closeTimeArray of dates and times when the task was closed
lastCloseTimeLast date and time when the task was closed
closeByArray of people who closed the task (email addresses)

For EventType rule.state_change

VariableDesc
deviceIdDevice id
deviceTypeDevice type
workspaceWorkspace id
timeDate and time when the changes happen
fieldField which state changed
stateTarget state for the field
messageDescription for the field state changes

For EventType infer.*state_change* or new_data.*

VariableDesc
idDevice id
typeDevice type
workspaceWorkspace id
onlinethe boolean online status
data field the device has
i.e. HUMIDITY,it will retrived the corresponding value

others veriable

Besides above specify variable per eventType, any seer variable defined in workspace can be used with syntax $().