• Home
  • blog
  • How to Build Your Own AI Assistant Using

How to Build Your Own AI Assistant Using

The world of artificially intelligent assistants is growing — Siri, Cortana, Alexa, Ok Google, Facebook M — all the big players in technology have their own. However, many developers do not realise that it is quite easy to build your own AI assistant too! You can customise it to your own needs, your own IoT connected devices, your own custom APIs — the sky is the limit.

Late last year, I put together a guide on five simple ways to build artificial intelligence in 2016 where I covered a few of the simple options out there for building an AI assistant. In this article, I’d like to look at one particular service that makes it incredibly simple to get quite a fully featured AI assistant with very little initial set up —

What is is a service that allows developers to build speech-to-text, natural language processing, artificially intelligent systems that you can train up with your own custom functionality. They have a range of existing knowledge bases that systems built with can automatically understand called “Domains” — this is what we will be focusing on in this article. Domains provide a whole knowledge base of encyclopaedic knowledge, language translation, weather and more. In future articles, we will cover some of the more advanced aspects of that allow us to personalise our assistant further.

Getting Started With

To get started, we will head to the website and click either the “Get Started for Free” button or the “Sign Up Free” button in the top right hand corner.

We are then taken to a registration form which is pretty straightforward — enter your name, email and password and click “Sign up”. For those avoiding yet another set of login credentials, you can also sign up using your GitHub or Google account using the buttons to the right:

Signing up to

Once we have signed up, we will be taken straight to the interface where we can create our virtual AI assistant. Each assistant we create and teach specific skills to is called an “agent” in So, to begin, we create our first agent by clicking the “Create Agent” button on the top left hand side:

Creating new agent in

