How it works

1. A message arrives on your Telegram bot. 2. A condition checks whether the message carries a document. 3. If it does, the bot looks up the file and downloads it. 4. An AI Tools step reads the PDF and returns its text and page count. 5. The text is saved as a record in your Pinecone index (Pinecone creates the embedding from the text). 6. The bot replies with how many pages were saved. 7. If there is no document, Pinecone is searched for the passages closest to the question. 8. An AI Agent (OpenAI) answers using only those passages, remembers the conversation per chat, and writes in Telegram HTML. 9. The answer is sent to the same chat.