Tutorial: Automate Text Messages when Database Conditional Changes
Tags: tutorial, sql, automation
Published: 2020-05-01 12:33:23

---
title: "Tutorial: Automate Text Messages when Database Conditional Changes"
canonical_url: https://wayscript.com/learn/automate-text-messages-when-database-conditional-changes
---
{% youtube fqFKpPXi0qc %}

*Thanks so much for the feedback on our [rapid development platform](https://www.wayscript.com)! Here's a tutorial to introduce automation and workflows.*

##Introduction
Setting up automatic notifications can help you make better decisions, quicker. It can often be hard to create these automations if the decisions that need to be made are complex. For example, if we need to process datasets or filter selections before making decisions, these automations usually are more difficult to make. With WayScript, we can create these automations in minutes, while still having full control of our script.

##Prerequisites
No prerequisites but some content you might find helpful:
[Working with our SQL Module](https://docs.wayscript.com/library/modules/sql)
[Working with our Time Triggers](https://docs.wayscript.com/library/triggers/time-trigger)
[Working with our Text Messages](https://docs.wayscript.com/library/modules/text-message)

##Automating an Action at Intervals
The automation part of this tutorial will occur with the time trigger. This will be the interval at which we want to check our database for the conditionals. On WayScript, we're able to easily automate complex interactions on a schedule. Whether you need to run a script by the day, hour, or minute, you can easily do this in our editor. To start programming on WayScript, sign up on the home page, or login to your account. We can create scripts, by clicking on the "+ New Script" at the top of the webpage. These scripts are what will house our automations.
We're able to automate anything on a schedule using time triggers. We can pull a time trigger into our workflow and configure the settings:

![Settings 1](https://cdn.wayscript.com/blog_img/76/1.png)

![Settings 2](https://cdn.wayscript.com/blog_img/76/2.png)

In this example, we'll use this time trigger to do periodic checks on our database, looking for the conditional change to send a text message alert for.

##Querying our Database
To Query items in our database, we first need to drag in a SQL module into our workflow.

![SQL module](https://cdn.wayscript.com/blog_img/76/3.png)

Once we connect our database, this will give us access to a full editor that we can write SQL code into. If you get stuck while trying to set up your database, feel free to reference this Youtube tutorial. Let's write something like:
<pre>
SELECT SUM(quantity)
FROM order_summary
WHERE product='A';
</pre>

Once with have this information, we can compare it using conditionals in our workflow:

![Workflow](https://cdn.wayscript.com/blog_img/76/4.png)

The above image depicts an if statement which compares the value we pull from the database directly, to the value in the last run. We can store these values between runes using the variable storage module on WayScript. If the values are different, then a notification of your choice can be sent using the true branch of the if statement. In this example, we're using the built in text message module.

##Questions, Concerns?
If there's any questions feel free to message us on discord. We're happy to help! If you want to see this full script template, you can find it [here](https://wayscript.com/user/derricks/qTc-gQR5). There's also a [video](https://youtu.be/fqFKpPXi0qc) of this tutorial on our [YouTube channel](https://www.youtube.com/channel/UCv1JpM-XII0PMnqoCJfZA2g). 

Meet Derrick from WayScript, the star of these videos and creator of these amazing tutorials: {% user derricksherrill %}