DEV Community

Derrick Sherrill for WayScript

Posted on

5 4

Automatically Send Text Messages when a Database Conditional is True

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:

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:

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.

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:

SELECT SUM(quantity) FROM order_summary WHERE product='A';

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

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

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup πŸš€

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay