Handle answers Beta

Ask the user a question and act on the answer

Beta. The Device SDK is live for design partners: Dopl issues your project's keys while the developer portal is being built, and @dopl/sdk is available on request. Agents that act for one signed in Dopl user can use the hosted MCP server instead.

1. Ask

ask delivers a question with the ask intent and waits for the answer. With two or more options Dopl uses ask.choice; without options it uses ask.text or ask.confirm, whichever the device supports. Keep options within the device's limit; glasses show at most four, and more fails with invalid_request.

const answer = await dopl.ask("usr_123", {
  question: "Book the 9:40 flight?",
  options: ["Yes", "No"],
});

if (answer.status === "answered") console.log(answer.answer);
else console.log("No answer yet", answer.delivery.delivery_id);

2. How the wait works

The Deliver call itself holds for up to 200 seconds while the user decides. If the user answers in time, the response's status is done; if not, it is still delivered or queued. Either way, read the answer from GET /v1/actions/{id} with the delivery_id, which is what ask does for you until its timeoutMs passes, 200 seconds by default. A timeout resolves with status: "timeout", and a failed action throws.

const action = await dopl.actions.get(delivery_id);
{
  "action_id": "4f7e2a10-6c1b-4d9e-8a35-0b2c7d9e1f42",
  "device_id": "8b0c6f1e-3d2a-4c51-9a7e-2f4d6b1c9e30",
  "capability": "ask.choice",
  "status": "done",
  "result": {
    "simulated": true,
    "index": 0,
    "label": "Yes"
  },
  "error": null,
  "created_at": "2026-10-27T17:02:11Z",
  "updated_at": "2026-10-27T17:02:11Z"
}

3. Ask on one device

To ask on a specific device, run ask.choice there with Run a device action. It holds the same way, and you read the answer with the action_id.

const { action_id } = await dopl.devices.action(deviceId, "ask.choice", { question: "Book it?", options: [{ label: "Yes" }, { label: "No" }] });

An ask.answered webhook comes with the developer portal. Agents reach glasses with the same flow today through glasses_ask on the hosted MCP server.