Cortana the simple way

Sascha Wolter
Cognigy.AI
Published in
4 min readJan 9, 2019
Image source Microsoft.

There are a variety of virtual assistants like Amazon Alexa and Google Assistant that rely on different tools and technologies depending on the vendor. But they all agree on one thing: Each of these assistants sends user requests via JSON (JavaScript Object Notification) to an endpoint, i.e. a web address. The reply, which is also returned as JSON, is displayed or read out to the user. Microsoft takes the same approach, but the tools required are different and tend more towards Azure services.

Don’t worry, you can use any endpoint with little effort. Either directly by specifying the endpoint’s URL or indirectly with a small redirection — according to Microsoft’s instructions.

Bot-Settings inside Microsoft Bot Framework Emulator.

Microsoft’s Bot Service manages the resources of a bot, including its endpoint to which the data of a conversation is sent. You can find the details in a bot file. You can also see the endpoint in the Microsoft Bot Framework emulator (see figure).

Create a bot

Microsoft Azure Bot Service as starting point.

The Microsoft Azure Bot Service is a good starting point as it provides the core components for creating bots and allows connecting to channels such as Cortana. Perform the following steps for your first bot:

  1. Log in to the Azure Portal.
  2. Click the “Create a resource” link found on the upper left-hand corner of the Azure portal, then select “AI + Machine Learning” -> “Web App Bot”. A new blade will open with information about the Web App Bot.
  3. In the Web App Bot blade, provide the requested information about your bot including the Bot name and pricing tier. You can also select a template here: Our example uses the Node.JS based template “Echo Bot” for the SDK version 4.0.
  4. Click “Create” to build the service and deploy the bot to the cloud. This process may take several minutes.
  5. Select the bot resource created in the previous step, then select “Channels” and add Cortana as an additional channel.
  6. Finally, in the “Configure Cortana” view, specify the “Invocation Name” for use with Cortana.
Cortana in action on Windows 10.

Now the bot can be tested both as a webchat and as a Cortana skill. So far, however, it does nothing more than simply send the user input back.

Create a redirection

Online code editor.

To enable the bot to have a complex conversation, a Conversational AI technology like Cognigy.AI is very useful: It processes user inputs, connects to third-party systems (e.g. databases) and generates system responses in a single intuitive interface. To control the bot using another technology such as Cognigy.AI, all that is required is a simple message redirection. This redirection has the advantage that it converts the JSON documents to a suitable format. For example, if a generic endpoint is provided which due to its generic nature is not fully compatible with Cortana. To achieve this, you can follow the steps below:

  • Select the bot created in the previous step, then choose “Build” and change to the code editor via the “Open online code editor” link. Now, select the file “bot.js” to insert the program code for redirecting the messages.
  • Replace the onTurn-method with the following program code:

Update: Depending on how exactly the function is created, the request module may still have to be included. Alternatively, you can also use another method for the HTTP request.

  • Add the following method to the program code to redirect user activity to an custom endpoint:
REST based endpoint URL in Cognigy.AI.

For Cognigy.AI you only need to create a REST endpoint and enter its URL in the sendActivoty-Method (see above).

Visual design of a conversation inside Cognigy.AI.

Once you have connected your bot to your Cognigy endpoint, you can visually design your Cortana conversations and easily connected to third-party systems without any further Azure or C# knowledge.

--

--

Sascha Wolter
Cognigy.AI

Developer, Trainer, and Speaker with Passion for Innovation, User Experience, Conversational AI (Voice and Chatbots) and the Internet of Things in all flavors.