DEV Community

Derrick Sherrill for WayScript

Posted on

2 3

Execute Cloud Hosted Python Scripts with your Phone

Introduction

In this tutorial, let's take a look at how we can execute a python script whenever we send a text message to a specific number. Additionally, we'll look at how we can pass variables to a python script using this text message to create custom responses. Let's get started!

Text Message Trigger

The WayScript text message trigger allows us to execute a script whenever a text message is sent to a certain number, containing an execution command for the script you're trying to execute. For example, the text may look something like this:

Building this in WayScript, we pull a time trigger into our workflow and turn it on:

The first time you use this module, you will have to connect your phone number for verification. After that, we can configure the outputs to receive from the test message. These are the values following the execution command in your message.

Here we're creating a variable called message, which will get assigned the value provided in the text message.

Executing a Python Script

Since we want this text message to execute a python script, let's pull a python module as the next step in the workflow.

By placing this under an activated text message trigger, this python script will execute any time a message is received. However, to provide a customized response, let's do something with the input provided by the user's message.

We could write some python code like this:

 
message = variables['message'] 
string_message = str(message)
response_string = 'Hello ' + string_message
variables['response_string'] = response_string

While we're not doing much here, we're taking the input, processing it, and creating a new variable that we can pass to another module. We can "export" this new variable out of python and back to Wayscript using the variables dictionary. There's limitless possibilities at this step.

Passing Back a Response

Now that we've created the response in the python module. Let's pass it back as a text message to the user.

We can write the resposne that we want into the body of the message. But in this example, let's just use that variable we created by dragging it in.

This will return that python response directly back to the user.

Questions, Feedback?

If you have any questions or concerns, please feel free to reach out to us on our discord channel. If you want to view this completed script, you can find it here.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay