Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

Free with an account

This part is free. Sign in or create an account to watch it.

Sign up
Foundations · 1b

Put it on Telegram

The assistant moves to your phone. The bot is a loop: it asks Telegram "anything new, from number N on?", and the question waits; each message gets one fresh agent run and one reply, then N moves past it, and N is the only thing the bot keeps. Seven stops follow one real message: the loop in main → a getUpdates request held for up to 30 seconds → the real JSON when the message arrives → three small Pydantic classes turn it into an Update and offset moves on by one → await agent.run, where every run starts with an empty history → sendMessage sends only Reply.text → asking again with the new offset, which confirms the old update. Then the recorded session shows three things: delete the offset line and one message is answered three times; a follow-up "make it 4pm" reaches the model alone; a message sent while the bot is off is answered as soon as it restarts. Telegram is called with plain httpx, no bot library.

Source code shown in the videos is quoted from pydantic/pydantic-ai (MIT licence), pinned at v2.71.0. This course is not affiliated with or endorsed by Pydantic; the explanations and assignments are original. Course code and assignments · pydantic/pydantic-ai at v2.71.0 · License

Up next2a · Read the calendar: the first tool→