On the next screen, we enter in our agent’s details, including:

  • Name: This is just for your own reference to differentiate agents in the interface. You could call the agent anything you would like, either a person’s name (I chose Barry) or a name that represents the tasks they are helping out with (e.g. light-controller).
  • Description: A human readable description so you can remember what the agent’s responsible for. This is optional and might not be needed if your agent’s name is self-explanatory.
  • Language: The language which the agent works in. This cannot be changed once you’ve chosen it — so choose wisely! For this tutorial, we will be choosing English as English has access to the most domains. You can see which domains are available for each language in the Languages table in the docs.
  • Compatibility with other services: You can also choose to make your agent compatible with Microsoft’s Cortana and/or with (the AI assistant app built by the creators of For now, we will leave those unchecked as you can check these later on in the agent’s settings.

When you have input your agent’s settings, choose “Save” next to the agent’s name to save everything:

Setting for your new agent in

The Test Console

Once your agent has been created, you should see a test console appear on the right. This is a sign that your agent is ready to go! To showcase the power of domains in, ask it to identify a celebrity and hit enter. For example, I asked it “Who is Steve Nash?” to see whether it would recognize one of my favorite NBA basketball stars. If it recognized your query, your results should appear below it:

The test console

If you scroll down on the right hand side of results, you will see more details for how interpreted your request. Below that, we have a button called “Show JSON”. Click that to see how the API will return this sort of response to us in our app:

Finding the Show JSON option will open up the JSON viewer and show you a JSON response that looks similar to this one:

[code language=”js”]
“id”: “389b5147-31c7-41d7-a7a7-5bbb8b324407”,
“timestamp”: “2016-01-11T01:13:00.881Z”,
“result”: {
“source”: “DuckDuckGo”,
“resolvedQuery”: “Who is Steve Nash?”,
“action”: “wisdom.person”,
“parameters”: {
“q”: “Steve Nash”,
“request_type”: “whatis”
“metadata”: {},
“fulfillment”: {
“speech”: “Stephen John Nash, OC, OBC, is a Canadian retired professional basketball player who played in the National Basketball Association. The point guard was an eight-time NBA All-Star and a seven-time All-NBA selection. Twice Nash was named the NBA Most Valuable Player while playing for the Phoenix Suns. He currently serves as the general manager of the Canadian national team and as a player development consultant for the Golden State Warriors.”
“status”: {
“code”: 200,
“errorType”: “success”

Reading through that response, we can see that got this information from DuckDuckGo, understood that I was asking for information on a person named “Steve Nash” and provided the response within result.fulfillment.speech. We have a status code section in the JSON object too which will alert us to any errors that occur during our requests.

Our agent is now be ready for us to integrate them into our own web app interface. To do so, we will need to get our API keys to give us remote access to our agent.

Finding your API keys

The API keys we will need are further down on this agent page. Scroll down and you will find the “API keys” section. Copy and paste the “Subscription key” and “Client access token” somewhere safe. Those are what we will need to make queries to the SDK:

Finding your API keys

The Code

If you would like to take a look at the working code and play around with it, it is available on GitHub. Feel free to use it and expand on the idea for your own AI personal assistant.

If you would like to try it out, I have Barry running right here. Enjoy!

Connecting to Using JavaScript

We have a working personal assistant that is running in’s cloud somewhere. We now need a way to speak to our personal assistant from our own interface. has a range of platform SDKs that work with Android, iOS, web apps, Unity, Cordova, C++ and more. For this example, we will be using HTML and JavaScript to make a simple personal assistant web app. My demo builds off the concepts show in their HTML + JS gist.

Our app will do the following:

  • Accept a written command in an input field, submitting that command when we hit the Enter key.
  • OR — Using the HTML5 Speech Recognition API (this only works on Google Chrome 25 and above), if the user clicks “Speak”, they can speak their commands and have them written into the input field automatically.
  • Once the command has been received, we will be using jQuery to submit an AJAX POST request to will return its knowledge as a JSON object as we saw above in the test console.
  • We will read in that JSON file using JavaScript and display the results on our web app.
  • If available, our web app will also use the Web Speech API (available in Google Chrome 33 and above) to respond back to us verbally.

The whole web app is available on Github at the link above, feel free to refer to that to see how we have styled things and structured the HTML. We won’t be explaining every piece of how it is put together in this article, we will focus on the SDK side of things. I will also point out and explain briefly which bits are using the HTML5 Speech Recognition API and Web Speech API.

Our JavaScript contains the following variables:

[code language=”js”]
var accessToken = “YOURACCESSTOKEN”,
subscriptionKey = “YOURSUBSCRIPTIONKEY”,
baseUrl = “”,
messageRecording = “Recording…”,
messageCouldntHear = “I couldn’t hear you, could you say that again?”,
messageInternalError = “Oh no, there has been an internal server error”,
messageSorry = “I’m sorry, I don’t have the answer to that yet.”;

Here is what each of these is for:

  • accessToken and subscriptionKey – These are the two API keys which you copied over from the interface. These give us permission to access the SDK and also say which agent it is that we are accessing. I want to access Barry, my personal agent.
  • baseUrl – This is the base URL for all calls to the SDK. If a new version of the SDK comes out, we can update it here.
  • $speechInput – This stores our <input> element so we can access it in our JavaScript.
  • $recBtn – This stores our <button> element that we will be using for when the user wants to click and speak to the web app instead.
  • recognition – We store our webkitSpeechRecognition() functionality in this variable. This is for the HTML5 Speech Recognition API.
  • messageRecording, messageCouldntHear, messageInternalError and messageSorry – These are messages to show when the app is recording the user’s voice, could not hear their voice, when we have an internal error and if our agent does not understand. We store these as variables so that we can change them easily at the top of our script and also so that we can specify which ones we do not want the app to speak out loud later on.

In these lines of code, we look for when the user presses the Enter key in the input field. If so, we run the send() function to send off the data to

[code language=”js”]
$speechInput.keypress(function(event) {
if (event.which == 13) {

Next, we watch for if the user clicks the recording button to ask the app to listen to them (or if it is listening, to pause listening). If they click it, we run the switchRecognition() function to switch from recording to not recording and vice versa:

[code language=”js”]
$recBtn.on(“click”, function(event) {

Finally, for our initial jQuery setup, we set up a button which will be on the bottom right of our screen to show and hide the JSON response. This is just to keep things clean, most of the time we won’t want to see the JSON data that comes through, but every now and then if something unexpected happens, we can click this button to toggle whether the JSON is viewable or not.

[code language=”js”]
$(“.debug__btn”).on(“click”, function() {
return false;

Continue reading %How to Build Your Own AI Assistant Using