Créer un bot Telegram intelligent FAQ avec Google Gemini et Supabase

Intermédiaire

Ceci est unSupport Chatbot, AI Chatbotworkflow d'automatisation du domainecontenant 15 nœuds.Utilise principalement des nœuds comme If, Set, Supabase, Telegram, Agent. Créer un bot Telegram intelligent FAQ avec Google Gemini et Supabase

Prérequis
  • URL et Clé API Supabase
  • Token Bot Telegram
  • Clé API Google Gemini
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "meta": {
    "instanceId": "7dc12cc14b4f095cedd2e9549d98eb1aca95241b7bf74a764272500de1b801ec"
  },
  "nodes": [
    {
      "id": "588b691b-8305-4761-89b2-e5e1d2d0699e",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -752,
        656
      ],
      "webhookId": "43dc004e-cda7-4eb6-95b5-61486b0bdf6d",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "2a241435-d6d1-41ba-8432-d44f4d837ef3",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        224,
        1184
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "802a6326-3858-4d8f-9d85-d2e7dc78e80c",
      "name": "Note autocollante",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        496
      ],
      "parameters": {
        "color": 4,
        "height": 288,
        "content": "## STEP 1: RECEIVE USER MESSAGE\nThis workflow starts when a user sends a message to the Telegram bot."
      },
      "typeVersion": 1
    },
    {
      "id": "ab604f07-25fc-4580-af0d-07f26dd120eb",
      "name": "Note autocollante 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        304
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "height": 176,
        "content": "## PATH FOR NEW USERS\nIf the user is not found in the database, this path runs. It creates a new user record and sends a one-time welcome message."
      },
      "typeVersion": 1
    },
    {
      "id": "08891444-00d4-46f0-b539-7aa3298b84ce",
      "name": "Note autocollante 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        496
      ],
      "parameters": {
        "color": 4,
        "width": 336,
        "height": 288,
        "content": "## STEP 2: CHECK IF USER IS NEW\nLooks up the user's Telegram ID in the database (Supabase). The 'If' node then checks if the user was found."
      },
      "typeVersion": 1
    },
    {
      "id": "2ec0132b-6c2f-444c-834c-219ccd785996",
      "name": "Note autocollante 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        1152
      ],
      "parameters": {
        "color": 3,
        "height": 208,
        "content": "## PATH FOR EXISTING USERS\nIf the user already exists, their question is processed by the AI to find an answer."
      },
      "typeVersion": 1
    },
    {
      "id": "d03a256a-7bbf-493c-83bd-4e2fa5738e23",
      "name": "Note autocollante 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        736
      ],
      "parameters": {
        "color": 4,
        "width": 432,
        "height": 336,
        "content": "## STEP 3: GENERATE AI ANSWER\nThe user's question is sent to the Google Gemini model. The AI Agent uses its knowledge base to generate a relevant answer for the FAQ."
      },
      "typeVersion": 1
    },
    {
      "id": "76eaef61-75d6-4ce3-8d11-436fe4e75665",
      "name": "Note autocollante 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        768
      ],
      "parameters": {
        "color": 4,
        "width": 368,
        "height": 272,
        "content": "## STEP 4: SEND AI RESPONSE\nThe final answer generated by the AI is sent back to the user via Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "e3c8e646-890d-45db-b3ef-6e9689352c15",
      "name": "Vérifier si l'utilisateur existe dans Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -528,
        656
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $json.message.chat.id }}"
            }
          ]
        },
        "tableId": "telegram_users",
        "operation": "get"
      },
      "credentials": {
        "supabaseApi": {
          "id": "1pgFwqTKn45GzSXW",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "601fc8b2-886b-436a-a337-3f47e3ba52e5",
      "name": "Route : Nouvel ou utilisateur existant ?",
      "type": "n8n-nodes-base.if",
      "position": [
        -304,
        656
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f4e144b5-d1b4-4752-9ad3-4c85d9e246cb",
              "operator": {
                "type": "number",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ff0ec30f-d2df-402a-a442-cd548102c1dc",
      "name": "Sauvegarder le nouvel utilisateur dans Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        144,
        512
      ],
      "parameters": {
        "tableId": "telegram_users",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "chat_id",
              "fieldValue": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
            }
          ]
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "1pgFwqTKn45GzSXW",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8314f5f5-f8a4-412e-93f7-571ca2efebb5",
      "name": "Envoyer le message de bienvenue (Nouvel utilisateur)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        368,
        512
      ],
      "webhookId": "cf7e2a9e-221f-4e34-a6a7-54d8548d4e61",
      "parameters": {
        "text": "Thank you for trying my project. You can also check out the FAQ or ask any questions you may have. If you want to see the FAQ here, just click this link |/Who_are_you?/What_can_you_do?/Who_created_you?/Are_you_free?",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "9GazysyOQ96DLdaD",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bdffd8ec-9f55-435a-8063-c683ad45ac68",
      "name": "Charger le contexte FAQ pour l'IA",
      "type": "n8n-nodes-base.set",
      "position": [
        -80,
        896
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "994d25f7-381c-4bb2-94c1-cd99e72948dd",
              "name": "faq_context",
              "type": "string",
              "value": "Q: Who are you? A: I am an automated assistant bot created to learn n8n and AI.  Q: What can you do? A: Currently, I can answer basic questions about myself. In the future, I will be developed to do other things.  Q: Who created you? A: I was created by the owner of this n8n server using Google Gemini and n8n.  Q: Are you free? A: Yes, I am a learning project and free to use."
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0f6a6366-543d-4e74-86e1-07c856bd2249",
      "name": "Traiter la question avec Gemini",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        144,
        896
      ],
      "parameters": {
        "text": "=Anda adalah asisten bot yang ramah dan membantu. Tugas Anda adalah menjawab pertanyaan pengguna berdasarkan Konteks FAQ yang diberikan. Jika pertanyaan pengguna tidak bisa dijawab dari konteks, jawab dengan benar pertanyaan tersebut\nJika pengguna bertanya terkait \"apa saja faq nya\" kamu bisa memberi semua pertanyaan yang tertera di faq dengan mengawali pertanyaan dengan / dan hilangkan spasi yang terkandung dalam pertanyaan ganti lah dengan underscore\"_\" \n--- KONTEKS FAQ ---\n{{ $json.faq_context }}\n--- AKHIR KONTEKS ---\n\nPertanyaan Pengguna: {{ $('Telegram Trigger').item.json.message.text }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "5cd2bd5b-fcff-4be9-9341-16e52e65cdc1",
      "name": "Envoyer la réponse IA à l'utilisateur",
      "type": "n8n-nodes-base.telegram",
      "position": [
        640,
        896
      ],
      "webhookId": "b73acbf7-3457-47f2-9ee3-499301eb820e",
      "parameters": {
        "text": "={{ $json.output.replace(/[*_`[\\]()]/g, \"\") }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "9GazysyOQ96DLdaD",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {},
  "connections": {
    "588b691b-8305-4761-89b2-e5e1d2d0699e": {
      "main": [
        [
          {
            "node": "e3c8e646-890d-45db-b3ef-6e9689352c15",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bdffd8ec-9f55-435a-8063-c683ad45ac68": {
      "main": [
        [
          {
            "node": "0f6a6366-543d-4e74-86e1-07c856bd2249",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2a241435-d6d1-41ba-8432-d44f4d837ef3": {
      "ai_languageModel": [
        [
          {
            "node": "0f6a6366-543d-4e74-86e1-07c856bd2249",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "ff0ec30f-d2df-402a-a442-cd548102c1dc": {
      "main": [
        [
          {
            "node": "8314f5f5-f8a4-412e-93f7-571ca2efebb5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0f6a6366-543d-4e74-86e1-07c856bd2249": {
      "main": [
        [
          {
            "node": "5cd2bd5b-fcff-4be9-9341-16e52e65cdc1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "601fc8b2-886b-436a-a337-3f47e3ba52e5": {
      "main": [
        [
          {
            "node": "ff0ec30f-d2df-402a-a442-cd548102c1dc",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "bdffd8ec-9f55-435a-8063-c683ad45ac68",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e3c8e646-890d-45db-b3ef-6e9689352c15": {
      "main": [
        [
          {
            "node": "601fc8b2-886b-436a-a337-3f47e3ba52e5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire - Chatbot de support, Chatbot IA

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds15
Catégorie2
Types de nœuds8
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
Mohammad Jibril

Mohammad Jibril

@muimsa

Hi i am an student, major informatic engineering

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34