Integration of rocketChat with Google calendar using a python script to create a webhook
The solution consists of two parts.
- A python script that connects to google calendar API and sends the data to RocketChat
- An incoming webhook in RocketChat that interprets the data sent from the python script
- Checkout the project
- Create an incoming webhook in your RocketChat
- Go to RocketChat-> Administration-> Integrations-> New Integration-> Incoming webhook
- Set "Enabled" to "true"
- Give a name for the webhook
- Define the channel you want the events to appear (ex: #calendar-events). Make sure the channel exists
- Set "Script Enabled" to "true"
- Put in the script field the contents of the file webhook.js
- Press "save changes"
- Copy the contents of the newly created field "Webhook URL" to clipboard. You will need it.
- Configure the python script
- Open the file calendarWebhook.py
- On line 18, put the url you copied form the RocketChat incoming webhook
- Open in your browser your google calendar, find the settings of that specific calendar and copy the CalendarId
- Paste the CalendarId on line 21
- If you want your results to appear in a specific timezone, fill in the line 24 (example: Europe/Athens)
- Install python prerequisites
- pip install --upgrade google-api-python-client
- pip install requests
- Create google api credentials as shown at: https://developers.google.com/google-apps/calendar/quickstart/python (step 1)
- Put client_secret.json from above step in the same directory as your python scrpt
- Fire up the OAuth authentication process by running it once on shell/terminal
- Create an event in your calendar starting somewhere in the next 30 minutes
- run: python calendarWebhook.py
- follow the instructions for authorising the script to access the calendar. Note: The user you use to authorise should have access to the calendar
- If all went well, it should post the calendar event in your channel
- set to run every 5 minutes