# Integrate with Webhook
In this article, we will simulate temperature and humidity data and report these data to EMQX Cloud via the MQTT protocol and then use the EMQX Cloud Data Integrations to dump the data into Webhook.
Before you start, you need to complete the following operations:
Deployments have already been created on EMQX Cloud (EMQX Cluster).
For Professional Plan users: Please complete Peering Connection Creation first, all IPs mentioned below refer to the internal network IP of the resource.(Professional Plan with a NAT gateway can also use public IP to connect to resources)
For Standard Plan users: No peering connection is required, all IPs below refer to the public IP of the resource.
# Create a Web server
You could use the following python code to create a simple Web server.
from http.server import HTTPServer, BaseHTTPRequestHandler class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.end_headers() self.wfile.write(b'Hello, world!') def do_POST(self): content_length = int(self.headers['Content-Length']) body = self.rfile.read(content_length) print("Received POST request with body: " + str(body)) self.send_response(201) self.end_headers() httpd = HTTPServer(('0.0.0.0', 8080), SimpleHTTPRequestHandler) httpd.serve_forever()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# EMQX Cloud Data Integrations configuration
Go to Deployment Details and click on EMQX Dashboard to go to Dashboard.
New Resource
Click on Data Integrations on the left menu bar, drop down to select the Webhook resource type. Fill in the webhook information you have just created and click Test. If you get an error, instantly check that the configuration is correct.
Rule Testing
Click
Data Integration
on the left menu bar, find the configured resource, click New Rule, and then enter the following rule to match the SQL statementSELECT timestamp as up_timestamp, clientid as client_id, payload.temp as temp, payload.hum as hum FROM "temp_hum/emqx"
1
2
3
4
5
6
7Add a response action
Click Next, select the resource created in the first step, make sure Action Type → Send Data to Web Service, and fill in the blanks and following data:
Message content template:
{"up_timestamp": ${up_timestamp}, "client_id": ${client_id}, "temp": ${temp}, "hum": ${hum}}
1Return to the list of rules
View rules monitoring
# Test
Use MQTT X (opens new window) to simulate temperature and humidity data reporting
You need to replace broker.emqx.io with the created deployment connection address, and add client authentication information to the EMQX Dashboard.
View data dump results