Telegram AI Calendar Assistant
# Setup Guide for Telegram AI Calendar Assistant
This guide will walk you through setting up the necessary API credentials for your "Telegram AI Calendar Assistant" workflow. This workflow integrates several powerful services to create an intelligent assistant:
* **OpenAI**: For natural language understanding, response generation, and voice-to-text transcription.
* **Telegram**: To interact with users via a bot.
* **Google Calendar**: To manage your calendar events.
* **Google Sheets**: To log events for tracking and auditing.
Let's get your automation ready!
---
## 1. OpenAI API Key Setup
Your workflow uses OpenAI for two key purposes:
1. **Language Model:** The 🤖 OpenAI Model (GPT-4o mini) node provides the core intelligence for your AI agent.
2. **Voice Transcription:** The 🎤 Transcribe Voice to Text node uses OpenAI's Whisper model to convert voice messages from Telegram into text.
To make this possible, you'll need an OpenAI API Key.
### A. Quick Facts
* **Time Required:** 5-10 minutes
* **Difficulty:** Easy
* **Cost:** Paid (pay-as-you-go). OpenAI offers a small amount of free credit upon signup, but continued usage will require a payment method.
### B. Account Creation Steps
1. **Visit OpenAI:** Open your web browser and go to [https://platform.openai.com/signup](https://platform.openai.com/signup).
2. **Sign Up:**
* You can sign up using your Google or Microsoft account for a quicker process.
* Alternatively, enter your email address and create a password.
* Follow the on-screen prompts for email verification and phone number verification.
3. **Success Check:** Once signed up, you should be redirected to the OpenAI Platform dashboard. Look for a welcome message or navigation options like "API keys" or "Usage".
### C. Billing Setup
**Important:** OpenAI's API is a paid service. Even with initial free credits, you will likely need to add a payment method to avoid interruptions, especially for sustained or higher usage.
1. **Access Billing:**
* On the OpenAI platform, click on your profile icon (usually in the top right corner).
* Select "Manage account" or "Billing".
* Navigate to the "Billing" or "Payment methods" section.
2. **Add Payment Method:**
* Click on "Add payment method" and follow the instructions to securely add your credit card or other payment details.
* You can check pricing details here: [https://openai.com/pricing](https://openai.com/pricing)
3. **Free Tier/Credits:** New accounts typically receive a small amount of free credit (e.g., $5) that expires after a few months. This is often enough for initial testing, but for a live workflow, a payment method is crucial.
### D. API Key Creation
1. **Navigate to API Keys:**
* From the OpenAI platform dashboard, go to the "API keys" section. You can often find this directly in the left sidebar or under your profile menu.
2. **Create New Secret Key:**
* Click the "+ Create new secret key" button.
* You'll be prompted to give your key a name. A good practice is to name it after your workflow, e.g., "Telegram Calendar Assistant". This helps you identify its purpose later.
* Click "Create secret key".
3. **Copy and Store:**
* **CRITICAL STEP:** The new secret key will be displayed **only once**. Copy it immediately and store it in a secure place (like a password manager).
Once you close the dialog, you will *not** be able to see the full key again. If you lose it, you'll have to create a new one.
### E. How to Connect This Key to Your JSON Template (n8n)
Your JSON template uses an n8n workflow. Here's how to add your OpenAI API Key to n8n:
1. **Open n8n:** Log in to your n8n instance.
2. **Access Credentials:**
* In the n8n sidebar, click on the "Credentials" icon (looks like a key).
* Click the "+ New Credential" button.
3. **Select OpenAI API:**
* Search for "OpenAI API" or "OpenAI" in the credential type list.
* Select OpenAI API.
4. **Configure Credential:**
* **Name:** Give this credential a descriptive name. The workflow expects OpenAi account (as seen in LMhBWR4HHC3Gn64j: "name": "OpenAi account"). It's best to use this exact name for consistency, or update the JSON. Let's stick with what's in the JSON.
* **API Key:** Paste the secret key you copied from the OpenAI platform here.
* Click "Create" or "Save".
5. **Nodes Using This Credential:**
* **`🤖 OpenAI Model (GPT-4o mini)`** (Node ID: 1a94838b-81e5-4040-b224-6cf28092d3ee)
```json
"credentials": {
"openAiApi": {
"id": "LMhBWR4HHC3Gn64j",
"name": "OpenAi account"
}
}
```
* **`🎤 Transcribe Voice to Text`** (Node ID: 46a02946-3be3-45b3-a35e-e17ddf535d07)
```json
"credentials": {
"openAiApi": {
"id": "LMhBWR4HHC3Gn64j",
"name": "OpenAi account"
}
}
```
* Both nodes will automatically use the n8n credential you just configured, identified by the name "OpenAi account".
### F. Testing
1. **Add a Test Node (Optional but Recommended):**
* In n8n, create a new workflow or open your existing one.
* Add an "OpenAI" node (not a Langchain one, just a regular OpenAI node).
* Set the operation to "Chat" or "Completions".
* Select your "OpenAi account" credential.
* Enter a simple prompt, e.g., "Tell me a short story."
* Execute the node.
2. **Success Check:** If the node executes successfully and returns a response from OpenAI, your API key is correctly configured.
3. **Error Indication:** If you see errors like "Invalid API Key", "Billing not enabled", or "Rate limit exceeded", your key is either incorrect, billing is not set up, or you're hitting usage limits.
### G. Troubleshooting
* **"Incorrect API key provided" / "Invalid authentication"**:
* **Solution:** Double-check that you copied the entire API key correctly. Make sure there are no leading/trailing spaces. If unsure, delete the n8n credential, generate a new OpenAI API key, and try again.
* **"You exceeded your current quota, please check your plan and billing details"**:
* **Solution:** This means your free credits have run out, or you haven't added a payment method. Go to OpenAI's billing page ([https://platform.openai.com/usage](https://platform.openai.com/usage) and [https://platform.openai.com/settings/organization/billing/overview](https://platform.openai.com/settings/organization/billing/overview)) and add a payment method or check your usage limits.
* **"The model gpt-4o-mini does not exist"**:
* **Solution:** Very unlikely for official models, but if you typed a model name incorrectly or if it's a new model not yet globally rolled out, you might see this. Double-check the model name (`gpt-4o-mini` is correct for this workflow).
* **"Request failed with status code 429" (Too Many Requests)**:
* **Solution:** You're sending too many requests too quickly. This is usually handled automatically by n8n's retry logic, but for very high loads, you might need to implement rate limiting or request higher limits from OpenAI.
---
## 2. Telegram Bot Setup
Your workflow uses Telegram to receive user messages and send replies. This requires a Telegram Bot.
### A. Quick Facts
* **Time Required:** 10-15 minutes
* **Difficulty:** Easy
* **Cost:** Free
### B. Account Creation Steps
1. **Install Telegram:** If you don't already have it, install the Telegram app on your phone or computer. You'll need an account to create a bot.
2. **Find BotFather:**
* Open Telegram.
* In the search bar, type @BotFather. Look for the official BotFather account (it will have a blue verified badge).
* Start a chat with BotFather.
3. **Success Check:** You should see a list of commands from BotFather.
### C. Billing Setup
Telegram bots are completely free to create and use. There are no billing steps required.
### D. API Key (Bot Token) Creation
1. **Start a New Bot:**
* In your chat with BotFather, type /newbot and send it.
* BotFather will ask you for a name for your bot. Choose a friendly name, e.g., "AI Calendar Assistant".
Next, BotFather will ask for a username for your bot. This *must end with 'bot'** (e.g., KasbahAICalendarBot). This username must be unique on Telegram.
2. **Copy Bot Token:**
If successful, BotFather will congratulate you and provide a *HTTP API Token**. This is your Bot Token.
* **CRITICAL STEP:** Copy this long string of characters (e.g., 123456789:ABCDEfGHiJkLmNoPqRsTuVwXyZ) immediately and save it securely.
3. **Find Your Bot:**
* BotFather will also provide a link to your new bot (e.g., t.me/your_bot_username). Click this link and click "START" in your bot's chat window. This activates the bot and makes it ready to receive messages.
### E. How to Connect This Key to Your JSON Template (n8n)
Your JSON template uses an n8n workflow. Here's how to add your Telegram Bot Token to n8n:
1. **Open n8n:** Log in to your n8n instance.
2. **Access Credentials:**
* In the n8n sidebar, click on the "Credentials" icon (looks like a key).
* Click the "+ New Credential" button.
3. **Select Telegram API:**
* Search for "Telegram API" or "Telegram" in the credential type list.
* Select Telegram API.
4. **Configure Credential:**
* **Name:** Give this credential a descriptive name. The workflow expects Telegram account (as seen in QYNyyU8D1JJKR749: "name": "Telegram account"). It's best to use this exact name for consistency, or update the JSON.
* **Access Token:** Paste the Bot Token you copied from BotFather here.
* Click "Create" or "Save".
5. **Nodes Using This Credential:**
* **`⚡ Start on Telegram Message`** (Node ID: 2decba19-0388-4f07-ba9e-ce492618b01b)
```json
"credentials": {
"telegramApi": {
"id": "QYNyyU8D1JJKR749",
"name": "Telegram account"
}
}
```
* **`💬 Send Reply on Telegram`** (Node ID: c46de7bc-ee8a-4720-b498-613b3278ea89)
```json
"credentials": {
"telegramApi": {
"id": "QYNyyU8D1JJKR749",
"name": "Telegram account"
}
}
```
* **`📥 Download Voice File`** (Node ID: b9ac0a9b-7e6c-4280-aa26-dfeb0f9a32af)
```json
"credentials": {
"telegramApi": {
"id": "QYNyyU8D1JJKR749",
"name": "Telegram account"
}
}
```
* All three nodes will automatically use the n8n credential you just configured, identified by the name "Telegram account".
### F. Testing
1. **Activate the Workflow:** After importing the JSON into n8n, activate the workflow (toggle the "active" switch in the top right).
2. **Send a Message:** Go to your Telegram app and send a message to your newly created bot.
3. **Success Check:**
* In n8n, you should see the ⚡ Start on Telegram Message node trigger (its execution count will increment).
* If the entire workflow runs, you should receive a reply from your bot in Telegram.
4. **Error Indication:** If the trigger node does not fire, or you see errors, check your n8n logs.
### G. Troubleshooting
* **Workflow not triggering:**
* **Solution:** Ensure the n8n workflow is **active**. Verify the Bot Token in n8n credentials is correct. Make sure you started the conversation with your bot in Telegram (clicked "START").
* **"Webhook could not be set"**:
* **Solution:** This can happen if your n8n instance is not publicly accessible or if there's a network issue. Ensure your n8n instance URL is reachable from the internet. Sometimes, simply deactivating and reactivating the workflow can re-register the webhook.
* **Bot not replying:**
* **Solution:** Check the n8n workflow execution history. If the 💬 Send Reply on Telegram node failed, review its error message. Ensure the chatId expression is correct (it should dynamically get the user's chat ID).
---
## 3. Google Calendar & Google Sheets API Setup
Your workflow interacts with both Google Calendar and Google Sheets. While these are two different services, n8n often uses a single Google OAuth2 credential to connect to multiple Google APIs, provided the necessary "scopes" (permissions) are granted. We'll set up a single credential that covers both.
### A. Quick Facts
* **Time Required:** 15-30 minutes
* **Difficulty:** Medium
* **Cost:** Free for typical usage, but higher usage may incur costs. Requires a Google account.
### B. Account Creation Steps
1. **Google Account:** You need a standard Google account (e.g., a Gmail account). If you don't have one, create one at [https://accounts.google.com/signup](https://accounts.google.com/signup).
2. **Google Calendar:** Ensure you have at least one Google Calendar associated with your account. You'll need to know its ID or select it by name later.
3. **Google Sheet:** Create a new Google Sheet that your bot will log events to.
* Go to [https://sheets.new](https://sheets.new) to create a new spreadsheet.
* Name it something like "AI Calendar Event Log".
* **Important:** Create the header row as specified in the ✍️ Google Sheets: Log Event node: Date, Title, Start Time, End Time, Description, Length, ID. (You can adjust column order, but ensure these headers exist in the first row).
* Make a note of the Spreadsheet ID (the long string of characters in the URL between /d/ and /edit). You'll need to paste this into the Google Sheets node in n8n.
### C. Billing Setup
Google APIs generally offer a generous free tier. For most personal or small-scale automation, you won't incur charges. However, it's good practice to be aware:
1. **Google Cloud Project:** When you create an API project, Google automatically enables a "Cloud Billing account" if you don't have one. You usually don't need to add payment details unless you exceed free limits.
2. **Monitor Usage:** You can monitor your API usage and potential costs in the Google Cloud Console under the "Billing" section.
3. **Pricing Links:**
### D. API Key (OAuth2 Client ID/Secret) Creation
This process involves setting up a project in Google Cloud Console to get OAuth2 credentials.
1. **Go to Google Cloud Console:** Open your browser to [https://console.cloud.google.com/](https://console.cloud.google.com/).
2. **Create a New Project:**
* At the top left, click on the project selector (it might say "My First Project" or your current project name).
* Click "New Project".
* Give it a name, e.g., "KasbahAI Calendar Assistant".
* Click "Create".
3. **Enable APIs:**
* Once your project is created and selected, navigate to "APIs & Services" > "Enabled APIs & services" in the left sidebar.
* Click "+ ENABLE APIS AND SERVICES" at the top.
* Search for "Google Calendar API" and enable it.
* Search for "Google Sheets API" and enable it.
4. **Configure OAuth Consent Screen:**
* In the left sidebar, go to "APIs & Services" > "OAuth consent screen".
* **User Type:** Choose "External" (unless you are part of an organization and intend to limit access internally) and click "Create".
* **App Registration:**
* **App name:** "AI Calendar Assistant" (or similar).
* **User support email:** Your email address.
* **Developer contact information:** Your email address.
* Click "SAVE AND CONTINUE".
* **Scopes:** This is crucial for granting permissions.
* Click "ADD OR REMOVE SCOPES".
* In the filter box, search for "calendar" and select:
* .../auth/calendar (or .../auth/calendar.events if you only need events, but .../auth/calendar is safer for full functionality).
* Search for "sheets" and select:
* .../auth/spreadsheets
* Click "UPDATE".
* Click "SAVE AND CONTINUE".
* **Test Users:** If your app is "External" and not "In Production" yet, you'll need to add your Google account as a test user. Click "ADD USERS" and enter your Google account email.
* **Publish App (Optional but Recommended):** To avoid the "This app isn't verified" screen for users (including yourself after a while), you can click "PUBLISH APP" in the "OAuth consent screen" dashboard. You might need to provide a privacy policy URL and home page URL, but for personal use, a simple placeholder URL might suffice, or just keep it in testing mode.
5. **Create Credentials:**
* In the left sidebar, go to "APIs & Services" > "Credentials".
* Click "+ CREATE CREDENTIALS" at the top and select "OAuth client ID".
* **Application type:** Select "Web application".
* **Name:** Give it a name, e.g., "n8n OAuth".
* **Authorized redirect URIs:** This is where Google will send the user back after authentication. You need to get this from your n8n instance.
* In n8n, when you create a new Google OAuth2 credential (as described in the next section), it will show you the exact "OAuth Callback URL" to use. It typically looks like https://your-n8n-instance.com/rest/oauth2-credential/callback.
* Copy this URL from n8n and paste it here.
* Click "CREATE".
6. **Copy Client ID and Client Secret:**
* Google will display your "Client ID" and "Client Secret".
* **CRITICAL STEP:** Copy both of these values immediately and securely store them.
### E. How to Connect These Credentials to Your JSON Template (n8n)
1. **Open n8n:** Log in to your n8n instance.
2. **Access Credentials:**
* In the n8n sidebar, click on the "Credentials" icon (key icon).
* Click the "+ New Credential" button.
3. **Select Google OAuth2 API:**
* Search for "Google OAuth2 API".
* Select Google OAuth2 API.
4. **Configure Credential:**
* **Name:** Give this credential a descriptive name. For Google Calendar, the JSON uses Google Calendar account 2 (`rKyJYAGqjbqTMyaZ: "name": "Google Calendar account 2"`). For Google Sheets, it uses Google Sheets account (`aousupuBssl8EPuw: "name": "Google Sheets account"`).
* **Recommendation:** To avoid creating two separate OAuth2 credentials (which would mean two sets of Client ID/Secret and two auth flows), you can set up one Google OAuth2 credential in n8n and then manually re-assign the credential in the workflow nodes to point to this single, unified credential.
* Let's create one named "Unified Google Account" for clarity in this guide. After saving, you'd edit the Google Calendar and Google Sheets nodes to point to this new credential.
* **Client ID:** Paste the Client ID you copied from Google Cloud Console.
* **Client Secret:** Paste the Client Secret you copied from Google Cloud Console.
* **Scopes:**
* Click "Add Scope".
* Add the following scopes (make sure they match exactly):
* Optional but recommended: https://www.googleapis.com/auth/drive.file (This scope is often needed for Google Sheets nodes to "find" the sheet you're working with, even if you just want to write to it.)
* Click "Create" or "Save".
5. **Connect Account:** After saving, n8n will prompt you to "Connect your account". Click this button. A new browser tab or window will open, asking you to log in to your Google account and grant the requested permissions. Make sure to select the same Google account you used to set up the project and enable APIs.
6. **Update Nodes in Workflow:**
* After connecting, go back to your workflow in n8n.
* Open the settings for the following nodes:
* **`🗓️ Google Calendar: Get Events`** (Node ID: 7aeacf97-0cab-413f-a2cc-e45ab79b6ad6)
* **`🗓️ Google Calendar: Create Event`** (Node ID: 0e31ab41-46a7-4489-bbf4-ab09e538dedc)
* **`🗓️ Google Calendar: Update Event`** (Node ID: b6ae7b9b-26e2-4e34-9a49-c8fac6a3b5af)
* **`✍️ Google Sheets: Log Event`** (Node ID: f3fab6a2-feda-46e7-a987-82287662c098)
* For each of these nodes, find the "Credentials" section and select your newly created "Unified Google Account" (or whatever you named it).
* **Crucial for Google Calendar/Sheets nodes:** The calendar and spreadsheet IDs are redacted in the JSON (`[REDACTED_CALENDAR_ID]`, [REDACTED_SPREADSHEET_ID]). You **must** update these:
* For 🗓️ Google Calendar: Get Events, 🗓️ Google Calendar: Create Event, 🗓️ Google Calendar: Update Event: In the calendar field, click the "Load from Google" button or manually enter the exact calendar ID (often your Google account email, or an ID like [email protected]).
* For ✍️ Google Sheets: Log Event: In the documentId field, paste the Spreadsheet ID you noted earlier when creating the Google Sheet. Also, ensure the sheetName is correct (e.g., Sheet1).
### F. Testing
1. **Test Google Calendar:**
* Add a standalone "Google Calendar" node in n8n.
* Select your "Unified Google Account" credential.
* Set the operation to "Get All Events" (similar to 🗓️ Google Calendar: Get Events).
* Provide a calendar ID and a time range.
* Execute the node.
* **Success Check:** If it returns a list of events from your calendar, the Google Calendar part is working.
2. **Test Google Sheets:**
* Add a standalone "Google Sheets" node in n8n.
* Select your "Unified Google Account" credential.
* Set the operation to "Append Row".
* Provide the Spreadsheet ID and Sheet Name of your "AI Calendar Event Log" sheet.
* Enter some test data for a row.
* Execute the node.
* **Success Check:** Check your Google Sheet online; if a new row with your test data appears, the Google Sheets part is working.
### G. Troubleshooting
* **"API not enabled"**:
* **Solution:** Go back to Google Cloud Console ([https://console.cloud.google.com/apis/library](https://console.cloud.google.com/apis/library)) and ensure "Google Calendar API" and "Google Sheets API" are both enabled for your project.
* **"Insufficient permissions" / "Request had insufficient authentication scopes"**:
* **Solution:** This is usually a scope issue. Go to Google Cloud Console > "APIs & Services" > "OAuth consent screen" and ensure you have added https://www.googleapis.com/auth/calendar and https://www.googleapis.com/auth/spreadsheets (and potentially https://www.googleapis.com/auth/drive.file) to your OAuth client. After changing scopes, you may need to re-authenticate the credential in n8n (edit the credential and click "Connect your account" again).
* **"This app isn't verified" warning during authentication in n8n**:
* **Solution:** This is normal if you haven't published your app in Google Cloud Console. For personal use, you can usually click "Advanced" and then "Go to [Your App Name] (unsafe)" to proceed. To remove the warning, you need to "PUBLISH APP" in the Google Cloud Console > "OAuth consent screen" and may need to provide a privacy policy link.
* **Calendar/Sheet ID issues**:
* **Solution:** Double-check that the Calendar ID and Spreadsheet ID you've entered into the n8n nodes are exact. For calendars, it's often your email, or a string like primary. For sheets, ensure the sheet name is also correct (`Sheet1` is common).
* **"Access blocked: This app’s request is invalid"**:
* **Solution:** This often means your "Authorized redirect URIs" in Google Cloud Console > Credentials > OAuth client ID are incorrect or missing. Make sure the exact callback URL from your n8n Google OAuth2 credential setup is listed there.
---
Scenario name: Telegram AI Calendar Assistant
5
1 comment
Youness Taza
4
Telegram AI Calendar Assistant
ARABIC AI AGENTS ACADEMY
skool.com/arabic-ai-agents-academy
🚀 أكاديمية الذكاء الاصطناعي والأتمتة
هنا تتعلم كيف تحوّل الذكاء الاصطناعي إلى فريق عمل يعمل من أجلك 24/7.
Leaderboard (30-day)
Powered by