No better time than quarantine time to play around with Python and Alexa. This tutorial demonstrates how to use WayScript. We say that WayScript gives developers superpowers. We'd love your feedback on the platform we're building. Check it out while learning something new today.
The WayScript Alexa Skill
In this tutorial, you will learn how to use WayScript to run your Python script in the cloud using an Alexa voice command.
This is done using the WayScript Alexa Skill, which you will first need to enable on your Amazon Alexa account.
After enabling the skill, you will then need to link it to your WayScript account using the Alexa app. Once successfully linked, you should see a message like this:
The Alexa Trigger
The next step is to build a WayScript program with an Alexa Trigger. To do so, first go to your WayScript dashboard and select "Build From Scratch".
Give your program a name, like "Run Python with Alexa".
Once your program is created, you'll start by adding an Alexa Trigger.
Click the "+" icon next to "Add Trigger(s)" and select the Alexa Trigger.
You should now have the Alexa Trigger in the "Triggers" section of your program.
Set up the Alexa Trigger
Now that you have added the trigger to your program, let's get it set up! Start by clicking on the trigger to open it in the settings panel.
You should see something like this:
Set "Activate Trigger" to "On".
Now, notice that the trigger shows the text "Alexa, launch WayScript and run my 'Run Python with Alexa' program".
That's kind of a mouthful, so you'll set the "Program Alias" field to create a phrase that's easier to say and easier for Alexa to understand.
In this case, you'll simply set the Program Alias field to "Python".
Now you have a much nicer phrase!
Add a Python Script
With the Alexa Trigger in place, it's time to add a Python Script. Start by dragging the Python module into your program.
Then, click on the Python module and paste your script into the code box.
That's it! You're done!
Run your Python script from any of your Alexa-enabled devices by saying "Alexa, launch WayScript and run my 'Python' program."
Of course, you don't have to stop at Python. You can run any WayScript program - including an evergrowing list of modules - using the Alexa Trigger.
Top comments (1)
if script returns a string or int. Is it possible to make Alexa to says it. Maybe with a sentense like "The wind speed is km/h".