AI-Powered Conversational Survey Bot using Telegram and Google Sheets - n8n Workflow

Build a dynamic product satisfaction survey using this complex n8n workflow. It integrates Telegram, Google Sheets, Redis, and OpenAI/LangChain agents to ask follow-up questions for deeper insights.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Market researchers needing high-quality, conversational survey data.
Businesses looking for advanced n8n templates integrating AI and chat platforms.
Developers specializing in building structured, stateful chatbot experiences using the n8n node ecosystem.
Users wanting to leverage Redis caching for fast session management in an n8n workflow.

Overview

Traditional surveys often fail to capture deep qualitative data. This sophisticated n8n workflow solves this by creating an AI-augmented survey bot. The core value of this n8n automation is its ability to seamlessly transition between structured questions (pulled from Google Sheets) and dynamic, open-ended conversational follow-ups powered by an AI agent (GPT-4o-mini). By using a Telegram n8n trigger, it provides a familiar chat environment for users. All conversation history and responses are accurately logged in a designated Google Sheets document, providing deep, segmented feedback without requiring manual intervention, making this one of the most powerful n8n templates for feedback collection. This structured approach ensures a predictable user journey while still leveraging advanced AI capabilities within the n8n node environment.

How it Works

The n8n workflow begins when the Telegram Trigger n8n node receives a message.


  1. Initialization: The n8n workflow first sets global variables (Set Variables1) for the Google Sheet ID and creates a unique Redis cache key based on the user's session ID.

  2. Message Routing: The flow checks if the user is issuing a command (/start, /next) via the Message Type1 n8n node.

  3. New Session: If the /start command is received, a new row for the user is created in Google Sheets (Create Record1), the session state is initialized in Redis (Start Session1), and a welcome message is sent via Telegram. This step ensures persistence for the n8n workflow.

  4. Data Processing & Classification: For a normal user message, the n8n workflow retrieves the current state and the previous bot message. It uses a LangChain Text Classifier n8n node (powered by an OpenAI model) to analyze the user's reply and determine if the response requires deeper exploration (AI follow-up) or if the n8n workflow should skip to the next structured question.

  5. AI Conversation Loop: If a follow-up is required, the Interview Agent1 n8n node uses Redis chat memory to maintain context and generates an insightful, probing follow-up question. This conversational exchange (User response + Agent response) is then appended to the correct cell in Google Sheets using an HTTP Request n8n node.

  6. Next Question Progression: If the classifier determines no follow-up is necessary, the n8n workflow calculates the next structured question index by reading the questions from Google Sheets columns. The Redis state is updated (Increment Index1).

  7. Completion Check: An If n8n node checks if the survey is complete. If so, a final completion message is sent. Otherwise, the agent memory is reset (Reset Agent Memory1) to ensure the agent focuses solely on the next structured question, which is then sent to the user via a Telegram n8n node.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance. This provides the structure for your automated survey.

  2. Credentials: Set up the required credentials:

Telegram: Configure a Telegram API credential linked to your bot. The Telegram Trigger n8n node must be active to initiate the survey.
Google Sheets: Authenticate a Google Sheets OAuth2 API account with write access to your survey sheet.
OpenAI: Set up an OpenAI credential for the AI Agent and Classifier nodes.
Redis: Configure a Redis credential for session state and chat memory management.

  1. Configuration: Update the Set Variables1 n8n node with your specific settings:

gsheetId: The ID of your Google Sheet containing the survey questions (questions must be defined in the column headers of the first sheet).
title: The title of your survey.

  1. Activation: Once all credentials and configurations are complete, activate the n8n workflow. You have successfully implemented this complex n8n template. Start the survey by sending /start to your Telegram bot.

Node Details

This n8n workflow utilizes a combination of core and specialized nodes:

Telegram Trigger (n8n trigger): The critical starting n8n node, initiating the flow upon receiving a user message.
Key Configuration: Listens for new message updates.
Set Variables1 (n8n node): Defines configuration parameters for the entire n8n workflow.
Key Configuration: Stores gsheetId, title, and constructs the dynamic Redis cacheKey.
Google Sheets (n8n node): Interacts with the survey data sheet.
Function: Used to create user rows (Create Record1/2) and retrieve all column headers (Get Columns1) which serve as the predefined survey questions.
Redis (n8n node): Used extensively for state tracking and session management.
Function: Stores the currentquestionidx to manage where the user is in the n8n workflow progression.
LangChain Text Classifier (n8n node): Should Follow Up?1 uses an OpenAI model (gpt-4o-mini) to analyze user input.
Function: Classifies if the user's response requires shouldaskfollowupquestions or shouldnotaskfollowup_questions based on predefined category descriptions.
LangChain Agent (n8n node): Interview Agent1 powers the conversational depth.
Function: Generates dynamic, context-aware follow-up questions to elicit deeper insights, leveraging prompt engineering and Redis memory.
LangChain Memory Manager (n8n node): Reset Agent Memory1 ensures conversational focus.
Function: Clears the chat history when moving from one structured question to the next, preventing the AI agent from getting distracted by previous topics.
HTTP Request (n8n node): Update Answer2/3 uses the Google Sheets API directly.
Function: Updates specific cells in the Google Sheet by appending the user's answer and the AI's response, maintaining a conversation log within the data sheet.

Related n8n Workflows

Free

Nodes: 15 Nodes
Updated: December 26 2025
View all
Created by
Jimleuk
Jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at [email protected] LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

Featured*