Skip to content

OpenAmbientIoT/wiliot-webhooks-demo-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample App to demonstrate working of Webhooks Connection for Wiliot

Overview

This sample app demonstrates how to use Wiliot webhooks to receive events from Wiliot Cloud Platform. The app is written in Node.js and uses the Express framework. It also uses the ngrok tool to generate a webhook URL.

Prerequisites

  • Node.js installed on your machine
  • ngrok installed on your machine
  • A Wiliot account. If you don't have one, you can sign up here.
  • A Wiliot device. If you don't have one, you can buy one here.

Setup

  1. Clone this repository to your local machine.

  2. Change directory to demos/wiliot-demo-webhooks-nodejs

$ cd demos/wiliot-demo-webhooks-nodejs
  1. Run the following command to install the dependencies:
$ npm install
  1. Run the following command to start the app:
$ npm start
  1. You should see the following output in the terminal:
vyshakhbabji@Vyshakhs-Mini wiliot-demo-webhooks % npm start 

> demos@1.0.0 start
> node index.js

Starting ngrok . Please wait ...
Webhook url is ready to use. Your webhook url is :  https://6285-2600-1700-dd90-14f0-fc10-ab-3e0a-9a1b.ngrok.io/webhook



Starting express server....
Your webhookURL is:  https://6285-2600-1700-dd90-14f0-fc10-ab-3e0a-9a1b.ngrok.io/webhook
Started Server.... 
App is listening at http://localhost:8080
  1. Copy the webhook url from the output and use it in the setting-up-webhook-connection process.

  2. Open the ngrok dashboard at http://localhost:4040/inspect/http to inspect the events sent to your webhook url.

  3. When you test the webhooks on Wiliot's management portal, you should see the events in the ngrok dashboard and in the terminal where you started the app similar to the following:

Event received: 
 Event Name  temperature 
 Value 35.5 
 StartTime  1675828046616   
 EndTime 1675828046616 
 OwnerId 607737204301 
 CreatedOn 1675828046616 
 AssetId testAsset 
 CategoryID testCategory 
 Confidence 0.50 
 KeySet [ (key: temperature, value: 35.5) ]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published