What This Automation Does
This workflow listens to messages from users and answers with an AI chatbot that remembers past talks and notes saved in Google Docs.
It solves the problem of chatbots forgetting what was said before, making chats smoother and helping save time.
The chatbot replies using previous memories and notes, then updates them in Google Docs.
It also can send answers back through Telegram for easy chatting.
Tools and Services Used
- n8n: The Automation platform where the workflow runs.
- OpenAI GPT-4o-mini: AI language model generating replies.
- LangChain Chat Trigger node: Captures incoming messages.
- LangChain AI Tools Agent node: Runs AI agent logic with memory and tools.
- Window Buffer Memory node: Keeps short-term chat context.
- Google Docs nodes: Reads and updates long-term memories and notes.
- Telegram Bot API: Receives user messages.
- Telegram node: Sends replies back to Telegram chats.
Inputs → Processing → Outputs Explained
Inputs
- User chat messages come in via the LangChain Chat Trigger node.
- Stored long-term memories are fetched from a Google Docs document.
- Previously saved notes are retrieved separately from another Google Docs document.
Processing Steps
- A Merge node combines memories and notes data to give the AI a full context.
- The Aggregate node groups this data for easy use by the AI Tools Agent.
- The AI Tools Agent node uses the chat input plus the retrieved memories and notes to create a relevant answer.
- The Window Buffer Memory node keeps track of recent messages to maintain conversation flow.
- After answering, updated memories and notes are written back to their Google Docs via respective Google Docs Tool nodes.
- An optional OpenAI GPT-4o-mini node produces fallback or enhanced chat replies.
Outputs
- Collected AI answers are sent back to users on Telegram using the Telegram node.
- A Set node formats the final response data for logging or further use.
Beginner Step-by-Step: How to Use This Workflow in n8n Production
Importing and Setup
- Download the workflow file using the Download button on this page.
- Open the n8n editor where the workflow will run.
- Click “Import from File” and select the downloaded workflow file.
- Add API credentials in n8n if missing, such as OpenAI API Key, Google Docs OAuth2, and Telegram bot credentials.
- Update any hardcoded IDs or URLs, like Google Doc URLs, folder IDs, or Telegram chat IDs.
- Check prompts or system messages in the AI nodes and copy-paste any code or URLs if provided.
Testing and Activation
- Send a test message through the input method (e.g., Telegram) to verify the workflow triggers properly.
- Look at the execution logs and ensure the AI generates answers and remembers previous info.
- Once testing succeeds, toggle the workflow status to “active” in n8n to start production use.
For secure, privacy-focused use of this workflow, consider self-host n8n on your own server.
Common Customizations
- Replace Google Docs nodes with Google Sheets or external databases by updating URLs and node settings.
- Make Telegram chat IDs dynamic by pulling them from incoming messages instead of fixed values.
- Edit the system prompt in AI Tools Agent to change chatbot tone or memory rules.
- Change how much recent chat is kept by adjusting the Window Buffer Memory node’s contextWindowLength setting.
- Add extra logging or error-catching nodes to track workflow status.
Troubleshooting Tips
- If Google Docs nodes return no data, check the document URLs and OAuth permissions.
- If messages don’t send in Telegram, verify the bot permissions and chat ID are correct.
- If the AI Tools Agent node gives no answer, confirm system prompt settings plus map chat input properly.
Pre-Production Checklist
- Verify Google Docs URLs and OAuth tokens are active.
- Test webhook triggers before going live.
- Check AI node generates good replies.
- Confirm Telegram node can send test messages.
- Ensure session memory preserves recent chat context.
Summary of Benefits and Outcomes
✓ Saves time by automating replies that remember past talks.
✓ Reduces repetitive questions and misunderstandings.
✓ Stores notes and memories securely in Google Docs.
✓ Works through Telegram for familiar user chatting.
✓ Easy to import, configure, and activate in n8n.
