How to Switch Chat from AI to a Human Agent in Telegram Bot + n8n + GPT-4o?

Hi everyone,

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.

How can this be implemented?

Thanks!

update:

  • n8n version: 1.80.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via: n8n cloud

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

Could you share your workflow, hit the three dots in the top right, then download. Paste the contents inside a preformatted text box : </>

1 Like

Hi. I shared my workflow.

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!

1 Like

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.

1 Like

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?

The very basic simple solution would be using chat ID along with message, (but it will still be confusing)

A wait till one conversation completes approach can be implemented.

1 Like

@8705e8767627 If you like this i would kindly ask you to Mark the before comment as solution,
Thank you very much

Thank you for the suggestion, I appreciate it. Before marking it as a solution, I want to hear the opinions of other experienced users.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.