Product
Continuing a session automatically
On this page you can learn how an Open session can be automatically resumed, so that the Ask agent can carry on with the work on its own.
Learn this page in your AI agent
Open it in Claude or ChatGPT and ask anything about it, or copy the Markdown and use it in any AI agent.
Three ways a session continues automatically
A workflow can describe work that needs its session to continue automatically. A workflow that acts as a customer support agent, for example, should continue every time the customer sends an email, and a workflow that chases a contractor should continue every week until there is a reply. An Open session is waiting for its next run, and it continues on its own in three ways: on an event, on auto-run, or through the API, each explained below. A session in Done is closed and ignores all three until you reopen it, as the Sessions page explains.
Webhook events
Picture: a source’s Webhook events tab, listing each event the source offers with the number of filters it has.
The Ask agent can subscribe a session to the webhook events of the sources selected for executing the workflow, with its Event subscriptions tool. Once subscribed, the moment the event happens in the connected tool, a reply on WhatsApp from one customer’s number for example, the session continues automatically. The full details of the event are added to the session, so the Ask agent has the context of exactly what happened in the tool. Only an Open session is resumed this way. To tell the Ask agent what to subscribe to, use the Events section of the PROCESS.md.
Example
- Requirement
- The workflow asks the Ask agent to answer the customer’s WhatsApp reply the moment it arrives.
- Solution
- Subscribe the session to the WhatsApp source’s message received event, filtered to that customer’s number, in the Events section of the PROCESS.md. The session then waits in Open. When the reply lands, the event resumes the session and the Ask agent answers it. Auto-run is not needed.
Auto-run
Picture: the Auto-run until completion dropdown of the message box, with the options Off, Hourly, Daily, Weekly and Monthly.
Auto-run re-runs a session on a schedule until every task is done. The Ask agent has no scheduler of its own to decide exactly when the next run starts, so auto-run, or subscribing to events, is how a workflow automatically continues.
- Where to switch it on.
- When creating a workflow, choose it in the Auto-run until completion dropdown. It applies to every session the workflow opens.
- When starting a workflow manually, choose it with the Auto-run: dropdown button in the message box. It applies to that run.
- In an open session, choose it with the same dropdown button in its title bar. It applies to that session, and this is also where you turn it off.
- How often it runs. Askpilot counts the gap from the session’s last run, not from the moment you switch auto-run on, and every run restarts the count, a message you send included. Run times are rounded up to the next ten minutes before the gap is counted. If the last run is already older than the gap when you switch auto-run on, the next run comes straight away.
- Hourly. An hour after the last run. A session that last ran at 11:36 is counted from 11:40 and runs again at 12:40.
- Daily. A day after the last run. A session that last ran at 10:00 runs next at 10:00 the following day, even if you switched auto-run on at 15:00.
- Weekly. A week after the last run. A session that last ran on Monday at 09:00 runs again the next Monday at 09:00.
- Monthly. A month after the last run. A session that last ran on the 3rd at 09:00 runs again on the 3rd of the next month at 09:00.
- What stops it.
- A run that needs your input pauses auto-run until you reply.
- A session in Done is not re-run.
Subscribed events do not stop it: a session can re-run on its schedule and also resume the moment an event arrives.
Example
- Requirement
- The workflow asks the Ask agent to send the customer a follow-up message in two days.
- Solution
- Set auto-run to Daily. On every run the Ask agent checks whether two days have passed since the last message. If they have, it sends the follow-up. If not, it stops and waits for the next auto-run to check again.
Through the API
Trigger a workflow in an existing session from your own system via the API. Learn more at Start workflows through the API.
How auto-run and webhook events work together
Auto-run and events work side by side. A session can re-run on its schedule and also resume the moment an event arrives. Use events for anything that depends on someone else acting, and auto-run for anything that depends on time passing.
Example
- Requirement
- The workflow asks the Ask agent to chase a contractor on WhatsApp every week until they confirm a date for the repair, and to tell the tenant as soon as the contractor replies.
- Solution
- Set auto-run to Weekly, so on each run the Ask agent sends the next chase if there is still no reply. Subscribe the session to the WhatsApp source’s message received event, filtered to the contractor’s number, so the reply resumes the session the moment it lands, days before the next scheduled run, and the Ask agent tells the tenant straight away.
Do not define in the PROCESS.md when the next run should be
A line in the PROCESS.md such as “follow up after two days” will not continue the session at that time automatically, because the Ask agent cannot yet set up on its own when the session will continue. What the Ask agent can do is check, each time the session runs, whether something is due, for example whether two days have passed since the last message, and act only then. So the session has to continue automatically, on a schedule with auto-run or on an event, and the PROCESS.md has to describe that check.
- Set auto-run to match the smallest gap between follow-ups. The Ask agent can only act when the session runs, and auto-run decides how often that is. For example, if the follow-ups are due after one, three and five days, set Daily. If one of them is due an hour after the last, set Hourly. A session cannot act sooner than its auto-run frequency.
- Subscribe the session to the reply event, so it resumes the moment the desired event happens, for example a person replied to a message, and the follow-ups stop.
- Write the follow-ups in the PROCESS.md as a check, not as a schedule. On each run the Ask agent should work out how long it has been since the last step and which step is next. If that step is due, it acts. If not, it does nothing and waits for the next run.
Example
- Requirement
- If the customer does not reply on WhatsApp, the workflow asks for a follow-up after one day, another after three days and a last one after five days.
- Solution
- Write the three steps in the file. Set auto-run to Daily and subscribe the session to the customer’s WhatsApp replies. On every run the Ask agent checks whether a reply has arrived and how many days have passed since the first message. It sends the follow-up that is due, or nothing. A reply resumes the session at once and ends the follow-ups.