I have a Telegram bot integrated with n8n and OpenAI’s GPT-4. Initially, the bot handles user interactions using AI, but when certain conditions are met, I need to transfer the conversation to a human agent while keeping everything within the same bot.
could you elaborate? Are you triggering it with something like a specific keyword (e.g., “help”), a special tool or signal, or maybe data matching a certain pattern (like sentiment or a score)? More details would really help me picture how to solve this!
Yes, I’m thinking of setting up a trigger word. For example, if the client writes: “I want to contact a manager,” “I want to chat with a manager,” or if the bot doesn’t know the answer, it will transfer the chat to a manager.
At this point, I’m not sure how to link the chat between the client and AI and then the chat between AI and the manager.
A trigger word like “I want to chat with a manager” is a solid plan! In n8n, use an IF node to spot those phrases (e.g., check if $input.item.json.message.text contains “manager”) or detect when GPT-4’s response confidence dips (e.g., via a score or “I don’t know” output). Then, link it by storing the client’s chat ID from the Telegram Trigger node and passing it to a Telegram node to message your manager’s private chat ID with the convo history—reply through the same bot with the client’s chat ID to keep it seamless.
I also considered this scenario but encountered a problem:
How can 20 clients who simultaneously want to chat with a manager be technically connected to a single manager?
For example, if 20 clients message at the same time, how can their messages be distributed so that one or two managers can communicate with them without confusion?