← All N8N workflows
Messaging & emailHTTP RequestIfMergeSupabaseTelegram

AI Telegram Bot with Supabase memory

Configured with HTTP Request, Supabase, Telegram, Telegram Trigger. Review the connections and setup before adapting this template.

Workflow preview
TriggerGet New MessageTelegram TriggerWeb / APIOPENAI - Create threadHTTP RequestData storeCreate UserSupabaseTransformMergeMergeWeb / APIOPENAI - Send messageHTTP RequestWeb / APIOPENAI - Run assistantHTTP RequestWeb / APIOPENAI - Get messagesHTTP RequestMessagingSend Message to UserTelegramRoutingIf User existsIfData storeFind UserSupabase

Node categories in this workflow

  • Trigger
  • Web / API
  • Data store
  • Transform
  • Messaging
  • Routing

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Get New MessageTriggerTelegram TriggerSee node parameters
OPENAI - Create threadWeb / APIHTTP RequestPOST
Create UserData storeSupabaseSee node parameters
MergeTransformMergeSee node parameters
OPENAI - Send messageWeb / APIHTTP RequestPOST
OPENAI - Run assistantWeb / APIHTTP RequestPOST
OPENAI - Get messagesWeb / APIHTTP RequestSee node parameters
Send Message to UserMessagingTelegramSee node parameters
If User existsRoutingIfSee node parameters
Find UserData storeSupabasegetAll

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • openAiApi
  • supabaseApi
  • telegramApi

Workflow notes

Sticky Note1

SQL query to create table in Supabase:

create table
  public.telegram_users (
    id uuid not null default gen_random_uuid (),
    date_created timestamp with time zone not null default (now() at time zone 'utc'::text),
    telegram_id bigint null,
    openai_thread_id text null,
    constraint telegram_users_pkey primary key (id)
  ) tablespace pg_default;
Sticky Note2

Create assistant in OpenAI.

Specify own assistant id here

Sticky Note3

Create own Telegram bot in Botfather bot

Sticky Note4

Create table in Supabase with SQL query

Set up steps

Set up steps

  1. Create a Telegram Bot using the Botfather and obtain the bot token.
  2. Set up Supabase:
    1. Create a new project and generate a SUPABASE_URL and SUPABASE_KEY.
    2. Create a new table named telegram_users with the following SQL query:
create table
  public.telegram_users (
    id uuid not null default gen_random_uuid (),
    date_created timestamp with time zone not null default (now() at time zone 'utc'::text),
    telegram_id bigint null,
    openai_thread_id text null,
    constraint telegram_users_pkey primary key (id)
  ) tablespace pg_default;
  1. OpenAI Setup:
    1. Create an OpenAI assistant and obtain the OPENAI_API_KEY.
    2. Customize your assistant’s personality or use cases according to your requirements.
  2. Environment Configuration in n8n:
    1. Configure the Telegram, Supabase, and OpenAI nodes with the appropriate credentials.
    2. Set up triggers for receiving messages and handling conversation logic.
    3. Set up OpenAI assistant ID in "++OPENAI - Run assistant++" node.
AI Telegram Bot with Supabase memory

AI Telegram Bot with Supabase memory

Made by Mark Shcherbakov from community 5minAI

Many simple chatbots lack context awareness and user memory. This workflow solves that by integrating Supabase to keep track of user sessions (via telegram_id and openai_thread_id), allowing the bot to maintain continuity and context in conversations, leading to a more human-like and engaging experience.

This Telegram bot template connects with OpenAI to answer user queries while storing and retrieving user information from a Supabase database. The memory component ensures that the bot can reference past interactions, making it suitable for use cases such as customer support, virtual assistants, or any application where context retention is crucial.

... or watch set up video [5 min]

... or watch set up video [5 min]

AI Telegram Bot with Supabase memory

AI Telegram Bot with Supabase memory

Purpose and structure

This folder contains the AI Telegram Bot with Supabase memory workflow. Its executable nodes use httpRequest, if, merge, supabase, telegram, telegramTrigger. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Get New Message

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Http/0594_HTTP_Telegram_Create_Webhook.json MIT; preserve source notices.

More in Messaging & email