Skip to main content
This feature is in preview. The API may change before general availability. To try it out, contact support@intunedhq.com and we’ll enable it for your workspace.

Overview

Some automations can’t finish on their own. A login asks for a one-time code, a CAPTCHA won’t solve, or a page needs a judgment call. Human in the loop lets a Run pause, ask for help, and continue with the answer. Usually a person answers, but your own system or an agent can answer through the same links. The Runtime SDK has two methods for this:
  • askForInput asks a question and waits for a JSON answer, such as a 6-digit code.
  • handoff hands over live control of the Run’s browser. Whoever takes over acts in the browser, then presses Done to hand it back.
Each call creates an interaction: a pending question or handoff with links to answer or cancel it. Use these methods for steps your code can’t do on its own. If a step can be retried or automated, keep it in code: every interaction holds a machine while it waits.

How it works

  1. Your code calls askForInput or handoff. The Run pauses on that line.
  2. Intuned creates the interaction and gives it a link. For askForInput, the link takes the answer (inputUrl). For handoff, it opens a page that controls the browser (handoffUrl).
  3. The link reaches whoever answers, either through the url your code passed or from the Run or AuthSession operation result API.
  4. They answer or press Done. Your code continues with the answer.
If no one answers before the timeout, the method throws. Links stop working once an interaction ends.

Ask for input

With a schema, the answer is validated and typed, and the schema is sent as JSON Schema so whoever answers knows what to submit.

Show the page with the question

The prompt is Markdown, and attachments adds images to it. Pass a Page or Locator to send a screenshot of it, or image bytes:
handoff takes attachments too, for example a screenshot of another tab. Up to 5 images (PNG, JPEG, WebP or GIF), 2 MB each and 8 MB in total. They need a recent UDAS version: on older machines, the images are dropped and the prompt is sent without them. To answer, POST the JSON to the interaction’s inputUrl:
To cancel the interaction instead of answering it, POST to its cancelUrl with no body. askForInput throws InteractionCanceledError. The responses are the same.
Answering and canceling are authenticated by the token in the link, or by Intuned’s usual authentication across the API, the dashboard and the CLI. With the usual authentication, the end delivery names who answered in endedBy.

Hand off the browser

The handoffUrl opens a page with the live browser, the prompt, a countdown, and Done and Cancel buttons. Done resumes the Run. Cancel makes handoff throw InteractionCanceledError. If your workspace restricts access by IP address, the page opens only from allowed addresses.
handoff needs a visible browser. Set headful to true in Intuned.json. In a headless Run, handoff throws InteractionUnsupportedError. A Run can have one handoff open at a time.

Check the page after a handoff

Whoever takes over can navigate, open tabs, or change what’s on the page. Don’t assume the page is where your code left it:
  • Wait for the state you need, such as page.waitForURL or a selector, instead of continuing right away.
  • Re-find elements after the handoff instead of reusing handles from before it.
  • If they may have opened a new tab, pick the page you need from context.pages().
With url. Intuned sends a POST to the URL with the headers your code passed, for example an Authorization header that your endpoint checks. The URL must be public HTTPS. Redirects aren’t followed. Deliveries are retried for up to 5 minutes; if they keep failing, the method throws InteractionDeliveryError.
attachments lists the images as signed download URLs. They expire when the interaction does (and no sooner than 15 minutes after they’re issued), so download any image you want to keep when the delivery arrives. A handoff interaction has handoffUrl in place of inputUrl, and its cancelUrl works like the page’s Cancel button. Every delivery carries an x-intuned-interaction-id header with the interaction id, so you can ignore repeats, and an x-intuned-interaction-event header: started here, ended for the end delivery. Without url. While a Run is waiting, the Run result API lists its open interactions in pendingInteractions, with the same fields. Poll it from your app, then show the link to whoever answers or answer from your own code. AuthSession create, validate and update operations work the same way: while one is in_progress, its result (create, validate, update) has the same pendingInteractions field. From the CLI. intuned platform runs get lists a waiting Run’s interactions, and intuned platform interactions resolve answers one: it prompts for the input like a local run, or opens the handoff page. intuned platform interactions cancel cancels one.
Anyone with an inputUrl, handoffUrl or cancelUrl can answer or cancel the interaction until it ends. Share links only with the people and systems that should answer.

Know when an interaction ends

With url, Intuned sends a second POST to the same URL, with the same headers, when the interaction ends, however it ends. Use it to take the request off your queue or tell whoever was asked that it’s no longer needed.
endedBy says who answered or canceled: a user (label is their email) or an API key (label is its name). It’s null when the link’s token alone was used, and when the interaction ended on its own (timedOut, deliveryFailed, attemptEnded). The answer itself isn’t included. The end delivery is retried for up to 5 minutes, like the first one. It can arrive before the first delivery when that one is still being retried, so match the two by id.

Timeouts and cost

While an interaction waits, the Run’s own timeout is extended every minute, so an answer can take longer than the Run timeout. Pass extendRunTimeout: false (extend_run_timeout=False in Python) to keep the Run timeout in force instead. The machine keeps running while it waits, so waiting time counts as compute time. A waiting Run also occupies a machine that other Runs can’t use.

In the IDE and CLI

Local Runs don’t use url. The developer answers in the terminal:
  • askForInput asks for each field when the schema has only string, number, and boolean fields, and asks for JSON otherwise. Press Esc to cancel.
  • handoff asks you to use the browser, then press Enter to continue or Esc to cancel.
  • The prompt is printed as written, followed by a link to each attachment, saved as a temporary file until the interaction ends.
  • Interactions are answered one at a time.

Limitations

  • Interactions fail right away with InteractionUnsupportedError when nobody can answer in a terminal: agent runs, and CLI runs whose input isn’t an interactive terminal.
  • When an interaction fails (for example, it times out), the attempt fails and is retried like any other error, which asks again.
  • Redeploying a project ends its open interactions, with status attemptEnded.