The following sections provide details about how AppSheet stores, triggers, executes and retries bots with scheduled events.
Storing bots with scheduled events
Each bot with a scheduled event is stored as a record in a SQL database. Each record contains the following information:
Name of the application containing the bot with a scheduled event
Name of the bot with a scheduled event
Date and time at which the scheduled event should be triggered
Triggering bots with scheduled events
The Schedule Service triggers the bot with a scheduled event at the appropriate time. It does this by reading the records from the SQL database and looking for bots with scheduled events that are due to be triggered.
When the Schedule Service finds a bot with a scheduled event that is due to be triggered, it issues an
HTTP POST request to the AppSheet service to invoke the scheduled event. The
POST request contains the names of the application and bot with a scheduled event. This allows the AppSheet Service to find and execute the scheduled event.
The Schedule Service then waits for a timeout period of up to four minutes for the scheduled event to complete.
Executing bots with scheduled events
The AppSheet service is responsible for executing the bot with a scheduled event. When it receives the
POST from the Schedule Service it uses the names of the application and bot with a scheduled event contained in the
HTTP POST to retrieve the scheduled event and begin executing it.
The AppSheet service records the time the scheduled event begins executing. Periodically, the AppSheet service checks to see if the scheduled event is taking too long to execute. If the total execution time exceeds four minutes, the AppSheet service aborts its execution.
When the bot with a scheduled event completes, the AppSheet service responds to the
HTTP POST request and indicates whether the scheduled event completed successfully.
Retrying bots with scheduled events
While the AppSheet service is executing the bot with a scheduled event, the Schedule Service is waiting for the AppSheet service to complete the scheduled event and respond to the
If the bot with a scheduled event does not complete within four minutes, the Schedule Service assumes that the scheduled event failed for some reason. A bot with a scheduled event can fail for several reasons including:
The bot with a scheduled event may be complicated and take a long time to execute. As a result, the bot may exceed the AppSheet service's four-minute timeout period.
The bot with a scheduled event may be delayed because it is competing with other bots that are scheduled to run at the same time. It is common to schedule bots with scheduled events to run exactly on the hour. This can cause a flood of bots to fire on exactly the hour and result in one bot waiting for other competing bots to complete. This can result in a timeout because the bot is not initiated immediately and does not complete within the Schedule Service's four-minute timeout period. You can mitigate this by scheduling your bot to run at least a few minutes before or after the hour.
The bot with a scheduled event may be executing on an AppSheet server that is restarted for some reason. This can also cause a timeout.
When the Schedule Service detects that the bot with a scheduled event has not completed within the four-minute timeout period, it will retry its execution up to three additional times. If the Audit History indicates that the bot with a scheduled event is being invoked at four-minute intervals, it is likely that the Schedule Service is retrying its execution.