Zuwinda
Search…
Webhook
Event
Description
WHATSAPP_MESSAGE_RECEIVED
Received payload data if received message from whatsapp
WHATSAPP_MESSAGE_STATUS
Received update status message from whatsapp (sent, delivered, read, played, pending or failed);
WHATSAPP_INSTANCE_STATUS
Received update status instances whatsapp (connected, disconnected, or auth failure)
please capture response data from zuwinda to find out sample responses
example response whatsapp message received:
1
{
2
"event":"WHATSAPP_MESSAGE_RECEIVED",
3
"instances_id":"xxxxxxxx-xxx-xxxx-xxxx-xxxxxxx",
4
"from":"628151xxxxxx",
5
"fromMe":false,
6
"content":"!halo",
7
"location":{},
8
"liveLocation":{},
9
"contact":{},
10
"received_at":1623325474
11
}
Copied!
this is example code, using php:
1
<?php
2
$base_url = 'https://api.zuwinda.com/v1.2/message/whatsapp/send-text';
3
$secret_key = 'your zuwinda secret key webhook';
4
$zuwinda_token = 'your zuwinda token';
5
$post_data = file_get_contents('php://input');
6
$json = json_decode($post_data);
7
$signature = hash_hmac('sha256', json_encode($json->data), $secret_key);
8
$headers = getallheaders();
9
if ($headers['X-Zuwinda-Signature'] == $signature) {
10
$data = $json->data;
11
// log response from webhook
12
error_log(json_encode($data));
13
// filter by event message received
14
if ($data->event == "WHATSAPP_MESSAGE_RECEIVED") {
15
// your action
16
if ($data->content == "!halo") {
17
$ch = curl_init( $base_url );
18
$payload = json_encode( array( "instances_id" => $data->instances_id, "to" => $data->from, "content" => "Halo zuwinda 🥳" ) );
19
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
20
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'x-access-key:' . $zuwinda_token));
21
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
22
$result = curl_exec($ch);
23
curl_close($ch);
24
}
25
}
26
}
27
?>
Copied!
Last modified 11mo ago
Copy link