description |
---|
How to use AI actions in Momentic tests. |
AI actions transform human-understandable goals into groups of preset commands. When an AI action is invoked, our web agent continuously generates and runs preset commands until the specified goal has been achieved. For example, the goal "add ice cream to my cart" on a shopping page may transform into a series of clicks.
Since they are powered by LLMs instead of hardcoded selectors, AI actions are self-healing, adapting automatically to minor changes to your website without human involvement. We recommend using AI actions to complete user flows such as logins, searches, and checkouts where the specific actions taken are not as important as being able to accomplish the goal.
<span style={{ display: "flex", justifyContent: "center" }}>
![AI action initial state](/images/docs/ai-action-initial-state.png)The configuration for an AI action consists only of the goal that should be achieved. The prompt should include any variables required to complete the task, such as credentials ("login using mypassword
"), descriptors ("add a 128GB iPad to my cart"), and option choices ("decline all add-ons and checkout").
Once you have entered the prompt, click the play button to run the action. You will begin to see Momentic's web agent generate and execute commands:
<span style={{ display: "flex", justifyContent: "center" }}>
![AI action generating state](/images/docs/ai-action-state-1.png)The web agent will continue generating commands until it believes your goal has been accomplished, at which point it will output a special Done
command that is only allowed at the end of AI actions and cannot be moved. If the agent is acting unexpectedly, you can click Cancel Execution
and manually tune the sequence of commands.
<span style={{ display: "flex", justifyContent: "center" }}>
![AI action final state](/images/docs/ai-action-state-final.png)On the first run, the web agent will always terminate the AI action with a Done
command that has a blank Success condition
. This means that, on subsequent runs, the AI action will be marked as successful if all nested commands within it succeed.
You can customize this behavior by adding a condition to the Done
command, which functions like an AI check that runs after the other nested commands in the AI action complete. If the check fails, the entire AI action will be marked as failed. This condition will also be used for auto-healing during scheduled runs if your website changes.
If the web agent chooses an incorrect sequence of commands, there are two ways to tune the AI action.
You can edit your original prompt to provide more details about the correct sequence of commands.
You are free to edit the commands generated by the web-agent, move commands around, delete commands, or add new commands. In the event your website changes and auto-healing is required in a scheduled run, your edits will incorporated as feedback by the Momentic web agent when generating new commands.
Note that you cannot delete or move the final Done
command. If you wish to regenerate all generated commands, please delete the entire AI action.