AlexNogard: IT HowTo

Linux & Opensource : Monitoring : Centreon, Nagios, Owncloud ..

By

Be SMS alerted new inbox mail with Google Calendar.

sms

To better manage messages you receive and be notified by SMS when an important email arrives, we’ll set up a Google script.

Therefore, the scenario is as follows:
– Receive email in your mailboxes.
– Filters are applied to email, if the filter is that you set for alert, we move to the next step.
– A script running on google drive looks every minute if a new mail that matches the filter is in the inbox.
– If YES, mail is listed in your calendar, and you will receive a SMS alert.
If NO, the script stops.

For implementation, several steps, namely:
– Changing our calendar
– Creating a filter for our emails,
– Creating a google script
– Test.

It is important to note that Google limits the sending of sms / day, but this limit is quite high.

I / Calendar Modification

For this step, go to your Calendar, click the cogwheel on the right, then click “Settings”:



Click on tab “Mobile Setup” :



If you haven’t activated your mobile yet to receive SMS, do it :

image07

Now that our number is added, click the “Calendar” tab on the main line of your calendar, click “Reminders & Notifications”

image12

Then select the “SMS” box, first line:

II / Filter creation on Gmail

Go to Gmail, click the cogwheel, then “Settings”:

image15

Then, click the “Filters” tab and “Create a filter”

image14

We fulfill our filter as we wish, for my part I put a filter on “Cristaline” word, so I receive sms only if an email matches this filter, go to the next step by clicking “Create a filter with this search “

image03

Then we select the following check boxes:- Apply label: “SMS” (creating a new language with this name).
– Never send it to SPAM folder
– Always mark it as important

Then click on “Create a filter”



/!\ (Especially do not apply this filter to old conversations, you may receive SMS for each with first script execution). /!\

III / Google Script Creation

Go to Google Drive and click on the “Create” button :


Then click on “Connect more apps“ :


Now, in the search box, type “script” and install the application “Google Apps Script” :

image05

Close the window, click again on “Create” and then click “Script”:


You are now on the Google script interface, choose “Empty Project”

image11

Then, remove pre-writtened lines (function myfunction ….), and replaced by:

function EnvoiSMS() {
var label = GmailApp.getUserLabelByName('SMS');
var threads = label.getThreads();
var now = new Date().getTime();
for(i in threads)
CalendarApp.createEvent('URGENT '+threads[i].getFirstMessageSubject(), new Date(now+60000), new Date(now+60000)).addSmsReminder(0);
label.removeFromThreads(threads);
}

Call our script by clicking “Untitled Project” :

We run our script by clicking on the following icon:

image01

The following window will appear, click authorize:

image21

Once authorized, a new window appears, click “I Agree”

Once done, click the little clock icon:

This is the trigger script, which we use to automate sending SMS.
Click “add a trigger”

Change the value “hour counter” with “Timer” and select “every minute” to the right and click “Save”:

image17

Leave your script.

Your function will look in your mailbox, labeled “SMS” if a new email has arrived, if so, it will send an alert via SMS by creating an event in the calendar.

I suggest you do a test to validate that everything is OK.

/! \ WARNING /! \
Choose well your filter not to be bombarded with SMS!

Leave a Reply

Your email address will not be published. Required fields are marked *