Files
mortimer/NATURAL_LANGUAGE_UPDATE.md
2025-12-19 09:54:03 +01:00

3.0 KiB

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
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

// 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