|
| 1 | +--- |
| 2 | +title: "UIB" |
| 3 | +description: "" |
| 4 | +weight: |
| 5 | +aliases: [] |
| 6 | +--- |
| 7 | + |
| 8 | +[UIB's](https://www.uib.ai/) technology makes human to machine communications simple. Keep following this guide to find out how to send notifications on data events to WhatsApp. |
| 9 | + |
| 10 | +<!--more--> |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +1. A WhatsApp Business Account. |
| 15 | +2. The content of the notification message which you need to send to the customer has to be submitted and approved by WhatsApp, before it can be used. |
| 16 | + |
| 17 | +{{< info >}} Please send an email to [[email protected]](mailto:[email protected]) with your company details, Facebook Business Manager ID and an approximate number of messages you want to send per month. UIB's support team will respond you back with the pricing and the steps to proceed. {{</ info >}} |
| 18 | + |
| 19 | +{{< note >}} Please note that the template/notification name, name space, access key, etc. will be provided once the notification message content is approved by WhatsApp. {{</ note >}} |
| 20 | + |
| 21 | + |
| 22 | +## Define the Uplink Payload Formatter |
| 23 | + |
| 24 | +In order for UIB to be able to decode the data coming from {{% tts %}}, you need to create an uplink [payload formatter]({{< ref "/integrations/payload-formatters" >}}) on {{% tts %}} to set fields in the `decoded_payload` object of the uplink message. |
| 25 | + |
| 26 | +The notification message will be sent to the user if the `decoded_payload_warnings` field is not empty. You can push a text to rhe warnings array according to your parameter thresholds (`field1`, `field2`, etc. can be the data of your device, for example temperature or pressure). |
| 27 | + |
| 28 | +The example uplink payload formatter is shown below: |
| 29 | + |
| 30 | +```js |
| 31 | +function decodeUplink(input) { |
| 32 | + var data = {}; |
| 33 | + data.field1 = (input.bytes[0] << 8) + input.bytes[1]; |
| 34 | + data.field2 = (input.bytes[2] << 8) + input.bytes[3]; |
| 35 | + var warnings = []; |
| 36 | + if (data.field1 < -10) { |
| 37 | + warnings.push("Warning"); |
| 38 | + } |
| 39 | + return { |
| 40 | + data: data, |
| 41 | + warnings: warnings |
| 42 | + }; |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +## Configure {{% tts %}} |
| 47 | + |
| 48 | +Next, you need to create a Webhook integration by instantiating the **UIB** [Webhook template]({{< ref "/integrations/webhooks/webhook-templates" >}}). |
| 49 | + |
| 50 | +The **Application Key**, **Template Name** and **Template Namespace** values are provided by UIB, and you need to use them in the respective fields of the UIB Webhook template. |
| 51 | + |
| 52 | +The **Receiver Phone Number(s)**, to which the notification message is to be sent, need to be separated by comma on entry. |
| 53 | + |
| 54 | +The **Template Variables** should also be comma separated, and in the order as they appear in the notification message. Make sure to use the same parameter names which you have provided in the payload formatter above. |
| 55 | + |
| 56 | +{{< figure src="uib-template-webhook.png" alt="UIB webhook" >}} |
| 57 | + |
| 58 | + |
0 commit comments