Introduction

Webhooks are one of the most useful features of our platform. It allows developers and site owners to listen for events from the devices or WhatsApp server, which is useful for creating automated tasks.

This function is specifically designed for receiving events only, such as sms, WhatsApp chat, ussd response, and android notifications.

Use Cases

  • Create an autoreply bot for SMS and WhatsApp.
  • Save messages and chats to your own database on receive.
  • Save notifications to your own database on receive.
  • Save USSD responses to your own database on receive.
  • Send the payload to the specified email addresses.
  • Send an SMS/Chat when you get a notification from Facebook.
  • Do something when you get a notification from an app.

How It Works

The system gets a received event from both sources, then the webhook url will be invoked and the payload data is sent. When your webhook server receives it, you can do anything with the payload yourself. Payloads are sent with POST method to ensure efficient delivery.

Payload Structure

The payload structure is straightforward; you just need to check the type of payload and then process the content of the data body.

# sms

[
    "type" => "sms", // type of payload: received sms
    "data" => [
        "id" => 2, // unique id from the system
        "rid" => 10593, // unique id from the device
        "sim" => 1, // sim card slot
        "device" => "00000000-0000-0000-d57d-f30cb6a89289", // device unique id
        "phone" => "+639760713666", // sender phone number
        "message" => "Hello World!", // message
        "timestamp" => 1645684231 // receive timestamp
    ]
]

# whatsapp

[
    "type" => "whatsapp", // type of payload: received whatsapp chat
    "data" => [
        "id" => 2, // unique id from the system
        "wid" => "+639760713666", // whatsapp account phone number
        "phone" => "+639760666713", // sender phone number
        "message" => "Hello World!", // message
        "timestamp" => 1645684231 // receive timestamp
    ]
]

# ussd

[
    "type" => "ussd", // type of payload: received ussd response
    "data" => [
        "id" => 98, // unique id from the system
        "sim" => 1, // sim card slot
        "device" => "00000000-0000-0000-d57d-f30cb6a89289", // device unique id
        "code" => "*143#", // ussd code
        "response" => "Sorry! You are not allowed to use this service.", // ussd response
        "timestamp" => 1645684231 // receive timestamp
    ]
]

# notification

[
    "type" => "notification", // type of payload: received notification
    "data" => [
        "id" => 77, // unique id from the system
        "device" => "00000000-0000-0000-d57d-f30cb6a89289", // device unique id
        "package" => "com.facebook.katana", // application package name
        "title" => "Someone commented on your post!", // notification title
        "content" => "Someone commented on your post!", // notification content
        "timestamp" => 1645684231 // receive timestamp
    ]
]

Code Example

<?php

    $request = $_REQUEST;

    $secret = "WEBHOOK_SECRET"; // you can obtain this from (Tools -> Webhooks)

    /**
     * Validate webhook secret
     */

    if(isset($request["secret"]) && $request["secret"] == $secret):
        // Valid webhook secret
        $payloadType = $request["type"];
        $payloadData = $request["data"];

        // do something with the payload
        print_r($payloadType);
        print_r($payloadData);
    else:
        // Invalid webhook secret
    endif;
Go to Top