Call in sick with a custom bot for Hangouts Chat
Update your calendar and auto-responder with a single message to your custom bot.
Last updated: August, 2019
When you wake up feeling ill the last thing you want to do is log in to your work account and update your status in multiple applications. With this solution, you simply send the message "I'm sick" to a custom bot in Hangouts Chat and it will turn on your out of office message in Gmail and block off your day in Google Calendar.
- Uses the Hangouts Chat API to build a chat bot, which you can message just like a human participant.
- The bot is implemented using [Apps Script][apps_script], allowing for rapid development and worry-free operation.
- Uses the Gmail API to set the user's out-of-office auto-responder.
- Blocks off the user's calendar using the Calendar API.
First, create the script:
- Click here to open the bot code in the Apps Script code editor.
- Click the menu item File > Make a copy to get your own copy. You can later access this copy in the G Suite Developer Hub.
Then create a Google Cloud project to use with it:
- Create a new project in the Google Cloud Developer Console. Name it "Call in Sick", select a Billing Account if prompted, and click CREATE. More information on how to setup billing here.
- When the project creation is complete a notification appears in the upper-right of the page. Click on the Create Project: Call in Sick entry to open the project.
- Open the OAuth consent screen settings page for the project.
- In the field Application name enter "Attendance Bot" and click the Save button at the bottom.
- Open the Gmail API page in the API library and click the ENABLE button.
- Open the Project settings page for the project.
- Copy the value listed under Project number.
Next, setup your script to use the new project and deploy it:
- Back in the Apps Script Code Editor, click the menu item Resources > Cloud Platform project.
- Enter the project number into the text box and click Set Project. When prompted, click Confirm.
- When complete, click the Close button or X icon to dismiss the dialog.
- Click the menu item Publish > Deploy from manifest.
- Next to the entry Latest Version (Head) click Get ID.
- Select and copy the Deployment ID value.
- Close the dialog and the Deployments window.
Then configure the Hangouts Chat API to create your bot:
- Back in the Google Cloud Developers Console, open the Hangouts Chat API page in the API library and click the ENABLE button.
- Once the API is enabled, on click the Configuration tab.
- In the Configuration tab, do the following:
- In the Bot name box, enter "Attendance Bot".
- In the Avatar URL box, enter
- In the Description box, enter "Call in sick with a bot".
- Under Functionality, select Bot works in direct messages.
- Under Connection settings, select Apps Script project and paste your script's Deployment ID into the text box.
- Under Permissions, select Specific people and group in your domain. In the text box under the drop-down menu, enter your email address.
- Click Save changes.
- After you save your changes, verify that the status on the Hangouts Chat API page shows the Bot Status to be LIVE – available to users.
Finally, test that your bot is working:
- Open Hangouts Chat.
- Click Find people, rooms, bots > Message a bot.
- From the list, select the Attendance Bot that you created.
- Send the message "I'm sick" to the bot.
- Click the CONFIGURE button and authorize access to your account.
- In the resulting card, click the SET VACATION IN GMAIL and BLOCK OUT DAY IN CALENDAR buttons.
To learn more about how the bot was made, follow this codelab for detailed instructions on each step in the process. You can also view the full source code of this solution on GitHub if you want to jump right to the end.
Were you able to get the solution up and running?
If you have an idea for another solution you'd like to see featured in our gallery submit a request on the GitHub issue tracker.