# Natural Language Processing - Feature Added! ๐ŸŽ‰ ## โœ… What Changed The Telegram bot now understands **natural language** - no need for commands! ### Before (Commands Only) ``` /deck add Review reports by Friday /email search train ticket /ask What's the weather? ``` ### After (Natural Language) ``` add a deck called cleaning tell me when my train leaves today what's the weather like? create a task to call mom tomorrow find my invoice from last week ``` ## ๐Ÿง  How It Works 1. **Message received** โ†’ Bot checks if it starts with `/` 2. **If no `/`** โ†’ Sends to OpenAI for intent classification 3. **AI analyzes** and returns one of: - `deck_add` - Create task in Nextcloud Deck - `email_search` - Search emails via IMAP - `general_chat` - Answer question with AI 4. **Converts to command format** and routes to appropriate workflow 5. **Processes normally** like a slash command ## ๐Ÿ“ Example Inputs ### Deck Tasks ``` add a deck called cleaning create task review quarterly reports remind me to call the dentist tomorrow add card: finish the presentation by Friday task for รผbermorgen: grocery shopping ``` ### Email Search ``` tell me when my train leaves today find my train ticket search for invoice from November show me emails about the project where's my booking confirmation? ``` ### General Chat ``` what's the weather like? explain quantum computing how do I convert Celsius to Fahrenheit? tell me a joke what's 15% of 250? ``` ## ๐Ÿ”ง Technical Details **AI Prompt** classifies intent with examples: - Extracts task name, due date for deck commands - Extracts search query for email commands - Passes full question for general chat - Supports German dates (morgen, รผbermorgen) - Returns structured JSON for routing **OpenAI Model:** `gpt-4o-mini` (fast, cost-effective) **Temperature:** 0.3 (focused, consistent) **Max Tokens:** 150 (quick classification) ## ๐Ÿš€ Usage Just chat naturally with your bot: โœ… **"add a deck called cleaning"** โ†’ Creates Nextcloud Deck card with title "cleaning" โœ… **"tell me when my train leaves today"** โ†’ Searches emails for "train" and shows results โœ… **"what's the capital of Germany?"** โ†’ AI answers: "Berlin" ## โšก Next Steps 1. **Activate workflow** in n8n (already imported) 2. **Test in Telegram** - just send a message without `/` 3. **Monitor** first few uses to verify classification accuracy ## ๐Ÿ“Š Classification Examples ```json // Input: "add a deck called cleaning" { "intent": "deck_add", "task": "cleaning", "duedate": null } // Input: "find my train ticket" { "intent": "email_search", "query": "train ticket" } // Input: "what's the weather?" { "intent": "general_chat", "question": "what's the weather?" } ``` ## ๐Ÿ› Fallback Behavior If AI classification fails or is unclear: - Defaults to `general_chat` - Sends original message to OpenAI - User still gets a helpful response --- **Updated:** 2025-12-02 **Workflow:** telegram-receiver.json (re-imported) **Status:** โœ… Ready to use - activate in n8n UI