Custom Cortana MQTT Commands


image Cortana can easily be extended to aid you with your DIY home automaton projects. In this example Cortana sends MQTT commands to open and close a garage door as well as ring the doorbell with custom jingles. By the way, you don’t have to use MQTT, you can also do a whole lot of other things as well from opening a file, opening a program, or launching your favorite websites.

As of the writing of this entry I am frantically trying to finish documenting the MQTT Doorbell and Garage Door Opener devices in separate posts. Hopefully I can get those whipped out in a few days.


The Cortana voice assistant comes with windows 10 on your tablet, mobile, or PC. You can develop on Cortana for free using Visual Studio 2015 Express. The project is UWP (Windows Universal Platform) so a single project can can run on all windows platforms  with no changes, just target the desired operating system in Visual Studio and deploy (debug). As you see in the video I am running the same app on my PCs and phone, the app is exactly the same on both.


In this app you can say “Cortana, please open the garage door” and a command will be sent to your MQTT server to open your garage door (MQTT garage door not included but I have videos coming on that).

Referenced MQTT library is M2MQTT, installed via git.


imageYou only need to debug the project once then you will find it in your windows 10 start menu, after that just say “Hey Cortana” to get Cortana to listen, “Please” this is the callable name of the program, you could change it to whatever you want, then “open the garage door” Cortana will launch the program and send the MQTT message then close.


The program can tell the difference between being launched by Cortana and being launched by the user, if launched buy the user a page opens where the user can execute the commands by pressing buttons.

To test download a MQTT test client like MQTT.fx, connect to, subscribe to topic Cortana/# to wach the MQTT traffic. If the program can’t connect to the MQTT Broker it will crash.


Get the code here!



Other Resources

Charles Clayton on YouTube with custom Cortana commands:

Bob Tabor. There is a great windows 10 video tutorial series on MSDN 80 videos long, this is great if you are a beginner to learn how to code with Visual Studio and make UWP apps. There is also a cool Cortana Example.

Paolo Patierno, the maker of M2Mqtt library. Here is the example that made me realize it actually was simple to use MQTT in Universal Windows apps. The code is supposed to run on a raspberry pi running windows 10 core but with a little coaxing you can figure out how to get it running on regular windows.

Leave a Comment