MuleSoft SmartHotDesk
Tags: mulesofthackathon, mulesoft, devoteam, techforpeople
Published: 2021-10-29 13:30:14

# Overview #
SmartHotDesk is an application that will help employees return to the office by booking them a desk via a voice command and then allocate them to the right desk, next to other team members.

## Inspiration ##
During the pandemic employees adapted very well to working from home and this type of working has proven itself as beneficial for both employers and employees. 

Now that we slowly move back to the office we see that the new norm is here to stay as an ever increasing number of companies choose to keep this flexible type of working and allow their employees to manage on their own when they want to work from the office. 

Employees going to the office from 1 to 3 days per week is quite common and this in turn has pushed SMEs to move to smaller offices, cutting the high cost of unused office space. 

This transition has also changed the way desks are allocated to employees, with hotdesking replacing the old model of individual owned desks.

## Idea ##
In this newly formed landscape, we wanted to build a quick and effective hotdesk booking system which will allow employees to book a desk with minimal effort and combine it with an intelligent algorithm that will allocate desks to them in such a way that everyone will be sitting next to his team members.

This will cut the hassle of finding and booking a desk while at the same time the smart allocation could increase productivity, as teams working on the same project will sit and work together.

## Solution using MuleSoft ##
We've used MuleSoft API-led connectivity to build a business flow that captures the intention of the employee to book a desk and an 
intelligent algorithm which runs once per day and allocates desks to employees based on the team they belong to.

The intentions are captured with the help of Alexa and processed by MuleSoft, enriched with additional info pulled from other backend systems. After the algorithm allocates the desks, the employees are notified via an email.

## Challenges we ran into ##
One of the main challenges was to convert the office blueprint in a format that would be usable by MuleSoft. 

We've chosen to model the office in a NoSQL database (MongoDB) mainly because we consider the static nature of the office entity not ideal for a classic entity-relationship database.

## Accomplishments that we're proud of ##
Within just one month from the inception of the idea, we were able to deliver an MVP of our application with 5 main features:

* Get, via a voice command, the members of one's team that have booked a desk for a particular day.
* Book, via a voice command, a desk for a particular day
* Check, via a voice command, the status of the booking and the allocated desk number if the algorithm has run for that day
* Cancel the booking, via a voice command
* Allocation Algorithm, assinging desk to employees next to their team members and notifying them via email 

Delivering the MVP so quickly was possible by levaraging MuleSoft API-led Connectivity and reusable Assets and APIs.

## What's next for SmartHotDesk ##
Our intention is to apply this solution to our own company and manage the hotdesking process through it. 

A few additions will be required to make it even more smart and easy to use:
* Web Portal channel for employees that don't own an Alexa device.
* Promote the Alexa Skill to Production and link it our organization's AD. 
* Supplementary features like "Book me a desk near a printer", "Book me a meeting room with a projector" etc
* SMS notifications

# Architecture #

## API-led View ##
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/luid1bg4ddd49gt95njz.png)

###System APIs###
**Employees**
RESTful System API which exposes Employees, Teams and Employements from the backend system. Resources are modeled to resemble closely Workday's entities even though we just use a Database for the hackathon. When the database will be replaced with Workday, the implementation of this API will be updated to use the Workday  Connector.

**Bookings**
RESTful System API which exposes Booking Requests, Desk Availability and Bookings. A MySQL database was used as the backend.

**Office Plan**
RESTful System API which exposes the office plan in JSON Format. The NoSQL database Mongo DB was used as the backend.

**Notifications**
RESTful System API which works as an Email and SMS gateway.

###Process APIs###
**Hotdesk Request**
Process API which receives a booking request, checks if the request is valid and provides a response based on the availability. Consumes the system APIs shown in the API-led view. 

**Desk Allocation**
Process API which is triggered by the Common Scheduler and executes the allocation algorithm. Consumes the system APIs shown in the API-led view.

###Experience APIs###
**Alexa Hotdesk Booking**
Experience API consumed by Alexa, routes the intents sent by Alexa
and transforms the request before sending it to Hotdesk Request Process API. The response received from the process API is again transform to Alexa format. 
 
###Utilities###
**Common Scheduler**
Common Scheduler can trigger jobs and maintain their state and history for 30 days.
(Accelerator Provided my MuleSoft: [MuleSoft Accelerators - Common Scheduler
](https://www.mulesoft.com/exchange/org.mule.examples/mulesoft-accelerator-for-salesforce-common-services/minor/2.0/pages/Common%20scheduler/) ) 

## Backend Systems ##
### HR System ###
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9t2d2hj3bn2r31slwjy.png)
 
### Bookings Database ###
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wiv8c9pqhrj41ixjp4v.png) 

### Office Plan ###
The office blueprint is stored in MongoDB as a JSON document (you can find it the source code). For better understanding you can see the following 3D floor plans

**Room 1**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oaf4gg22xwye50a22nop.jpg)

**Room 2**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wje0nnsb6dopr81enaiz.jpg)

**Room 3**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6m77qo18b4l6qxfwz34h.jpg)

To set up a MongoDB cloud instance: 
We've used MongoDB Atlas cloud service and created a new project "Smart Hotdesking" which was then deployed to AWS us-east-1 region. 

This project has only one database, hotdesking, and only one user hotdeskUser. For the purpose of the hackathon we are connecting with basic authentication (username-password). No additional security measures have been applied, like IP whitelisting etc.


## Alexa ##
Developer account for Alexa: https://developer.amazon.com/alexa/console/

1. Create a new custom skill with 4 Intents
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vo3nghz1m8vyviaj9pz0.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fo2rf4838eeehx2jbkbd.png)

2. Update the Code (source code is provided in our public repo).

3. Before you can test from the Test Console enable the Email Permission (this email is sent to MuleSoft to indentify the employee)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7x674o52bbo95iksyrt.png)  

No additional security measures have been applied for the scope of the hackathon.


## Use Cases ##

### Get Team Member's Bookings Use Case ###
Sequence Diagram:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zne0tzgxjn0q21im6m55.png)

Alexa Sample Dialog:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohawmgdovhfk4vsl2gib.png)

 
### Book a Desk Use Case ###
Sequence Diagram:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c0jn36zjxbta4kbusx4.png)

Alexa Sample Dialog:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxr0nayv7334um0a3gs5.png)
 
 
### Check Booking Status Use Case ###
Sequence Diagram:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69lytab30l0sf86xet7v.png)

Alexa Sample Dialog:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdi21wnwm3onh10mqp9q.png)
 
 
### Cancel Booking Use Case ###
Sequence Diagram:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4t1rlpda2lgf7dtxwdm.png)

Alexa Sample Dialog:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fsplaeyq4avoq9sny85.png)


### Allocation Algorithm Use Case ###
Sequence Diagram:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/elh31w4b8xxcqtn0fcjg.png)

Email Notification Sample:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rl3lszkex8govzjy28r5.png)
 


# Demo #
{% youtube pCqdYe-X-gE %}

 

# GitHub Repo #
{% github spiros-pappas/mule-hot-desk no-readme %}