Skip to main content

Create a Telegram bot with Mistral Nemotron AI and conversation memory

Workflow preview

Workflow preview
100%
Create a Telegram bot with Mistral Nemotron AI and conversation memory preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Create a Telegram Bot with Mistral AI and Conversation Memory A sophisticated Telegram bot that provides AI powered responses with conversation memory. This template demonstrates how to integrat...

Best for

  • Support Chatbot automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.telegramtrigger, n8n-nodes-base.if, n8n-nodes-base.telegram, n8n-nodes-base.code, n8n-nodes-base.httprequest

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Ajith joseph .

Original n8n.io source

1.1 Workflow description

Title
Create a Telegram bot with Mistral Nemotron AI and conversation memory
Workflow name
Create a Telegram bot with Mistral Nemotron AI and conversation memory

πŸ€– Create a Telegram Bot with Mistral AI and Conversation Memory

A sophisticated Telegram bot that provides AI-powered responses with conversation memory. This template demonstrates how to integrate any AI API service with Telegram, making it easy to swap between different AI providers like OpenAI, Anthropic, Google AI, or any other API-based AI model.

πŸ”§ How it works

The workflow creates an intelligent Telegram bot that:

  • πŸ’¬ Maintains conversation history for each user
  • 🧠 Provides contextual AI responses using any AI API service
  • πŸ“± Handles different message types and commands
  • πŸ”„ Manages chat sessions with clear functionality
  • πŸ”Œ Easily adaptable to any AI provider (OpenAI, Anthropic, Google AI, etc.)

βš™οΈ Set up steps

πŸ“‹ Prerequisites

  • πŸ€– Telegram Bot Token (from @BotFather)
  • πŸ”‘ AI API Key (from any AI service provider)
  • πŸš€ n8n instance with webhook capability

πŸ› οΈ Configuration Steps

  1. πŸ€– Create Telegram Bot

    • Message @BotFather on Telegram
    • Create new bot with /newbot command
    • Save the bot token for credentials setup
  2. 🧠 Choose Your AI Provider

    • OpenAI: Get API key from OpenAI platform
    • Anthropic: Sign up for Claude API access
    • Google AI: Get Gemini API key
    • NVIDIA: Access LLaMA models
    • Hugging Face: Use inference API
    • Any other AI API service
  3. πŸ” Set up Credentials in n8n

    • Add Telegram API credentials with your bot token
    • Add Bearer Auth/API Key credentials for your chosen AI service
    • Test both connections
  4. πŸš€ Deploy Workflow

    • Import the workflow JSON
    • Customize the AI API call (see customization section)
    • Activate the workflow
    • Set webhook URL in Telegram bot settings

✨ Features

πŸš€ Core Functionality

  • πŸ“¨ Smart Message Routing: Automatically categorizes incoming messages (commands, text, non-text)
  • 🧠 Conversation Memory: Maintains chat history for each user (last 10 messages)
  • πŸ€– AI-Powered Responses: Integrates with any AI API service for intelligent replies
  • ⚑ Command Support: Built-in /start and /clear commands

πŸ“± Message Types Handled

  • πŸ’¬ Text Messages: Processed through AI model with context
  • πŸ”§ Commands: Special handling for bot commands
  • ❌ Non-text Messages: Polite error message for unsupported content

πŸ’Ύ Memory Management

  • πŸ‘€ User-specific chat history storage
  • πŸ”„ Automatic history trimming (keeps last 10 messages)
  • 🌐 Global state management across workflow executions

πŸ€– Bot Commands

  • /start 🎯 - Welcome message with bot introduction
  • /clear πŸ—‘οΈ - Clears conversation history for fresh start
  • Regular text πŸ’¬ - Processed by AI with conversation context

πŸ”§ Technical Details

πŸ—οΈ Workflow Structure

  1. πŸ“‘ Telegram Trigger - Receives all incoming messages
  2. πŸ”€ Message Filtering - Routes messages based on type/content
  3. πŸ’Ύ History Management - Maintains conversation context
  4. 🧠 AI Processing - Generates intelligent responses
  5. πŸ“€ Response Delivery - Sends formatted replies back to user

πŸ€– AI API Integration (Customizable)

Current Example (NVIDIA):

  • Model: mistralai/mistral-nemotron
  • Temperature: 0.6 (balanced creativity)
  • Max tokens: 4096
  • Response limit: Under 200 words

