Tutorial: Run a Python Script with an Alexa Voice Command
Tags: python, tutorial, alexa, beginners
Published: 2020-04-16 13:03:34

*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:

![Successfully linked](https://cdn.wayscript.com/blog_img/36/successful_alexa_link.png)

##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".

![Name your program](https://cdn.wayscript.com/blog_img/36/run_python_with_alexa.png)

Once your program is created, you'll start by adding an [Alexa Trigger](https://docs.wayscript.com/library/triggers/alexa-trigger).

Click the "+" icon next to "Add Trigger(s)" and select the Alexa Trigger.

![Add Alexa](https://cdn.wayscript.com/blog_img/36/add_alexa.png)

You should now have the Alexa Trigger in the "Triggers" section of your program.

![Triggers](https://cdn.wayscript.com/blog_img/36/alexa_trigger_2.png)

##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:

![Setting panel](https://cdn.wayscript.com/blog_img/36/alexa_settings.png)

Set "Activate Trigger" to "On".

Now, notice that the trigger shows the text "Alexa, launch WayScript and run my 'Run Python with Alexa' program".

![Run Python](https://cdn.wayscript.com/blog_img/36/long_phrase_2.png)

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".

![Program Alias](https://cdn.wayscript.com/blog_img/36/completed_settings.png)

Now you have a much nicer phrase!

![Better phrase](https://cdn.wayscript.com/blog_img/36/python_phrase_2.png)

##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.

![Module](https://cdn.wayscript.com/blog_img/36/with_python_module_2.png)

Then, click on the Python module and paste your script into the code box.

![Code box](https://cdn.wayscript.com/blog_img/36/python_code.png)

##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."

![All done](https://cdn.wayscript.com/blog_img/36/alexa_run_command.png)

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.