Action: Cancel scheduled¶
With this action, you can stop a scheduled task before it executes, whether it was set up using Jump to action or Run button actions.
What can you do with this action?¶
- Cancel scheduled tasks: Cancel scheduled tasks that are no longer needed or were set up by mistake.
How to configure the action?¶
1. Create the action¶
- Go to your bot and press
🛠 Editto enter editor mode. - Select the button or command where you want to add this action, or create a new one.
- Click
Actions 🌟→🎯 New action→⭕️ Cancel scheduled. - Click
Configure 🛠to set it up.
2. Configure the options¶
➡️ ID of the scheduled task¶
Enter the cancel_id of the task you want to cancel. This is generated by actions such as Jump to action or Run button when scheduling a task. You can retrieve it using:
#ScheduledActionID.cancel_id#
Replace
ScheduledActionIDwith the action ID of the action that scheduled the task (Jump to actionorRun button).
3. Activate the action¶
Click ✅ Activate to enable this action and make it functional.
What does this action return through its ID?¶
- Use
#ActionID.status#to check if the task was canceled:ok: The task was successfully canceled.failed: The task could not be canceled (for example, if it had already been executed).
Replace
ActionIDwith the action ID of this action (Cancel scheduled).
Practical example: Stopping a reminder¶
We will use the /reminder command from the practical example of the Jump to action, which schedules a reminder to notify you minutes in the future. If you haven't created it yet, do so before continuing.
Once created, we will create another command /cancel_reminder to cancel it if you change your mind.
Example usage:
-
The user sends:
/reminder "Call the doctor" 15The bot schedules the reminder for 15 minutes later.
-
Then, the user sends:
/cancel_reminder "cancel_id"The bot cancels the reminder before it is sent.
1. Modify the /reminder command¶
We will modify the /reminder command to display the cancel_id to the user:
- Go to the bot editor by clicking
🛠 Edit. - Select the
/remindercommand by sending it to the bot. - Click
Actions 🌟to enter the command's action menu. -
Locate the third added action, which should be of type
Send message. It currently contains the following message:✅ Your reminder has been scheduled and will be received in {#ActionIDRecParam.param2#} minutes.Replace the message with:
✅ Your reminder has been scheduled and will be received in {#ActionIDRecParam.param2#} minutes. 🆔 Cancellation ID: <code>{#ActionIDJumpToAction.cancel_id#}</code>Note 1: Replace
ActionIDRecParamwith the Action ID ofReceive parameters(action 1).Note 2: Replace
ActionIDJumpToActionwith the Action ID ofJump to action(action 2).Note 3: We used
HTMLto format thecancel_id, allowing the user to copy it by tapping on it. See HTML tags here.
2. Create the /cancel_reminder command¶
- Exit the action menu by clicking
↙️ Exit ↘️. - Create a new command by clicking
✳️ New button | commandand name it/cancel_reminder. - Click
Actions 🌟to enter the command's action menu.
3. Configure the actions¶
a) Action 1: Receive parameters¶
- Click
🎯 New action→🖥 Receive parameters. - This action does not require configuration, simply activate it by clicking
✅ Activate. - Copy the ID of this action, as you will need it shortly.
b) Action 2: Cancel scheduled¶
- Click
🎯 New action→⭕️ Cancel scheduled. -
Click
Configure 🛠→🆔 ID of the scheduled task 🆔and enter:#ActionIDRecParam.param1#Replace
ActionIDRecParamwith the Action ID ofReceive parametersyou copied earlier (action 1). -
Return to the action menu and activate this action by clicking
✅ Activate.
c) Action 3: Send message¶
- Click
🎯 New action→✉️ Send message. -
Click
Configure 🛠→💬 Set message 💬and enter the message that will inform the user about the cancellation status:✅ Your reminder has been canceled.-
If you want to display a different message depending on the cancellation status, use this expression:
{condition(#ActionIDCancelScheduled.status# == "ok", "✅ Your reminder has been canceled.", "⚠️ Unable to cancel the reminder.")}Note 1: Replace
ActionIDCancelScheduledwith the Action ID ofCancel scheduled(action 2).Note 2: We used the condition() function to display different messages based on a condition. You can see all functions here.
-
-
Return to the action menu and activate this action by clicking
✅ Activate.
Final result¶
-
The user sends the command:
/reminder "Buy a gift" 30The bot responds:
✅ Your reminder has been scheduled and will be received in 30 minutes. 🆔 Cancellation ID: daf50311-4dc5-41c0-985c-733a063f13b6 -
Before 30 minutes pass, the user sends:
/cancel_reminder "daf50311-4dc5-41c0-985c-733a063f13b6"The bot responds:
✅ Your reminder has been canceled. -
The reminder message will not be sent.
Important notes¶
- If the task has already been executed or does not exist, it cannot be canceled, and the status will be
failed. - Use the
cancel_idcorrectly: This ID is unique for each scheduled task; if you do not have it, you will not be able to cancel it.