1. Teleboard | Support Center
  2. Solution home
  3. Getting Started
  4. Business SMS Solutions
Open navigation

SMS Auto-Reply with Google Calendar

The script explained in this article will auto-reply with a text message to any emails based on events in your calendar. If an e-mail is received during an event in the calendar, the script will reply to it with a message of your choice. The script does not reply to any read messages.

You should make a separate calendar to store these events. Instructions for this begin on step 19. 


You can create events whenever you want to auto-reply even when there is no real event (such as closing hours). Instructions for this begin on step 39.


The script needs to be set up on both your end and Telebroad's. If you don't already have an existing Google account, you need to create one in order to use the script.


Please send the Google account information and your TeleConsole's user name to our customer service department, requesting a calendar auto-reply setup. We will make the configuration on our end to make the script send automatic SMS replies from your business SMS phone number. If you have more than one SMS line associated with your TeleConsole account, please let us know which one you want to use for the auto-reply.


 To set up the auto-reply script on your end do the following:


1. Go to script.google.com on your browser of choice and click Start Scripting.

Enter your Google credentials if required



2. Click New script  (you might need to click the three lines menu icon in the upper left corner first).

3. Select any existing code in the script and delete it.

Download the script from the attached text file below (auto_reply_script.txt), copy and paste it into the new script window.


4. Click the save icon (or press ctrl + S on your keyboard).



5. You will be prompted to name your project. Give it any name you like and click OK.

6. Click on the Resources menu and select Advanced Google Services.


7. Click the link to go to Cloud Console Terms of Service.


8. Agree to the Google Cloud Platform Terms.


9. Go Back to the script.



10. Click on the Resources menu and select Advanced Google Services again.

11. In the list that shows up, look for Calendar API.

Click the on-off toggle to the on position then click OK at the bottom of the list.



12. Click the Run button or in the Run menu select Run Function>calendarBasedReply.


13. You will need to grant permissions. Click Review Permissions.


14. If a sign-in page comes up, sign in. Make sure you are using the correct Gmail account for the calendar (at this point google may want to verify that this is you.)



15. A warning will come up saying that the app isn't verified by Google. This is fine since you are running the script yourself, and are not verifying it with google.


16. Click Advanced.


17. Click Go to <the name you used to save the project> (unsafe).


18. Scroll to the bottom and click Allow.


19. Go to calendar.google.com.


20. On the left-hand side click the plus button next to Other calendars then click Create new calendar.



21. Fill out the form for creating a new calendar.


22. Refresh the page.


23. On the left-hand side under settings for my calendars, you should see the calendar you just created. Click it.


24. Scroll down until you find the Integrate Calendar section. 


25. Find the calendar ID and copy the whole ID (it should, but doesn't have to, end with  group.calendar.google.com)


26. In the script find the following line 'var calendarId = 'placeholder@group.calendar.google.com'.


27. Replace placeholder@group.calendar.google.com with the calendar ID you copied. 


MAKE SURE TO INCLUDE THE SINGLE QUOTES ON BOTH SIDES!



28. By default the script won't mark any thread as read, however this can be changed as follows:


  • If you want all messages to be marked as read find and change this line var shouldAlwaysMarkAsRead = false to var shouldAlwaysMarkAsRead = true.

  • If you only want messages replied by the script to be marked as read, find and change this line var shouldMarkAsReadAfterReply = false to var shouldMarkAsReadAfterReply = true.


29. Click Save.


30. Click the white arrow with the blue background in the upper left corner to go back.



31. Click on My projects.


32. In the project list, find the project you created and click on the 3 dots menu on the right. 


33. Select Triggers and click Add Trigger.

Set up the trigger options as explained in steps 34-37.


34. For Choose which function to run select calendarBasedReply.


35. For Select event source choose Time-Driven.


36. For Select type of time based trigger choose Minute timer.


37. For Select Minute interval choose Every Minute.


38. Click Save.


39. Go back to Google Calendar.


40. Click create event.


41. Next to the calendar icon select the calendar you created in step 20 (the same calendar that you copied its ID to the script in step 26.)


42. In the description enter the text of the message you want to auto-reply with. 


43. Please make sure that the message is less than 160 characters (or carriers might suspect spam). 


 You can use www.lettercount.com to ensure that the message is indeed shorter than 160 characters.


44. Under more options you can set the event to repeat.

You can try looking on google calendar help to find whatever other settings you can ap the event.


45. Click Save.



46. Add more events as needed. Remove events when you no longer need them. 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article