Kafka Trigger
Kafka is an open-source distributed event streaming platform that one can use for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.
!!! note "Credentials" You can find authentication information for this node here.
Example Usage
1. Kafka Trigger node
This node will trigger the workflow when a new message is sent to the topic test_topic
. If you're using a different topic, use that instead. We are sending the message { "id": 1, "temp": 100 }
to test_topic
.
- First of all, you'll have to enter credentials for the Kafka Trigger node. You can find out how to do that here.
- Enter the name of the topic in the Topic field.
- Enter the group ID in the Group ID field.
- Click on Add Option and select 'JSON Parse Message'.
- Toggle JSON Parse Message to
true
. - Click on Execute Node to run the node.
2. IF node
This node will compare the value of temp
that we received in the message from the previous node. If the value is greater than 50, it will return true otherwise false.
- Click on Add Condition and select 'Number' from the dropdown list.
- Click on the gears icon next to the Value 1 field and click on Add Expression.
- Select the following in the Variable Selector section: Nodes > Kafka Trigger > Output Data > JSON > message > temp. You can also add the following expression:
{{$node["Kafka Trigger"].json["message"]["temp"]}}
. - Select 'Larger' from the Operation dropdown list.
- Set Value 2 to 50.
- Click on Execute Node to run the node.
3. Vonage node (send: sms)
This node sends an SMS to the specified phone number when the value of temp
is greater than 50
.
Create a Vonage node connected to the 'true' output of the IF node.
You'll have to enter credentials for the Vonage node. You can find out how to do that here.
Enter the name of the sender in the From field. If you're using a number, enter the number instead.
Enter the receiver's phone number in the To field.
Click on the gears icon next to the Message field and click on Add Expression.
Enter the following in the Expression field.
Alert!
The value of temp is {{$node["Kafka Trigger"].json["message"]["temp"]}}.
- Click on Execute Node to run the node.
4. NoOp node
Adding this node here is optional, as the absence of this node won't make a difference to the functioning of the workflow.
- Create a NoOp node connected to the 'false' output of the IF node.
- Click on Execute Node to run the node.
!!! note "Activate workflow for production" You'll need to save the workflow and then click on the Activate toggle on the top right of the screen to activate the workflow. Your workflow will then be triggered as specified by the settings in the Kafka Trigger node.