Carl Patenaude Poulin Carl Patenaude Poulin - 5 months ago 67
Javascript Question

How can I develop a Cortana app in JavaScript?

I would like to develop a Cortana application in HTML/JavaScript/CSS. Unfortunately, all the documentation pertaining to Cortana apps is written for C#/XAML.

Answer

To integrate with Cortana, you need to develop a Universal Windows Platform (UWP) app which exposes an "App Service" that integrates with Cortana.

In Visual Studio 2015 (or Visual Studio 15), create a new project using the JavaScript project template "Blank App (Universal Windows)". Find the element with tag Application, and add the following as a child element:

<Extensions>
  <!-- Provide a hook for Cortana to ask your app questions -->
  <uap:Extension Category="windows.appService" StartPage="voiceCommandService.js"> 
    <uap:AppService Name="AdventureWorksVoiceCommandService"/> 
  </uap:Extension>
  <!-- Enable deep linking into your app from Cortana -->
  <uap:Extension Category="windows.personalAssistantLaunch"/>
</Extensions> 

The file voiceCommandService.js will then serve as an entry point for Cortana. It will be executed whenever Cortana hands off a request to your app, and you'll be able to get the task details from Windows.UI.WebUI.WebUIBackgroundTaskInstance.current.

For the rest, just follow the C# documentation.

Answer based on this Cortana sample.

Comments