πŸ”„ Easy to Replace with Any AI Service:

OpenAI Example:

{
  "model": "gpt-4",
  "messages": [...],
  "temperature": 0.7,
  "max_tokens": 1000
}

Anthropic Claude Example:

{
  "model": "claude-3-sonnet-20240229",
  "messages": [...],
  "max_tokens": 1000
}

Google Gemini Example:

{
  "contents": [...],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 1000
  }
}

πŸ›‘οΈ Error Handling

  • ❌ Non-text message detection and appropriate responses
  • πŸ”§ API failure handling
  • ⚠️ Invalid command processing

🎨 Customization Options

πŸ€– AI Provider Switching

To use a different AI service, modify the "NVIDIA LLaMA Chat Model" node:

  1. πŸ“ Change the URL in HTTP Request node
  2. πŸ”§ Update the request body format in "Prepare API Request" node
  3. πŸ” Update authentication method if needed
  4. πŸ“Š Adjust response parsing in "Save AI Response to History" node

🧠 AI Behavior

  • πŸ“ Modify system prompt in "Prepare API Request" node
  • 🌑️ Adjust temperature and response parameters
  • πŸ“ Change response length limits
  • 🎯 Customize model-specific parameters

πŸ’Ύ Memory Settings

  • πŸ“Š Adjust history length (currently 10 messages)
  • πŸ‘€ Modify user identification logic
  • πŸ—„οΈ Customize data persistence approach

🎭 Bot Personality

  • πŸŽ‰ Update welcome message content
  • ⚠️ Customize error messages and responses
  • βž• Add new command handlers

πŸ’‘ Use Cases

  • 🎧 Customer Support: Automated first-line support with context awareness
  • πŸ“š Educational Assistant: Homework help and learning support
  • πŸ‘₯ Personal AI Companion: General conversation and assistance
  • πŸ’Ό Business Assistant: FAQ handling and information retrieval
  • πŸ”¬ AI API Testing: Perfect template for testing different AI services
  • πŸš€ Prototype Development: Quick AI chatbot prototyping

πŸ“ Notes

  • 🌐 Requires active n8n instance for webhook handling
  • πŸ’° AI API usage may have rate limits and costs (varies by provider)
  • πŸ’Ύ Bot memory persists across workflow restarts
  • πŸ‘₯ Supports multiple concurrent users with separate histories
  • πŸ”„ Template is provider-agnostic - easily switch between AI services
  • πŸ› οΈ Perfect starting point for any AI-powered Telegram bot project

πŸ”§ Popular AI Services You Can Use

Provider Model Examples API Endpoint Style
🟒 OpenAI GPT-4, GPT-3.5 https://api.openai.com/v1/chat/completions
πŸ”΅ Anthropic Claude 3 Opus, Sonnet https://api.anthropic.com/v1/messages
πŸ”΄ Google Gemini Pro, Gemini Flash https://generativelanguage.googleapis.com/v1beta/models/
🟑 NVIDIA LLaMA, Mistral https://integrate.api.nvidia.com/v1/chat/completions
🟠 Hugging Face Various OSS models https://api-inference.huggingface.co/models/
🟣 Cohere Command, Generate https://api.cohere.ai/v1/generate

Simply replace the HTTP Request node configuration to switch providers!

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Telegram Trigger

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Check Start Command

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 5 - Check Clear Command

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 6 - Filter Regular Messages

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 7 - Check Non-Text Messages

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 8 - Send Welcome Message

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.1

Block 9 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Clear Chat History

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 11 - Send Clear Confirmation

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.1

Block 12 - Manage Chat History

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 13 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Prepare API Request

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - NVIDIA LLaMA Chat Model

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.1

Block 16 - Save AI Response to History

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Send AI Response

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.1

Block 18 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Send Error Message

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.1

Block 20 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Create a Telegram bot with Mistral Nemotron AI and conversation memory
Complexity advanced
Nodes 20
Categories Support Chatbot, AI Chatbot
Author Ajith joseph
Published 28 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/5438/5438.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Create a Telegram bot with Mistral Nemotron AI and conversation memory do?

Create a Telegram Bot with Mistral AI and Conversation Memory A sophisticated Telegram bot that provides AI powered responses with conversation memory. This template demonstrates how to integrat...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI Chatbot use case.