DEV Community

Cover image for Automating Event Management: A Discord to Google Calendar Bot
ZhiHong Chua
ZhiHong Chua

Posted on

Automating Event Management: A Discord to Google Calendar Bot

One of my proudest achievements of 2024 has been the successful implementation of a project that combines my technical skills with a deep understanding of user behavior in a community. This project reflects months of learning and design experimentation:

  1. Immersing myself in a community to understand its workflows and needs.
  2. Applying system design principles from work to a meaningful side project.

The Inspiration

I am part of a thriving Discord community with 622 members and 154 active threads. Events are frequently organized, but many go unnoticed due to the lack of a centralized, discoverable schedule. This inspired the idea of a Discord bot that syncs event messages to Google Calendar—a one-stop platform for viewing all community activities.

System Design: From Concept to Execution

While the final design closely mirrors the initial concept, it was initially daunting and took some time before I revisited the idea. To understand the alternatives, let’s first examine how activities are typically organized:

  1. A user proposes a date, time, and activity in a message, listing attendees.
  2. Interested members copy the list and append their names.

Exploring Alternatives

Here are some of the approaches considered, along with their pros and cons:

Idea Pros Cons
Write All Events to Google Sheets Easy to process data (e.g., sorting) Requires behavior change: users must update the sheet instead of messages.
Run a Weekly Script to Summarise Simple, no integrations required Manual effort needed to run the script weekly.
Create a Bot to Sync with Google Calendar Seamlessly integrates with current workflows More complex, requiring software integrations.

The Final Design

The bot uses AWS EventBridge to trigger an hourly Lambda function. The function:

  1. Reads Discord messages via a bot.
  2. Parses messages for event information.
  3. Updates Google Calendar via its API.

Overcoming Barriers

Initially, I hesitated due to concerns about AWS costs spiraling out of control. However, AWS’s cost monitoring tools provided reassurance. Taking the leap into experimentation proved worthwhile and became a learning opportunity in managing cloud resources responsibly.

Key Features

User Features

  1. Event Links: Each calendar event links back to the original Discord message for easy sign-ups.
  2. Device Compatibility: A single calendar link supports Android, iOS, and PC users.
  3. Seamless Integration: Users can subscribe with one click and hide the calendar if desired.

Technical Features

  1. Secure Token Storage: Google Calendar API tokens are securely stored in AWS Systems Manager Parameter Store, avoiding read-only file system limitations in Lambda.
  2. Optimized Search: Message searches are limited to the last two hours, balancing accuracy and efficiency while accounting for potential runtime errors.
  3. Dedicated Calendar Account: A standalone Google account ensures easy project handover without entangling personal credentials.

Challenges and Fixes

  1. Regex Limitation: Initial regex matched "7.30pm" but failed for "1930." This was addressed with an updated pattern.
  2. Hardcoded Year: Events for 2025 failed due to a 2024-specific filter. Adjustments now dynamically account for multiple years.

Next Steps

The bot is currently used by approximately 5% of the community. AWS CloudWatch logs show no runtime errors, indicating the system's reliability. While optimizations and feature improvements are possible, I plan to let the bot run autonomously for now. After juggling this project alongside work, it’s time to recharge before diving into the next challenge.

Top comments (0)