Report Events to Slack from Google Calendar Automatically
Tags: wayscript, slack, notifications, bots
Published: 2020-06-16 17:21:31

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

Connecting Slack with Google Calendar is one effective way to save time and stay organized in your business.  
With Wayscript, we can create effective integrations using the Wayscript platforms and its powerful tools. And in this article, we'll create a Google Calendar and Slack Integration that remind events ahead every day.

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

No prerequisites but some content you might find helpful :

*   [Working with Google Calendar](https://docs.wayscript.com/library/modules/google-calendar)
*   [Working with Slack](https://docs.wayscript.com/library/modules/slack)
*   [Working with Python](https://docs.wayscript.com/library/modules/python)

The workflow
------------

Our workflow should look like something like this:

*   Time trigger: Set the time we want the script to run
*   Events list are imported from Google Calendar
*   A loop through the events list to first format the date properly and send the message on the slack channel

Trigger
-------

We will use the time trigger and choose the hour the script will run. I set the time to 10:00 am but you can change it.

![Adding the time trigger](https://cdn.wayscript.com/blog_img/105/1.png)

Google Calendar
---------------

The next step is to retrieve the events. For this purpose, we will use the Google Calendar module and configure it.  
If you have a dedicated calendar for your business meetings or special events, you can easily change the input. And also as you want only the next event, I suppose you to set the number of events to 2.

![Adding Google Calendar](https://cdn.wayscript.com/blog_img/105/2.png)

For the output, let’s choose Events. It’s a list of dictionary object and it will be easy to manipulate with Python.

Date formating
--------------

Well, before working on the date, we must loop through the Event list. To make it, add a loop step. We'll loop trought Events variable.

![Adding loop](https://cdn.wayscript.com/blog_img/105/3.png)

Great, the next step. Why using Python? It’s simple and Wayscript provides every tool you need to create amazing scripts. Add a new step and select Python. For this example, the code is quite simple because we are only working on the start date. Each event item has a key for the starting date of the event.

![](blog_img/4.png)

Now, let’s get rid of the last numbers to make the date look good and register the value.

![Python code](https://cdn.wayscript.com/blog_img/105/5.png)

Slack
-----

The Slack module comes with a lot of configuration for various integrations. Adding the Slack module, we'll configure the mode, choose the channel, and choose what we would like to do.  
Now, let’s configure Slack and write the message we want to send.

![Slack Configuration](https://cdn.wayscript.com/blog_img/105/6.png)

Once it's done, we'll be writing data to the channel. Let's fill the message input with the text we want to send.

![Slack message and bot](https://cdn.wayscript.com/blog_img/105/7.png)

Conclusion
----------

Don't forget to switch on the Time Trigger so Wayscript will handle the running of the script for you.  
Questions about this script or anything else? Join our [discord](https://discord.gg/VWbXSbj). We're always around to help. If you want to work the full script template, just find it [here](https://wayscript.com/user/mangabo_kolawole/CZgtDNPo).