DEV Community

Derrick Sherrill for WayScript

Posted on

Send Slack Notification if User Uploads a File to a Web Form

Introduction

Today, we’ll use the WayScript platform to build a script to send Notification via Slack if Condition met in user-uploaded file.

Prerequisites

No prerequisites for this tutorial but here is the documentation worth reading.

Form Trigger

For the Trigger, we’ll use Form Trigger. The objective is to receive files, then run the script and the conditions following the Trigger.

Add it as a new Trigger.

Adding Trigger

Now we can configure the Trigger. First, let’s add useful information to the form.

Adding Descriptions

We can now create the form element. Choose File input as element type and .pdf for extensions.

Adding Form elements

Conditionals

The next step is to put some conditions on the file before sending the Slack notification. For this tutorial, we’ll ensure that we are receiving a pdf file.

Add If/Else as a new step.

Adding conditionals modules

Once it’s done, we’ll add an input: the comparison. We’ll compare the extension of the file to “pdf” string.

condition

Great. If you’ve noticed, adding an If/Else module creates two branches: one If the condition is valid (If branch) and one if the condition is invalid (Else). WayScript allows you to add many modules to the branches. It all depends on your needs. Well, in the If branch, add the Slack module.

Adding Slack module

If you’ve added the module, we can easily configure it now.

Configuration of Slack module

And now, let’s add a message.

Slack Message

Great! In the Else branch, I’ve added the Write to Log module, to print a message when the condition is not met.

Log message

if you’ve followed well this tutorial, here’s how your workflow should look like.

Workflow image

The Script is ready now. Be sure to have your Trigger turned on, so everyone can access the webpage.

Conclusion

Questions about this script or anything else? Join our Discord. We're always around to help. If you want to work with the full script template, just find it here

Top comments (0)