Menu

Build a Facilities Management IoT Chatbot with Azure IoT Hub

By Aravindan Chandrasekaran | Internet of Things

Jun 08
Chatbot for Facilities Management

Managing thousands of IoT devices via a dashboard may not always be the most intuitive way. After all, who wants to scan through the clutter of a thousand different things and their notifications. In this blog post, we show you a unique approach to solve this problem through an IoT chatbot. Just like you chat with your co-workers, you can also chat with your devices, and they can respond back too.

Read on to know how a facilities management team interacts with the device/assets via a chat interface to make their maintenance chores easier and seamless.  This chat interface is powered by the Azure IoT Hub and PubNub. 

 

Overview of Azure IoT Hub

Azure IoT Hub can connect thousands of devices to control and monitor then via cloud-to-device and device-to-cloud interfaces and communicate using familiar protocols such as HTTP, AMQP and MQTT.

Azure IoT Hub

It supports multiple languages and platforms such as .NET, Node.js, PHP, Java, and Python on Windows and Linux.

Platforms supported by Azure IoT Hub

Azure IoT Hub is built to scale for managing hybrid cloud deployments and supports orchestration of services for distributed data storage, analytics, artificial intelligence and more.

Azure IoT Hub at Scale

 

Images Courtsey, Azure IoT Hub

In this blog post, we’ll show you how to deploy Azure IoT service that powers an application which can be used by the facilities management team of a building. If you can think of connecting all the building assets to the Azure IoT Hub, then there can be new ways of managing them via chatbots. Let’s look at how to build an IoT chatbot for this use case.

Facilities Management with IoT Chatbot

In a typical office building or premises,  a facilities management team takes care of maintaining all the utilities such as electrical, plumbing, sewage & fire safety systems, among others. For demonstrating this IoT chatbot, let’s consider only the electrical system for now. Imagine that the electrical staff uses a chat app, akin to Whatsapp or Slack, to coordinate repair and inspection works. Wouldn’t it be more convenient if that chat app also hooks up all of the several hundreds of the electrical points, appliances, and machinery?

If we somehow manage to do this, then for Jack and Mike, who are our champion electricians, replacing a fused light bulb will be just as easy as interacting with the bulb device socket via chat. Here is a simulated scenario of this interaction.

Facilities Management IoT Chatbot Interaction

So that’s the concept. All you need is an intelligent device and a chatbot to impersonate that device. Once deployed, the chatbot can take part in chat conversations and can convey commands and messages to and from the device.

If you have a chat interface to interact with your co-workers then why not extend it to also interact with the devices that you and your co-workers manage on a day to day basis

IoT Chatbot: Demo Setup

Want to know how we built this demo app?  Let’s dive in to learn how to make this with Azure IoT Hub.

We have a simulated setup of a small office, in the form of a web page containing the office floor plan along with light socket points.

Azure IoT Hub Facilities Management

And a web-based chat UI for the facilities management staff users.

IoT ChatBot for Facilities Management

The source code for this demo simulation is available in this GitHub repository.

There are three components of this demo source code.

  1. azure-buildingThis is the simulated small office with several light bulbs. It has a web-based, SVG interface that shows the office floor plan with light points and allows mouse events to perform operations on the light bulbs. It is served by a Node.js backend, acting as the device chatbot that interacts with the Azure IoT Hub.
  2. azure-chatThis is the chat UI application where all the facilities management staff and the devices bunch up for the day to day work coordination. A separate Node.js backend serves this chat UI. The UI orchestrates the chat messages via PubNub service. Chat messages can be initiated from the logged in staff users or can be sent from the device chatbot via the Azure IoT Hub.
  3. createDevice : Device creation script that registers the light bulbs on Azure IoT Hub.

Let’s launch these three components to make a working demo. We will start with the Azure IoT Hub.

Registering devices in Azure IoT Hub

Before launching this demo application, we have to create the devices and get their device keys. These keys are used to send messages to the Azure IoT hub. In this case, the devices are the light bulb sockets in the office.   Refer this README file for the step by step instructions on creating the Azure IoT HUB service and registering the devices for this application.

Launch Building Simulation with Devices

Refer to this README file to launch the Node.js server for building simulation.

Once launched, you can interact with the light bulbs displayed in the office floor plan as follows.

  • Mouse click: To toggle the lights on and off
  • Mouse double click: To toggle the bulb from defect/malfunction state to operating state and vice versa.

The light bulbs have three states which are indicated by distinct colors:

  • on : yellow
  • off : black
  • defect : red

(Note: To keep things simple, the building currently supports interaction with two light bulbs only. These two light bulbs are the ones that you can see in the animated interaction demo above.)

Launch the Chat UI for Facilities Management Staff

Refer this README file to launch a separate instance of Node.js server for the Chat UI. With this, all the three components of the application are not up and running.

You can sign in to the chat with your nickname and can see the pre-listed devices as shown in the animated demo above. Now you can play around with the chat UI and also interact with the building and perform operations on the light bulbs. Give it a try and see the messages popping up in the chat window.

Congratulations!! You are now part of a harmonious human to machine conversation.

IoT Chatbot Architecture

This application relies on Azure IoT Hub and PubNub data stream service. Azure IoT orchestrates the device-to-cloud and cloud-to-app messaging.

PubNub provides a real-time data stream channel over which two Internet endpoints can communicate directly.  For this application, PubNub plays the role of intermediate orchestrator, for exchanging chat messages between different users’ chat UI instances. Also on the building simulation side, PubNub is used to notify the Node.js (IoT Chatbot) about the device status.

IoT Chatbot App Architecture

All messages between the components are exchanged in JSON format. Refer to the message format file to know the exact format of messages that are sent during

  • Device status update ( From device to chatbot)
  • Device message ( From Azure IoT hub to chat UI)
  • User message (From one user’s chat UI to all other chat UI instances)

Start Imagining Your Own IoT Chatbot

If this use case excites you, then we would like to hear from you on how to improve it.

Maybe you can think of an improved chat interface that can filter devices based on their states, or group them based on some categorization. When it comes to maintaining thousands of devices, we need such efficient arrangements to provide a good user experience to the facility maintenance staff.

You could also extend this use case for scenarios like perimeter security & warehouse management, etc.. Feel free to comment below to discuss any similar application areas. We will be back soon with yet another cool use case of Internet of Things.

Follow

About the Author

Aravind is a technology enthusiast. He is an expert in conceptualizing and developing niche apps around IoT and cloud computing and is aspiring to be a full stack developer.