- Followed the Python SDK Setup guide for installation and initialization.
- Obtained your credentials as described in Managing API Keys.
- Successfully initialized the
agentobject as shown in the SDK Setup guide.
Creating a Workflow Definition
Define a reusable sequence of tasks that can be executed later.create_workflow method requires a name for the workflow and a list of tasks. Each item in the tasks list defines a step and must contain either:
- An
instructionsstring (which guides the agent’s actions for that step). This may optionally be paired with atarget_url(string or list of strings) to specify an exact starting page(s) for the step. - OR the
task_idof a pre-defined task (like one generated from video).
instructions and task_id for the same step.
The target_url within a task step definition is optional. If provided, it specifies the starting page(s) for that specific step. If omitted for a step, the agent will begin that step based on the context from the previous step or navigate based purely on the instructions provided for the current step.
For more details on using target_url (including multiple URLs) versus instruction-based navigation within steps, see Advanced SDK Patterns: Using target_url.
Example using task_id:
create_workflow returns a dictionary containing the details of the created workflow, including its unique workflow_id.
Starting a Workflow Run
Initiate an execution run of a previously defined workflow for a specific end-user.start_workflow_run method requires the workflow_id of the definition to execute and the developer_user_id of the target end-user. On success, it returns a dictionary containing the unique run_id for this specific execution and its initial status (usually ‘queued’).
Checking Workflow Run Status (Polling)
Monitor the progress and retrieve the results of a specific workflow run using itsrun_id.
get_workflow_run_status method requires the run_id. It returns a dictionary containing the run’s current status, result (if completed, structure may vary), error (if failed), and other details like workflow_id and timestamps, or None on error.
(Note: Handling results via webhooks, similar to tasks, is also recommended for workflows to avoid polling. The webhook payload structure for workflow events would need to be defined and verified using agent.verify_webhook.)