{"node":"{\n\"updatedAt\": \"2026-01-07T09:03:30.000Z\",\n\"createdAt\": \"2026-01-07T08:59:54.652Z\",\n\"id\": \"ZbbOwzCYtGcn5WCD\",\n\"name\": \"Automated reservation system with Telegram, Google Gemini AI, and Google Sheets\",\n\"active\": false,\n\"isArchived\": false,\n\"nodes\": [\n {\n\"parameters\": {\n\"updates\": [\n\"message\"\n ],\n\"additionalFields\": {}\n },\n\"id\": \"cdee9b4c-c94d-47c7-802b-0825919db984\",\n\"name\": \"Telegram Trigger\",\n\"type\": \"n8n-nodes-base.telegramTrigger\",\n\"position\": [\n 912,\n 544\n ],\n\"webhookId\": \"c2f4be19-1555-454d-bd08-46096d4521af\",\n\"typeVersion\": 1.2,\n\"credentials\": {\n\"telegramApi\": {\n\"id\": \"Z2FSMKmPu6xdQdXH\",\n\"name\": \"my-hominem-bot\"\n }\n }\n },\n {\n\"parameters\": {\n\"chatId\": \"={{ $('Telegram Trigger').item.json.message.chat.id }}\",\n\"text\": \"={{ $json.output }}\",\n\"additionalFields\": {\n\"appendAttribution\": false\n }\n },\n\"id\": \"01d625c7-17e7-4cdc-9463-346eef53397e\",\n\"name\": \"Telegram\",\n\"type\": \"n8n-nodes-base.telegram\",\n\"position\": [\n 2032,\n 544\n ],\n\"webhookId\": \"4c856a8c-484d-43ad-8405-7136d637f499\",\n\"typeVersion\": 1.2,\n\"credentials\": {\n\"telegramApi\": {\n\"id\": \"Z2FSMKmPu6xdQdXH\",\n\"name\": \"my-hominem-bot\"\n }\n }\n },\n {\n\"parameters\": {\n\"promptType\": \"define\",\n\"text\": \"={{ $json.finalPrompt }}\",\n\"options\": {\n\"systemMessage\": \"\\n\\nYou are a helpful Court Reservation Assistant for Black Ball Sporting Club. Your role is to help players book training courts through a simple, guided process. Keep responses concise and friendly.\\n\\n## Core Behavior\\n\\n- Always respond with complete, helpful messages\\n- If you don't understand something, ask for clarification politely\\n- Handle errors gracefully without technical jargon\\n- Stay focused on court reservations\\n\\n## Reservation Process\\n\\n### 1. Welcome New Users\\n\\nWhen someone starts a conversation:\\n\\n- Greet them warmly\\n- Explain you help with court bookings\\n- Ask for their reservation details\\n\\n### 2. Collect Information\\n\\nAsk users to provide these details (they can send multiple messages):\\n\\n- **Date** (YYYY-MM-DD format, e.g., 2025-06-15)\\n- **Full Name**\\n- **Email Address**\\n- **Court Number** (check available courts using the court info tool)\\n- **Start Time** (24-hour format, e.g., 14:30)\\n- **End Time** (24-hour format, e.g., 16:00)\\n\\n**Example:** \\\"I need: Date, Your Name, Email, Court Number, Start Time, and End Time. You can send these in separate messages or all together.\\\"\\n\\n### 3. Validation & Conflict Check\\n\\nBefore confirming any booking:\\n\\n- Verify date format is YYYY-MM-DD\\n- Check start time is before end time\\n- Ensure email looks valid (contains @ symbol)\\n- Use the court confirmation tool to check for scheduling conflicts\\n- If there's a conflict, suggest alternative times or courts\\n\\n### 4. Booking Confirmation\\n\\nOnce details are validated and no conflicts exist:\\n\\n- Save the reservation using the court confirmation tool\\n- Send confirmation email using the Gmail tool\\n- Confirm success to the user in Telegram\\n\\n## Error Handling\\n\\n**Invalid Formats:**\\n\\\"I need the date as YYYY-MM-DD (like 2025-06-15) and times as HH:MM (like 14:30). Could you try again?\\\"\\n\\n**Time Conflicts:**\\n\\\"Sorry, that time slot is already booked. Here are some available alternatives: [suggest 2-3 nearby time slots]\\\"\\n\\n**Missing Information:**\\n\\\"I still need [list missing items]. Could you provide those details?\\\"\\n\\n**System Errors:**\\n\\\"I'm having trouble accessing the booking system right now. Please try again in a moment.\\\"\\n\\n## Important Rules\\n\\n- Never send empty or incomplete responses\\n- Always acknowledge what the user sent before asking for more info\\n- If using tools fails, explain the issue simply\\n- Offer helpful alternatives when possible\\n- Keep the conversation moving forward\\n- Don't repeat the same instructions multiple times\\n\\n## Tone\\n\\n- Friendly but professional\\n- Encouraging and supportive\\n- Clear and direct\\n- Solution-focused\"\n }\n },\n\"id\": \"3cf98881-4c56-41fc-9025-96aee9ee6954\",\n\"name\": \"AI Agent\",\n\"type\": \"@n8n/n8n-nodes-langchain.agent\",\n\"position\": [\n 1504,\n 544\n ],\n\"typeVersion\": 1.9\n },\n {\n\"parameters\": {\n\"instructions\": \"Write code to:\\n• Get today’s date formatted “Month Day, Year”\\n• Extract the telegram message from chat.text\\n• Build a field finalPrompt exactly as:\\n\\nvbnet\\nCopy\\nEdit\\nToday's date is: [date]\\n\\n\\n\\nUser's question:\\n[body]\\n• Return finalPrompt only.\",\n\"codeGeneratedForPrompt\": \"Write code to:\\n• Get today’s date formatted “Month Day, Year”\\n• Extract the telegram message from chat.text\\n• Build a field finalPrompt exactly as:\\n\\nvbnet\\nCopy\\nEdit\\nToday's date is: [date]\\n\\n\\n\\nUser's question:\\n[body]\\n• Return finalPrompt only.\",\n\"jsCode\": \"const items = $input.all();\\nconst today = new Date();\\nconst formattedDate = `${today.toLocaleString(\\\"default\\\", { month: \\\"long\\\" })} ${today.getDate()}, ${today.getFullYear()}`;\\n\\nconst finalPrompt = items.map((item) => {\\n const telegramMessage = item?.json?.message?.text;\\n return {\\n finalPrompt: `Today's date is: ${formattedDate}\\\\n\\\\nUser's question:\\\\n${telegramMessage}`,\\n };\\n});\\n\\nreturn finalPrompt;\\n\"\n },\n\"id\": \"718b57b6-15bb-47cb-8371-77c8e1997572\",\n\"name\": \"Prepare Prompt\",\n\"type\": \"n8n-nodes-base.aiTransform\",\n\"position\": [\n 1136,\n 544\n ],\n\"typeVersion\": 1\n },\n {\n\"parameters\": {\n\"content\": \"🧠 Purpose\\nThis workflow powers a general-purpose reservation bot using Telegram, Google Sheets, and Email. Users send one message to request a reservation—it's validated against existing bookings, stored, and confirmed automatically.\\n\\n📥 Input Collected (in one go):\\n\\nDate\\n\\nName\\n\\nEmail\\n\\nResource (court, room, etc.)\\n\\nStart Time\\n\\nEnd Time\\n\\nConfirm (by replying \\\"yes\\\")\\n\\n🧩 Main Logic Flow\\n\\nTelegram Trigger → captures full request\\n\\nFunction → parses message fields\\n\\nGoogle Sheets → checks for availability\\n\\nDecision Node → validates time slot\\n\\nGoogle Sheets → appends confirmed data\\n\\nEmail Node → sends confirmation\\n\\nTelegram → replies with confirmation summary\\n\\n📄 Google Sheets Setup Required\\n\\nResource Info sheet (optional reference)\\n\\nReservation Log sheet with these headers:\\n\\n\\nCopy\\nEdit\\nDate | Name | Email | Resource | Start Time | End Time | Status\\n⚠️ Notes\\n\\nAll data is captured from a single user input (no multi-step flow).\\n\\nTime conflict logic uses date + resource + time slot.\\n\\nYou can rename \\\"Resource\\\" to anything (Room, Coach, Session, etc.)\\n\\n📬 Publisher Support\\nNeed help customizing or deploying this bot?\\n📧 tharwat.elsayed.hamad@gmail.com\",\n\"height\": 1300,\n\"width\": 360\n },\n\"id\": \"53ebf4e3-b3dc-4160-afe7-ecfb7b353337\",\n\"name\": \"Sticky Note\",\n\"type\": \"n8n-nodes-base.stickyNote\",\n\"position\": [\n 368,\n 240\n ],\n\"typeVersion\": 1\n }\n ],\n\"connections\": {\n\"AI Agent\": {\n\"main\": [\n [\n {\n\"node\": \"Telegram\",\n\"type\": \"main\",\n\"index\": 0\n }\n ]\n ]\n },\n\"Prepare Prompt\": {\n\"main\": [\n [\n {\n\"node\": \"AI Agent\",\n\"type\": \"main\",\n\"index\": 0\n }\n ]\n ]\n },\n\"Telegram Trigger\": {\n\"main\": [\n [\n {\n\"node\": \"Prepare Prompt\",\n\"type\": \"main\",\n\"index\": 0\n }\n ]\n ]\n }\n },\n\"settings\": {},\n\"staticData\": null,\n\"meta\": {\n\"templateId\": \"5454\",\n\"templateCredsSetupCompleted\": true\n },\n\"pinData\": {},\n\"versionId\": \"2eaba905-34c8-48ab-9d42-e407710bc212\",\n\"triggerCount\": 0,\n\"shared\": [\n {\n\"updatedAt\": \"2026-01-07T08:59:54.662Z\",\n\"createdAt\": \"2026-01-07T08:59:54.662Z\",\n\"role\": \"workflow:owner\",\n\"workflowId\": \"ZbbOwzCYtGcn5WCD\",\n\"projectId\": \"M2s3vgFF3i2bt62b\"\n }\n ],\n\"tags\": []\n}","fileName":"Automated_reservation_system_with_Telegram__Google_Gemini_AI__and_Google_Sheets.json"}