Erstellung eines intelligenten FAQ-Telegram-Bots mit Google Gemini und Supabase

Fortgeschritten

Dies ist ein Support Chatbot, AI Chatbot-Bereich Automatisierungsworkflow mit 15 Nodes. Hauptsächlich werden If, Set, Supabase, Telegram, Agent und andere Nodes verwendet. Erstelle einen intelligenten FAQ-Telegram-Bot mit Google Gemini und Supabase

Voraussetzungen
  • Supabase URL und API Key
  • Telegram Bot Token
  • Google Gemini API Key
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "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": "Notiz",
      "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": "Notiz1",
      "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": "Notiz2",
      "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": "Notiz3",
      "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": "Notiz4",
      "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": "Notiz5",
      "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": "Prüfen, ob Benutzer in Supabase existiert",
      "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: Neuer oder bestehender Benutzer?",
      "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": "Neuen Benutzer in Supabase speichern",
      "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": "Willkommensnachricht senden (Neuer Benutzer)",
      "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": "FAQ-Kontext für KI laden",
      "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": "Frage mit Gemini verarbeiten",
      "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": "KI-Antwort an Benutzer senden",
      "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
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - Support-Chatbot, KI-Chatbot

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes15
Kategorie2
Node-Typen8
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
Mohammad Jibril

Mohammad Jibril

@muimsa

Hi i am an student, major informatic engineering

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34