Using a Bot Heartbeat

Using a Bot Heartbeat

The bot heartbeat option can be enabled from the General tab in bots. Bot heartbeat option is only available on bots and service bots.

 

image-20250221-071717.png

 

The bot heartbeat time needs to be entered by the user; by default it is 15 mins. It can be between 1 - 60 mins. A 3 mins buffer time is added to the bot heartbeat cover up for any delays caused by the infrastructure

The bot heartbeat time tells how often a heartbeat needs to be sent by the bot from within the bot's script. for example, if we set it to 4 then the bot will need to send a heartbeat atleast once every 4 mins otherwise the bot will be terminated. The bot will not be terminated instantly after 4 mins because we are adding a 3 mins buffer time to it. but the user does need to send a bot heartbeat every 4 mins.

 

How to send bot Heartbeats: -

A user can send heartbeats using the Send-RbBotHeartbeat cmdlet or using $Readi.Bot.Heartbeat.Send() method available in the Readi object. They need to sprinkle these in their code to stop the bot from dying. If the bot's execution is halted for any reason, then no heartbeat will be sent, and the bot will be terminated.

It’s up to the user how often they send heartbeats in their script, but they should send at least one within the interval they have set.

Ex: -

$userData = @(1..10) foreach($data in $userData) { $Readi.Bot.Heartbeat.Send() Send-RbBotHeartbeat write-debug "heartbeat sent {$data}" if ($data -eq 7) { start-sleep 300 } }

Execution logs -

image-20250221-073858.png

 

If the Alert on Bot Failure option is checked, then an email is sent as well to email id provided in Send Alerts To Option or if not provided the owner of the bot.

image-20250221-074408.png