A comprehensive Discord bot that integrates with Google Tasks to provide task management capabilities directly from Discord. The bot offers full synchronization with Google Tasks, reminder systems, and advanced task organization features.
- Full Google Tasks Integration: Complete synchronization with your Google Tasks account
- Task CRUD Operations: Create, read, update, and delete tasks seamlessly with Google tasks sync
- Task Status Toggle: Mark tasks as complete/incomplete with a single command
- Task Reminders: Create custom task reminders
- Due Date Management: Set and modify task due dates with validation
- Task Lists Management: Create and manage multiple task lists.
- Custom Categories: Create and assign custom categories to tasks for better organization
- Priority System: Assign priority levels (Low, Medium, High) to tasks
- Task View: View tasks by various criteria including category and priority
- Gen AI based queries : Type
query
followed by your query in natural language - Note : Currently only task creation and a few more queries are supported in natural language
- One-time Reminders: Set individual reminders for specific tasks
- Recurring Reminders: Create repeating reminders with customizable intervals (1-30 days)
- Synced Recurring Tasks: Create recurring reminders that sync with Google tasks and track task completion
- Timezone Support: Full timezone awareness for accurate reminder scheduling
- Task Groups: Create and manage task groups for collaborative work
- Group Commands: Dedicated command processor for group-specific operations
Before setting up the bot, you'll need:
- Python 3.8 or higher
- A Google Cloud Platform account
- A Discord Developer account
- MongoDB database (local or cloud)
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Tasks API:
- Navigate to "APIs & Services" > "Library"
- Search for "Tasks API" and enable it
- Create OAuth 2.0 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth 2.0 Client IDs"
- Choose "Web application" as the application type
- Add authorized redirect URIs (your auth server URL) which is http://localhost:8080
- Note : If unable to add localhost as redirect URI first add another random valid domain before adding localhost.
- Set the necessary environment variables in .env ( Use .env.example as a reference )
- Note you need the following scopes enabled in OAuth
openid
,email
,profile
andhttps://www.googleapis.com/auth/tasks
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Navigate to the "Bot" section
- Click "Add Bot"
- Copy the bot token (you'll need this for the
.env
file) - Enable necessary intents:
- Message Content Intent
- Server Members Intent (if using group features)
Create a .env
file in the project root with the following variables:
# Discord Bot Token
DISCORD_BOT_TOKEN = <your_discord_bot_token>
# Google OAuth Credentials
GOOGLE_CLIENT_ID = <your_google_client_id>
GOOGLE_CLIENT_SECRET = <your_google_client_secret>
# MongoDB Configuration
MONGO_DB_CLUSTER_URL = <your_mongo_db_cluster_url>
MONGO_DB_ADMIN_USERNAME = "<your_mongo_db_admin_username>"
MONGO_DB_ADMIN_PASSWORD = "<your_mongo_db_admin_password>"
# Generative AI Config
GEMINI_API_KEY = "<your_gemini_api_key>"
# Timezone Configuration ( Local timezone of server )
LOCAL_TZ = "<your_local_timezone>"
Install the required Python packages ( preferably in a fresh virtual environment ) :
pip install discord.py
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client
pip install pymongo
pip install python-dotenv
pip install table2ascii
pip install pytz
pip install asyncio
Create a database called as TBot_DB
with the following collections :
auth
for storing user refresh tokens and OAuth credentialstasks
for storing a synced version of users Google Taskstasks_ns
for storing category and priority informationreminders
for storing user remindersgroups
for storing user groupsgroup_tasks
for storing user group tasks
Ensure your project has the following structure:
discord-task-bot/
├── main.py
├── Reminder_Bot.py
├── Auth_Server.py
├── Group_Commands_Processor.py
├── Group_Bot.py
├── User.py
├── Tasks.py
├── User_Tasks.py
├── Misc_Methods.py
├── Mongo_Access.py
├── .env
└── README.md
The bot requires multiple components to run simultaneously. Start each in a separate terminal:
python Auth_Server.py
python main.py
python Reminder_Bot.py
python Group_Commands_Processor.py
python Group_Bot.py
- Send a DM to the bot with the message
initialise
- Click the provided Google OAuth link to authorize the bot
- Complete the authorization within 60 seconds
All commands are prefixed with #
and must be sent as direct messages to the bot:
#list_tasks
- Display all your tasks#create_task
- Create a new task#modify_task
- Edit an existing task#delete_task
- Remove a task#toggle_task
- Mark task as complete/incomplete
#list_tasklists
- Show all your task lists#create_tasklist
- Create a new task list
#list_category
- View all categories#create_category
- Create a new category#assign_category
- Assign a category to a task#assign_priority
- Set task priority (low/medium/high)
#create_reminder
- Set up task reminders#list_reminders
- View all active reminders
#create_task_group
- Create a task group enabling group task support#join_group
- Join task group#assign_group_channel
Assign channel to a group#create_group_task
- Create group task#list_group_task
- Lists all group tasks#toggle_group_task
- Toggle group task completion status#delete_group_task
- Delete group task#list_groups
- List all user groups#invite_member_to_group
- Invite member to group#assign_role
- Assign role to group member#leave_group
- Leave the group
Note : Only users with role Moderator and Above can create tasks as well as assign tasks to other users.
#set_timezone
- Configure your timezone for accurate reminders
When creating or modifying tasks, use this format:
Task Name Due Date(YYYY-MM-DD) Notes(if any)
Example: Complete project report 2025-06-15 Final version with all sections
- One-time Reminders: Get notified once at a specific date and time
- Recurring Reminders: Repeat every 1-30 days
- Synced Reminders: Automatically update task due dates and reset completion status
- Create reminders that sync with task due dates ( essentially regenerating tasks )
- Automatically reset task completion status on each recurrence
- Perfect for daily, weekly, or monthly recurring tasks
- Set your local timezone for accurate reminder scheduling
- All reminders are displayed in your configured timezone
- Supports all standard timezone formats (e.g.,
Asia/Kolkata
,America/New_York
) listed inpytz -> common_timezones
- Organize tasks with custom categories
- Set priorities to focus on important tasks
- Bot not responding: Ensure all four components are running
- Google Tasks sync issues: Check your OAuth credentials and API enablement
- Reminder not working: Verify timezone settings and ensure Reminder_Bot.py is running
- Database errors: Confirm MongoDB is running and accessible
"Initialise by typing initialise first"
: You need to complete the Google OAuth setup"Error fetching user tasks"
: Check Google API credentials and network connection"Time elapsed please try again later"
: Command timeout - retry the operation
For additional support or to report issues:
- Check that all prerequisites are properly installed
- Verify all environment variables are correctly set
- Ensure all four Python scripts are running simultaneously
- Check MongoDB connectivity and Google API credentials
- Keep your
.env
file secure and never commit it to version control - Regularly change your Discord bot token and Google OAuth credentials
- Use secure MongoDB configurations in production environments
- Consider using application-specific passwords for enhanced security
Note: This bot requires continuous internet connectivity for Google Tasks synchronization and Discord API communication. Reminders should be created at least 30 minutes before the due time to ensure proper delivery.
- The reminder bot utilises a priority queue for efficient and scalable reminder alerts
- I did try testing the bot with async MongoDB clients but it did not yield noticeable performance improvements
- The codebase relied on json files earlier prior to the migration to MongoDB which made it very inefficient as all users files needed to be loaded for each query
- Appropriate MongoDB indexes were set up for unique fields commonly accessed to speed up query times
- The overall user experience relies a bit heavily on typing as opposed to discord interactions due to time constraints and realising it a lot later down the project