This project demonstrates how to configure the Amazon Echo to send voice commands to a LabVIEW application running on a Raspberry Pi 3.
The Amazon Echo routes all communication through Amazon's cloud services and therefore cannot communicate with the Raspberry Pi 3 directly. Using the Alexa Skills kit we can create an Alexa skill that will forward requests to our Raspberry Pi and route responses back to the Amazon Echo.
Setup The LabVIEW Project- Setup the Raspberry Pi and LabVIEW as described in the LINX 3.0 tutorial series.
- Download and extract the Amazon Echo LabVIEW Project.
- Open the LabVIEW project.
- Update the Raspberry Pi IP address (Right Click>>Properties) and then right click the Raspberry Pi and connect.
- Expand the Raspberry Pi target.
- Right click the alexa web service and choose start.
- Open main.vi and click run.
Note: The alexa/Web Resources/post.vi handles all incoming Alexa requests and can be updated later for custom applications.
Setup The Raspberry PiThe Alexa skill we create in the next section will send an HTTP POST to our Raspberry Pi using HTTPS. We need to route this HTTPS request to our HTTP LabVIEW Web Service. This is accomplished with a Node.js script.
- Make sure Node.js is installed on the Raspberry Pi.
- Download and extract httpsHelper.zip on the RPI.
- Enter the directory where you extracted httpsHelper.zip and run.
npm install
- Start the httpsHelper with the following command:
node httpsHelper.js
The httpsHelper must remain running for Echo quests to be routed to LabVIEW.
Note: the httpsHelper is hard coded to listen on port 8123 and route to a LabVIEW Web Service running on port 8001.
Setup The Alexa SkillCreate an Alexa skill to send voice commands to LabVIEW.
- Create an Amazon Developer account.
- Browser to the Get Started With Alexa page.
- Under Alexa Skills Kit click Get Started.
- Click Add New Skill
- Select your Language
- Select Custom Interaction Model
- Enter a name for the skill
- Under Invocation Name enter 'lab view'
- Paste the following into the Intent Schema
{
"intents": [
{
"intent": "HaveLabVIEW",
"slots": [
{
"name": "Request",
"type": "SHORT_PHRASE"
}
]
}
]
}
- Paste the following into the Sample Utterances
HaveLabVIEW ask lab view {Request}
HaveLabVIEW tell lab view {Request}
HaveLabVIEW make lab view {Request}
HaveLabVIEW ask lab view to {Request}
HaveLabVIEW tell lab view to {Request}
HaveLabVIEW make lab view to {Request}
- Click Add Slot Type
- Under Enter Type enter 'SHORT_PHASE'
- Under Enter Values enter the following:
one
one two
one two three
one two three four
one two three four five
one two three four five six
one two three four five six seven
one two three four five six seven eight
one two three four five six seven eight nine
one two three four five six seven eight nine ten
one two three four five six seven eight nine ten eleven
one two three four five six seven eight nine ten eleven twelve
one two three four five six seven eight nine ten eleven twelve thirteen
one two three four five six seven eight nine ten eleven twelve thirteen
one two three four five six seven eight nine ten eleven twelve thirteen fourteen
- This enables you to say any phrase up to 14 words to pass to LabVIEW.
- Click Save.
- Click Next.
- Under Service Endpoint Type select HTTPS.
- Under HTTPS URL select the closest region.
- Enter the your domain name beginning with https://
A domain name is required for the Alexa Skill Kit. You can register a free .tk domain from dot.tk. Make sure the domain points to your public IP address (see your public IP at ipchicken.com).
The Alexa service sends an HTTP POST request on port 443. This is currently not configurable and most routers require port forwarding port 443 to the device running LabVIEW. Ensure port forwarding is setup correctly using canyouseeme.org.
- Click Next.
- Choose to upload a self-signed SSL certificate and follow the instructions to create a self signed certificate on the Raspberry Pi.
Note: The httpsHelper script is hard coded to look for certificate.pem and private-key.pem in the same directory as httpsHelper.js
- Click Next.
- Use the Service Simulator to test the skill by typing "Have LabVIEW Turn the LED On". Confirm that the LED control lights up and that a valid response is received in the Service Response window.
- The Alexa skill is ready to use in developer mode. Try using the Amazon echo to send voice commands to LabVIEW.
At this point you should be able to send voice commands to a LabVIEW application running on the Raspberry Pi. You can process commands by parsing request strings in LabVIEW or by creating new utterances in the Alexa Skill.
Comments