Send Notifications when Airtable Events occur to Slack and email
Published: 2020-08-04 14:14:07

Introduction
------------

Do you have a need to receive a notification anytime a new row is added or change in your Airtable? In this post, we will be exploring this use case harnessing WayScript to create notifications on both Slack and Email

Prerequisites
-------------

You will need to have an Airtable account and generate an API key. To learn more about how to do that to can refer to the following documentation

*   [Working with Airtable](https://docs.wayscript.com/library/modules/airtable)

You will also need to create a base with a proper table name like the example below

![](https://wayscript.com/blog_img/124/airtable_base.PNG)

You will also need an active Slack account which can be linked to WayScript, for more info check out this resource

*   [Working with Slack](https://docs.wayscript.com/library/modules/slack)

Finally, we will need to import the Time Trigger, Airtable, Slack, and Send Email packages which can be done easily through the WayScript libraries tab

![](https://wayscript.com/blog_img/124/libraries.PNG)

For this post we will also use the Time Trigger and Send Email packages as well as the Variable Storage and If modules which you can read more about through the following resources:

*   [Working with Time Trigger](https://docs.wayscript.com/library/triggers/time-trigger)
*   [Working with Send Email](https://docs.wayscript.com/library/modules/send-email)
*   [Working with Variable Storage](https://docs.wayscript.com/library/logic/variable-storage)
*   [Working with Conditionals](https://docs.wayscript.com/getting_started/conditionals)

Getting Started
---------------

Simply, click the ‘+ New Script’ button found in the top right corner to start creating your new workflow.  
  

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

  
  
Now, let’s add and enable a simple _Time Trigger_  
  

![](https://wayscript.com/blog_img/124/time_trigger.PNG)

  
  

Create Variable Storage
-----------------------

We will need to use the _Variable Storage_ to store persistent data to track our _Airtable_ changes  
  

![](https://wayscript.com/blog_img/124/variable_storage.PNG)

  
  

Get Airtable Records
--------------------

Next, we need to retrieve our Airtable rows to compare with our persistent data to check for new rows or changes  
  

![](https://wayscript.com/blog_img/124/airtable.PNG)

We also want to set our Airtable output as follows so we can compare with persistent data

![](https://wayscript.com/blog_img/124/airtable_outputs.PNG)

  
  

Check for Differences
---------------------

We can use a simple Python one-liner to check for differences and output a variable for our condition statement
<pre> variables[ 'diff' ] = list( set( variables[ 'Fields_JSON' ) - set( variabled[ 'data' ] ) )
</pre>

If Differences Exist
--------------------

Now that we have checked for differences we add an if statement to see if any found  
  

![](https://wayscript.com/blog_img/124/if_diff.PNG)

  
  

Send Slack Notification
-----------------------

Sending a slack notification takes little effort with WayScript  
  

![](https://wayscript.com/blog_img/124/slack.PNG)

  
  

Send Email
----------

Sending an email with WayScript is just as easy  
  

![](https://wayscript.com/blog_img/124/send_email.PNG)

  
  

Synchronize Airtable Changes
----------------------------

Finally, we will want to synchronize our Airtable changes and persistent data for the next run variables\[ 'data' \] = variables\[ 'Fields\_JSON' \]

Result
------

Finally, our result should be a notification in Slack  
  

![](https://wayscript.com/blog_img/124/slack_result.PNG)

As well as an Email

![](https://wayscript.com/blog_img/124/email_result.PNG)

  
  
As always, if you have any questions, comments, feedback, or suggestions, please let us know on WayScript or through our [discord](https://discord.gg/VWbXSbj). If you would like to view this WayScript simply follow the link [Airtable Notifications to Slack and Email](https://wayscript.com/user/wizgeeky/mSRgo5EK).