I have updated this project to version 2. Version 2 eliminates the need for the Universal Windows App, enabling the project to work on other versions of Windows. Simple install instructions for version 2 can be found here.
IntroductionHave you ever played a game, perhaps a virtual reality game, and wondered, "What if I could use my voice as my controller?"
That question inspired my idea to implement Alexa into my space ship in Elite Dangerous, an exploration, trading, and combat game, in which you can explore the Milky Way Galaxy on a galactic scale.
When I first researched this question, I found that Elite Dangerous did have a way to control your spaceship with your voice. It was a third party product that was essentially voice recognition software that would respond to you by selecting a random sound file and simulated a key press to operate a specific function on your ship. I personally found this very limiting, because this did not actually allow you to talk to your ship. I wanted the functionality to ask where I was in space and actually get a response back, and, after more research, I found that there was not a way to do this yet.
Being a 16 year old gamer with experience with Alexa, I knew that I would love some sort of interactive voice implementation.
So I created one...
My project has 3 parts. As we go through each part, I will describe the part's processes and will give you a walk-through on how to construct each part. Please note that I have two creation methods, Simple and Advanced.
Simple is for those who what to run the skill without going in depth into the code. Advanced is for those who want to add on to the project and make it their own.
Let's begin!
Part 1: Alexa SkillMy Alexa skill was written in Node.js and is hosted on Amazon's Lambda web service. To open the skill, simply say "Alexa, open ship assistant." Alexa will send you a card on your Alexa app containing your session id. This id will need to be entered into the application on your computer later on. By asking the skill for help or referencing the Voice User Interface Diagram provided below, you should be able to navigate the skill with ease. When you give a command to Alexa, the request is sent through a PubNub virtual device and this is where the communication between the skill and their computer takes place.
The two APIs at work in my skill are as follows:
- Custom Ship Command and Information API
- Elite Dangerous Star Map (EDSM)
The Custom Ship Command and Information API is an add on to the event logging API that was introduced in the Horizons 2.2: Engineers update for Elite Dangerous. It was created by the game developers to enable 3rd party developers to make projects that extend the game. I extended the API to pack the user's in-game information from the Elite Dangerous user event log and send it to my skill for Alexa to read. It is also used to receive all incoming commands from my skill for specific ship functions.
The Elite Dangerous Star Map is a public API that is maintained by fans of Elite Dangerous. It features detailed information on every known star system in the game. For instance, if I query for Sol (our Sun), I will get population, government, economy status, and more information that is useful for users.
How to set up:
Simple:
- Enable my published skill for use with your Alexa enabled device.
- You may now see if the skill is enabled by saying, "open ship assistant".
- After the skill is enabled, you can move on to the Computer Application set up. Remember to follow the Simple creation method.
Advanced:
- Go to PubNub.com and create a profile.
- Add a new device.
- Click on your newly added device.
- Make note of both the Publish Key and Subscribe Key.
- Create a AWS account.
- Navigate to the Lambda service.
- Create a new Lambda function.
- Skip the next screen
- Select the gray box and pick "Alexa Skills Kit"
- Download my Git repository here. Extract it, navigate to the "Alexa Skill" folder, then to the "Skill" folder.
- Edit the "index.js" file and find the line that defines "iotCloud". Copy your publish key and subscribe key into their respective definitions.
Note: If you do not want to have a randomly generated session ID, you can create a custom one by commenting out the line where "myChannel" is defined. You can then use the line above it as a template on how to define "myChannel" to a custom name. Remember this name, because you will need it when setting up the application on your computer.
- Select all of the contents of the "Skill" folder and send them to a compressed zip folder.
Give it a name and description. Choose the Upload Zip option as the code entry type.
- Navigate to your zip file and upload it to Lambda.
- Choose an existing role for the handler and select "lambda_basic_execution".
Hit next.
Create function.
- Now, copy the ARN in the top right hand of the webpage. You will need this for the skill creation.
- Now go to Amazon's Developer dashboard. Go to Alexa -> Alexa Skills Kit and create a new skill.
- Give your skill a name and an invocation name.
Navigate to the "Interaction Model" folder. Locate "utterances.txt", "intents.json", "LIST_OF_RANKS.txt", and "LIST_OF_SYSTEMS.txt".
Add the custom slot types first (red), then get the intent schema and utterances and copy their contents into their respective text areas (yellow).
Hit save and next. Enter you Lambda function's ARN and select Lambda function.
Click next. Test the skill. You can either test from your device, or you can type in a command.
Nice job! You created the skill! Now you can go to your Alexa-enabled device and open the the skill using its invocation name. If you want the published version, it's located here. After the skill has been tested, you may move on to the Computer Application set up. Remember to follow the advanced creation method.
Part 2: Computer ApplicationIn order for Alexa to be able to send commands and receive information, I needed to create a way to bridge the game to my skill. My method of bridging depended on the creation of two programs that needed to be run on the user's Windows 10 computer. The next two sections describe each program and will guide you on how to get them working on your computer.
Note: I have updated this project to version 2. Version 2 eliminates the need for the Universal Windows App, enabling the project to work on other versions of Windows. Simple install instructions for version 2 can be found here. If you do not wish to use version 2, this method will still work, but only for the Advanced set up method.
Note: You must have a computer running Windows 10 to continue and, if you intend on following the advanced creation method, you must also have Visual Studio 2015. You can download it here.
Part 2.1: Alexa Communication ProgramThe first program that I made was a Windows Universal Application that serves two functions: to send ship information to Alexa and to receive incoming commands from Alexa. In order to send the ship information, the program publishes a JSON message, built from my second program, to the user's PubNub information channel. To receive information, the program calls into the user's PubNub command channel history, pull the most recent command from Alexa, and build a JSON file for my second program to read. Both of these functions act simultaneously, so my skill can run with minimal delay.
How to set up:
Simple:
- Download my Git repository here. Extract it, navigate to the "ComputerApp" folder, then to the "Simple Install" folder, and finally to the "Universal Windows App" folder.
- Double-click the "APPXBUNDLE" file.
App Installer should open and ask you if you want to install "PubnubWindowsStore". Click install.
When App Installer finishes installing the application, you will be able to start it by going searching for "Elite Dangerous Alexa Send".
When it starts, it will prompt you to enter your session id. This is the id Alexa will send to your Alexa App. Enter it and press the continue button.
After you get the program running, you can move on to the next part of the Computer Application set up. Remember to follow the Simple creation method.
Advanced:
- Download my Git repository here. Extract it, navigate to the "ComputerApp" folder, then to the "Advanced Install" folder.
- Double-click "ComputerApp.sln". Visual Studio should open.
- Both applications are in this solution. We are focusing on "PubnubWindowsStore". Right-click the project and make it the startup project.
All of the functionality of this application are in the following files:
- PubnubDemoStart.xaml.cs
- PubnubOperation.xaml.cs
They can be found under their respective XAML files. Each file is commented, but if you have any specific questions, you can leave a comment below.
Double-click "PubnubDemoStart.xaml.cs"
If you are hosting your own version of the skill, enter your info in this file.
Now you can click the debug button and run the program.
Nice job! You created the first application! You may move on to the next part of the Computer Application set up. Remember to follow the advanced creation method.
Part 2.2: Elite Dangerous Communication ProgramThe second program that I made was a Windows C# Console Application that also serves two functions: to build the ship information JSON message and to send key presses to the game from the commands JSON message recieved from Alexa. As I stated before, Elite Dangerous logs all user events into a log file in JSON format. My program takes these logs, reads all of the events, builds a ship information JSON message, and makes them available for my Windows Universal Application to send to Alexa. This program also reads the commands message from my Windows Universal Application and associates the commands to specific sequences of virtual key presses that are sent to the game to carry out function in-game.
Note: The Universal Windows App needs to be closed before moving on.
How to set up:
Simple:
- Navigate to the "ComputerApp" folder that you extracted earlier, then to the "Simple Install" folder, and finally to the "Console App" folder.
- Double-click the "setup" application.
When the confirmation message appears, click "Install".
After the installation completes, you should see a black box, and, if you have Elite Dangerous Engineers update, there also may be some text as well.
Well done! You have finished setting up the entire project. You can now open the Universal Windows Application and input your session ID when prompted. You can also start your game and enjoy using Alexa with Elite Dangerous. If you need to configure your keybindings, you should continue to part 3.
Note: When you want to start these programs, you must start the Console Application BEFORE you start the Universal Windows Application.
Advanced:
- Navigate to the "ComputerApp" folder that you extracted earlier, then to the "Advanced Install" folder.
- Double-click "ComputerApp.sln". Visual Studio should open.
- Both applications are in this solution. We are focusing on "eliteDtoAlexa". Right-click the project and make it the startup project.
All of the functionality of this application is in "Program.cs". This file is commented, but if you have any specific questions, you can leave a comment below.
Double-click "Program.cs".
Now you can click the start button and run the program.
Well done! You have finished setting up the entire project. You can now open the Universal Windows Application and input your session ID when prompted. You can also start your game and enjoy using Alexa with Elite Dangerous. If you need to configure your keybindings, you should continue to part 3.
Note: When you want to start these programs, you must start the Console Application BEFORE you start the Universal Windows Application.
Part 3: Configuring Elite DangerousThe last step that you need to do is set Elite Dangerous's keybindings. I used the same keybindings as the HCS VoicePacks, so if you have used any of their packs before, you can use your previous keybindings, or you can refer to the following video to set your keybindings.
If you want to use your own keybindings, then you can edit the "Program.cs" file in the Console Application (Part 2.2 Advanced Method).
Additional InformationMy project is not endorsed by Frontier Developments PLC, Elite Dangerous, or HCS VoicePacks LTD.
You can get the code from my GitHub.
Comments