Quick overview
This workflow turns a Google Docs knowledge base into a Telegram customer support chatbot using Anthropic Claude, logs each Q&A to Google Sheets, and replies back to the user in Telegram.
How it works
- Triggers when a new Telegram message is received by your bot.
- Fetches the latest content from a specified Google Docs document to use as the knowledge source.
- Combines today’s date, the Google Docs text, and the user’s Telegram question into a single prompt.
- Sends the prompt to an Anthropic Claude chat model via an AI Agent with conversation memory keyed by Telegram chat ID.
- Generates a timestamp, then records the date, question, answer, chat ID, and username to a Google Sheets spreadsheet.
- Cleans the AI response text (for example, flattening Markdown links) and sends the final answer back to the user in Telegram.
Setup
- Create a Telegram bot with BotFather, add your Telegram credentials in n8n, and start a chat with the bot so it can receive messages.
- Add Google Docs OAuth2 credentials and replace the document URL with your own knowledge base document.
- Add an Anthropic API credential and confirm the selected Claude model is available for your account.
- Add Google Sheets OAuth2 credentials, set the target spreadsheet, and ensure it has columns for the logged fields (date/question/answer/chatid/username) as mapped in the workflow.