Laravel Queues Example: Telegram Bot with Self-Dispatching Jobs
Chapters11
The presenter introduces the project idea: a Telegram bingo game and the Q jobs that power its delayed actions.
A practical walkthrough of self-dispatching Laravel queue jobs with a Telegram bingo game, showing delayed dispatch, periodic self-calls, and end conditions.
Summary
Laravel Daily’s video by the creator demonstrates a clever queue pattern built around a Telegram bingo game. The focal point is how to delay a job after a game starts, then have that job self-dispatch at regular intervals to drive the gameplay. The example uses a Filament-admin generated game model, with parameters like join window length and per-number draw intervals to drive the queue logic. The presenter walks through the lifecycle: starting the game, delaying the complete-join period, and then a draw-number job that re-dispatches itself every few seconds until all numbers are drawn or a bingo is claimed. Telegram bot interactions are shown in real time, illustrating how the bot receives new numbers and updates the user’s card. The video also notes practical deployment details: using Laravel Forge to run a database-backed queue worker and ensuring the queue driver and worker process stay healthy. Throughout, the emphasis is on how queue configuration, delayed dispatch, and self-dispatching loops create a responsive, time-based game flow in a real-world scenario. The host also mentions a premium course on Laravel Daily Cues for deeper dives into batching, chaining, and priority jobs. By the end, viewers should understand how to implement a self-dispatching queue pattern and recognize its applicability beyond simple one-off jobs.
Key Takeaways
- Delay a job after game start (e.g., 60 seconds) to model a join period before any numbers are drawn.
- A single job (completeJoinPeriod) is dispatched with a 60-second delay and then triggers a subsequent draw-number job.
- Draw-number jobs run every 5 seconds, sending updates to Telegram and then self-dispatching with a fresh game state from the database.
- End conditions are checked inside the handle method (e.g., drawOrder reaches 75 or a bingo is claimed) to stop the self-dispatch loop.
- Deployment details include running a database-backed queue worker on Forge with a temporary domain for testing.
- Filament admin panel is used to create the game and configure parameters like join duration and per-number draw interval.
- The video highlights how this pattern scales beyond basic dispatching to more complex, time-driven scenarios in Laravel queues.
Who Is This For?
Laravel developers curious about advanced queue patterns, especially self-dispatching jobs with delayed intervals and real-world bot integrations. Great for those building time-based games or long-running workflows.
Notable Quotes
"Hello guys, in this video I want to show you an interesting example of Laravel Q jobs that are delayed with certain rules to play a bingo game with Telegram."
—Opening statement framing the demo and the use of delayed queue jobs.
"So we delay that job. would dispatch that job. But after 60 seconds on the server by Laravel Forge... I have a temporary domain on Forge.com."
—Explains the 60-second delay and the hosting setup used for the test.
"And then self-dispatch. So this is the thing the same job is dispatching itself with delay of 5 seconds with game fresh which is refreshed from the database."
—Describes the core self-dispatching mechanism driving the game loop.
"Every 5 seconds, we see a new number here."
—Notes the periodic draw updates visible in the Telegram bot.
"The main thing I wanted to show you in this video is how you can dispatch a Q job in Laravel with intervals."
—Summarizes the key takeaway about interval-based queue dispatching.
Questions This Video Answers
- How do self-dispatching queue jobs work in Laravel with delayed intervals?
- What are best practices for delaying queue jobs and ensuring reliable retries in Laravel Forge?
- How can I implement a Telegram bot that updates a user card using Laravel queues?
- What setup is required on Filament Admin to configure a game like this with Laravel queues?
- Can Laravel 13 changes affect batching, chaining, or multi-queue patterns demonstrated by this bingo bot?
Laravel QueuesSelf-Dispatching JobsDelayed DispatchTelegram BotFilament AdminLaravel ForgeQueue WorkerDatabase DriverDraw Number LogicBingo Game
Full Transcript
Hello guys, in this video I want to show you an interesting example of Laravel Q jobs that are delayed with certain rules to play a bingo game with Telegram. So this is the game that I played with a bot that I created on Telegram and I will focus in this video on the Q part which is very interesting and you may learn a thing or two how Q jobs may work. So it comes with filament admin panel and part of this project was generated by AI. I will admit. So I create a game on filament admin panel and these parameters are very important.
First, how many seconds do people have on Telegram to join the game that will start and then how many seconds for each bingo number to be drawn. So we create the game. This is without the queue. And then when I start the game, look what happens in the code on filament in the action. There's action to start the game. There's a service. Then it also sends the message to the telegram and I will show you that in a second. But the start method of game life cycle service looks like this. Change the status of the game.
That doesn't really matter what that does. What matters is this complete join period job which comes after 60 seconds for example. And this is exactly the delay thing. So we delay that job. would dispatch that job. But after 60 seconds on the server by Laravel Forge, I have a temporary domain on Forgecom. In the commands or actually in the processes, I have this process which is Q work with database driver which is running successfully on forge. And now look what happens. We start the game. Then I open my Telegram and bingo game bot says a new bingo game has started.
join within 60 seconds. And if I go to bingo gamebot, I can go slash join I think is here. And no game accepting joins right now. That is probably an error. Let's try join here. Does it work? Oh yeah, I've done it in a wrong window. So I join in the main chat group chat of telegram and then personally I get this bingo card in my personal conversation with that bot and then when those 60 seconds and then there's another Q job. So complete join period dispatch and then another draw number job here is dispatched automatically and look what happens here.
draw number job. We will probably get the numbers. Oh, it's already drawn. So, every 5 seconds, we see a new number here. And then in the conversation with bot, I can go slashcard and it will refresh the card with what numbers are drawn and what numbers were correct with my bingo card. And if I follow the rules. So if I go one line or one one column, then I can claim bingo. So these are Telegram commands with this bot. Not valid yet. The game continues. So what happens every 5 seconds. This is another important part of Q job that I wanted to show.
So handle the job of drawing the number. So it draws the number, sends it to Telegram, sends the message, stuff like that. and then selfd dispatch. So this is the thing the same job is dispatching itself with delay of 5 seconds with game fresh which is refreshed from the database with new status. And then there are a few checks in the same handle method. Draw order is 75. It means that all numbers have been drawn. No one claimed bingo. And then the game ends with return. So no more dispatched jobs this way. This is kind of the condition of the end of this self-dispatching life cycle unless someone claims bingo.
Let's try to do that again. /bingo and this is not a cute job anymore. So yeah, bingo. I did win called bingo and won a vertical line. So what happened in this case? It was a web hook of telegram with some validation and then whatever is the command in this case it was /bingo but there are private methods of handle bingo handle join handle everything and handle bingo then checks the database some game details and then starts the transaction with log for updates and then update the bingo claim which may or may not be correct and at the end we have game life cycle service complete which saves the result to leaderboard and logs the events and stuff like that.
So this is outside of Q jobs. So the main thing I wanted to show you in this video is how you can dispatch a Q job in Laravel with intervals. So start some process then dispatch the job in 60 seconds or whatever and then that job after 60 seconds after it's done it dispatches another job which then self-dispatches in a loop every 5 seconds until some condition is met to stop self-dispatching. So I kind of like this example that's why I wanted to show you this in this video because Q jobs with Laravel it's kind of easy to dispatch.
On the surface it's a simple topic. You configure the queue, you launch the queue worker, and then you dispatch a job. But in this case on real scenarios with various parameters of dispatching, it's much more interesting and much more tricky. So I hope you learned something from this video. And I actually have a course on Laravel daily cues in Laravel 12, which I will need to update when Laravel 13 comes out this week probably. But the Q logic will not change in Laravel 13. So if you want to get more information about batching, chaining and multiple cues and priority jobs and stuff like that, I can recommend my course which I will link in the description below for premium members of Laraveville Daily.
And thank you for being a premium member and for supporting my work here on YouTube as well. That's it for this time and see you guys in other
More from Laravel Daily
Get daily recaps from
Laravel Daily
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.









