Overview
This tutorial explains how to automate appointment scheduling by connecting a Telegram bot to Google Calendar using Activepieces, including voice and text message handling, event conflict checks, and automated user notifications.
Automation Workflow Overview
- The automation lets users schedule or view appointments via a Telegram bot, with details added to Google Calendar automatically.
- Both text and voice messages are supported and handled differently within the workflow.
- Activepieces is used for flow orchestration; Google Drive serves as temporary storage for voice messages during transcription.
- An LLM (OpenAI) processes user inputs to categorize requests and extract event information.
Setting Up the Telegram Bot
- Use BotFather in Telegram to create a new bot, assign a username, and obtain the API token.
- Integrate this API token into Activepieces for automation triggers.
Handling Telegram Messages
- Configure Activepieces to trigger on new Telegram messages.
- Differentiate between text and voice messages using condition checks.
- Voice messages are temporarily uploaded to Google Drive, then downloaded, and transcribed using OpenAI's API.
Processing and Storing User Input
- Transcribed or text messages are saved in Activepieces storage for workflow progression.
- Messages are then sent to a language model to determine if the user wants to view or schedule an appointment.
- The LLM extracts start/end dates, event name, description, and requested task.
Branching Logic for Task Handling
- The automation routes the flow based on whether the task is “retrieve schedule” or “schedule.”
- If the intent is unclear, the bot replies asking for clarification.
Retrieving Google Calendar Events
- When retrieving schedules, fetch all relevant calendar events within the specified time range.
- Use custom code to format and clean event data, then prompt the LLM to generate a readable Markdown summary.
- Send formatted event summaries back to the user via Telegram.
Scheduling a New Appointment
- Before scheduling, check for event conflicts by retrieving events within the requested time.
- If a conflict exists, notify the user of the conflict.
- If no conflict, create the event in Google Calendar with details from the parsed message.
- Confirm scheduled events to the user, including event name and date.
Error Handling and Notifications
- At each branch (conflict, schedule created, unclear intent), send appropriate feedback to the user via Telegram.
- Clean up temporary files from Google Drive after processing.
Recommendations / Advice
- Use Google Drive only as temporary storage for voice files, deleting them post-transcription to avoid clutter.
- Ensure all API tokens and connections in Activepieces are kept secure and up-to-date.
Questions / Follow-Ups
- Explore alternative methods for voice file handling that don’t require Google Drive as an intermediary.
- Check if future updates to Activepieces introduce direct voice message or typing action APIs.