What you're describing is a middleware layer between your API and Telegram, and the right shape depends on one fork.
If a single official bot works for you, it's simple. Set a webhook on a Telegram bot, every incoming message hits your endpoint, you call your AI API and send the reply back through the Bot API. Clean and within ToS, but users have to start the bot first and it clearly reads as a bot.
If you want it to feel like real one on one chats from normal accounts, the CupidBot style, that's the MTProto route. You run user sessions through Telethon or Pyrogram, a listener catches each incoming DM, passes the thread to your API for the reply, and sends it back from that account. There's no clean off the shelf panel for this at any real scale, so most people running it built a custom middleware: session storage, a message router to your API, a sender, plus account rotation and pacing so the accounts don't get limited.
So the question that decides everything is whether you're running an official bot or human style accounts. The first is a weekend webhook, the second is a managed account layer your API plugs into.
Best,
Floqal