Previously, we successfully integrated JIRA and Docker for Monitoring and spawning new instances on demand using Alexa.
This time we wanted to extend the function of Alexa into a more general setting, like playing the role of an office building receptionist. So we decided to integrate Alexa with Confluence. Most companies already utilize the Knowledge Base feature of Confluence. Now, all that needs to be done is to interpret the user's most utilized requests and respond with the right responses.
Like most of Alexa's skills, there is an Invocation name that becomes the trigger or wake up word for Alexa to start the skill. Ours is called as Knowledge Base. Any information provide after the wake word becomes the input for the backend function to execute and return the appropriate response. Most of Alexa's Skills are single line conversations, there is a request from User and Alexa responds the output. But Alexa Skill Kit provide an option which can extend into multi line conversations using the Session parameter to store the context of the previous search. So when using the Knowledge Base skill, if Alexa requires more information about the look up content it can ask the user with question that can improve the search in confluence
In order to capture the user request phrase we had to use the Alexa's Interaction Model. Based on the User phrase , ASK chooses a specific part of the lamda function to execute. For example using Alexa help would invoke the help module and using Alexa EndSearch would end the current search. So we needed to create a set of phrases (preSearch phrase) that Alexa understands when user starts searching. For example, Alexa would intepret phrases like How to, What is, where is ... that the user is trying to search for content. Alexa has some inbuilt literal that can understand number , date , predefined keywords etc ... but all phrases that a User searches for can not be sampled. So we used the Amazon Literal slot to capture all search pharse that follows the preSearch to form the search string
Once we interpreted the user's requests using the ASK (alexa skill kit), we used the Confluence search feature, to grab the top 5 matching results. If confluence search responds with an exact match, then Alexa responds to the user with the answer to their question. But, if Confluence returns multiple search results, Alexa presents the top 5 results to the user asking them to choose among them. Based on the user's choice, Confluence picks a page from Confluence and reads the content back to the user.
The content of the Confluence page only returns the HTML Content when queried using the REST API. In order for Alexa to read meaningful content to the user, we needed to present plain text with pause-able phrases. So we parsed the content to remove the HTML tags and added pause breaks using simple Regex. This worked surprisingly well, so we didn't need to use any library for parsing.
How It Is Used
In order to use the Alexa Skill, go to the Alexa skill store in your Alexa App and search for Knowledge Base, that is the name of our skill. After installing it, you can enter your Confluence "Instance Base URL" and the "Space" you would like Alexa to search through. It is better to provide the space in which all of the knowledge base articles are present. So that the user gets the most relevant response to their question.
In order to know the different functionalities that are available in the skill, simply say:
Alexa , Ask Knowledge Base.
Welcome to Knowledge base.
This skill is designed to search through the Confluence space and returns with the top results for users to choose from .
To start Search please say ask Knowledge base followed by the search phrase
If search on confluence returns single result , the contents of the page will be read to you
If mutiple results were returned from the search, top 5 results will be presented to the user and request user to choose an option number
You can select an option by saying the number
To end a search please say stop or cancel
Now, lets try a working example on how you can ask Alexa to search a Knowledge Base.
Lets say I would like to query knowledge base to know what is the guest wifi password. You would simply ask:
Alexa , Ask Knowledge Base , What is the guest wifi password ?
Here is the steps for Connecting to the Guest Network.
Have fun surfing
Alexa , Ask Knowledge Base , Does this hotel offer room service ?
Yes, this hotel offers room service from 7am to midnight.
The menu is located on the desk.
Understanding how confluence search works is very important. The results are more effective if search was based out of relevant keywords. For example, searching for "guest wifi password" would provide better results than searching for "what is the guest wifi password". The later would return results which have references to "what is the" whereas what you are looking for, which is the "guest wifi password."