LLM-friendly URL

Letting the agent ask clarifying questions

Some requests can be read in clearly different ways. "Show revenue by region" can mean gross or net revenue, and a "region" can be a country or a sales territory. When your client can show choices, the universal agent can ask the user which reading they mean.

Your client handles clarifying questions in these steps:

  1. Your client sends the user's message and says it can show questions. The response is either a normal answer or a question asset with one to three multiple-choice questions.

  2. Your client shows the questions, then sends the user's choices back in a new request. The agent continues the original request with those choices.

Before you begin

You need:

  • An Embed key and token for the user, as described in Adding Luzmo IQ to your agentic workflow . The user needs Luzmo IQ access.

  • The universal agent, agent: "auto" . The other agents never ask questions.

  • A client that can show a question with its options and a free-text Other field.

The examples use stream: true . The AIPrompt reference describes every stream event.

Ask for questions in the request

Add client_capabilities with interactions: ["question"] to an auto request. This tells the agent that your client can show questions.

ask.sh
bash
curl https://api.luzmo.com/0.1.0/aiprompt \
  -H "Content-Type: application/json" \
  -d '{
    "action": "create",
    "version": "0.1.0",
    "key": "<your-embed-key>",
    "token": "<your-embed-token>",
    "properties": {
      "agent": "auto",
      "stream": true,
      "client_capabilities": { "interactions": ["question"] },
      "input": [
        { "type": "text", "text": "Show revenue by region for last quarter." }
      ]
    }
  }'

Declaring the capability does not guarantee a question asset. Handle both a question asset and a normal answer.

Without the capability

If you leave out client_capabilities , or leave "question" out of interactions , the response contains no question asset. The agent continues without asking your client for a structured answer.

Read the question asset from the stream

When the agent asks, its turn includes a question asset, an asset with asset_type: "question" . The turn can also contain text and other assets, such as a chart, so find the question asset by its asset_type . The stream sends text as normal text events, and the question asset as an asset_start , asset_delta , and asset_end event:

json
{ "type": "text_delta", "text_id": "6f2c…:text", "delta": "Which revenue and regions do you mean?", "conversation_id": "fdce930b-4f6d-4d2b-8a43-7ea7d62457a2", "user_message_id": "…", "assistant_message_id": "…" }
{ "type": "asset_start", "asset_id": "3b9e1c52-8d4f-4a61-9f0e-2c7a5d18b6e4", "asset_type": "question", "conversation_id": "fdce930b-4f6d-4d2b-8a43-7ea7d62457a2", "user_message_id": "…", "assistant_message_id": "…" }
{ "type": "asset_delta", "asset_id": "3b9e1c52-8d4f-4a61-9f0e-2c7a5d18b6e4", "delta": { … the question asset value … }, "conversation_id": "fdce930b-4f6d-4d2b-8a43-7ea7d62457a2", "user_message_id": "…", "assistant_message_id": "…" }
{ "type": "asset_end", "asset_id": "3b9e1c52-8d4f-4a61-9f0e-2c7a5d18b6e4", "conversation_id": "fdce930b-4f6d-4d2b-8a43-7ea7d62457a2", "user_message_id": "…", "assistant_message_id": "…" }

The asset_delta carries the whole question asset value in one event:

json
{
  "v": 1,
  "requestMessageId": "a41d6e0b-2f7c-4c8e-9b35-71e0c6d2f9a8",
  "status": "open",
  "questions": [
    {
      "id": "q1",
      "type": "single",
      "title": "Which revenue do you mean?",
      "options": [
        { "id": "o1", "label": "Net revenue", "description": "After discounts and returns", "recommended": true },
        { "id": "o2", "label": "Gross revenue", "description": "Before discounts and returns" }
      ]
    },
    {
      "id": "q2",
      "type": "multiple",
      "title": "Which regions should the chart include?",
      "minSelected": 1,
      "maxSelected": 3,
      "options": [
        { "id": "o1", "label": "Europe" },
        { "id": "o2", "label": "North America" },
        { "id": "o3", "label": "Asia Pacific" }
      ]
    }
  ]
}

Store the conversation_id and the asset_id . You need both to send the answer.

With stream: false , the question asset is in assistant_message.aiMessageAssets with type: "question" . Its id is the asset_id , and its value is the object above.

The question asset value

Field Description
v Version of the value. Always 1 .
requestMessageId Read-only ID of the user message the questions are about. Use it to show the questions next to that message, for example when you reload a conversation. You never send it back. The answer uses conversation_id and answer.asset_id .
statusopen when the agent sends it. See Question statuses .
questions One to three questions. Show all of them, and answer all of them in one call.

Each question has these fields:

Field Description
idq1 , q2 , or q3 . Use it as the key in your answer.
typesingle for one choice, multiple for one or more choices.
title The question, up to 120 characters.
description Optional extra context, up to 200 characters.
minSelected , maxSelected Optional, only on multiple questions. The fewest and most choices the answer may hold.
options Two to five options.

Each option has these fields:

Field Description
ido1 to o5 . Unique within its question.
label The option text, up to 80 characters.
description Optional short explanation, up to 160 characters.
recommendedtrue for an option the agent recommends. You can mark it as recommended in your interface. Absent otherwise. A single question has at most one recommended option.

Count choices with Other

Every question also accepts a free-text Other answer, up to 300 characters. The options list does not include it, so your client adds the field itself. Other counts as one choice.

A single question takes exactly one choice: one option, or Other text. A multiple question takes between minSelected and maxSelected choices. Without those fields, it takes at least one choice and at most all options plus Other.

Send the answer

Send a new AIPrompt request in the same conversation with an answer instead of a text input:

  • conversation_id : the conversation that holds the question asset.

  • answer.asset_id : the asset_id of the question asset.

  • answer.response : type: "question" , action: "submit" , and answers , an object keyed by question ID. Each entry must include options , an array of the chosen option IDs, and can include other , the Other text. For an answer with Other alone, send "options": [] and the user's text in other , for example "q1": { "options": [], "other": "Recurring revenue" } .

Use agent: "auto" , and the same agent_id if the first request had one. Send the answer with a token for the same user who started the conversation.

answer.sh
bash
curl https://api.luzmo.com/0.1.0/aiprompt \
  -H "Content-Type: application/json" \
  -d '{
    "action": "create",
    "version": "0.1.0",
    "key": "<your-embed-key>",
    "token": "<your-embed-token>",
    "properties": {
      "agent": "auto",
      "stream": true,
      "conversation_id": "fdce930b-4f6d-4d2b-8a43-7ea7d62457a2",
      "client_capabilities": { "interactions": ["question"] },
      "answer": {
        "asset_id": "3b9e1c52-8d4f-4a61-9f0e-2c7a5d18b6e4",
        "response": {
          "type": "question",
          "action": "submit",
          "answers": {
            "q1": { "options": ["o1"] },
            "q2": { "options": ["o1", "o2"], "other": "Latin America" }
          }
        }
      }
    }
  }'

You do not need input on an answer request. The user's choices become their message, and the agent keeps the datasets of the original request, so text and dataset entries are ignored. You can still send item and dashboard entries as in a normal request.

Every question needs an answer. To skip all questions instead, send "response": { "type": "question", "action": "skip" } without answers . Skipping sends the recommended options, where a question has one, as the user's assumed choices. A skip with answers , even answers: {} , is rejected.

When the user types instead

The user does not have to answer. If they type a new message, send it as a normal request in the same conversation. Every open question asset in the conversation then gets the status superseded , so disable its answer form in your client.

What the stream returns next

The answer starts a normal agent turn. The stream returns the same events as any request: text, chart or dashboard assets, and a final finish event. The agent continues the original request with the user's choices.

The response to an answer can contain another question asset. Keep client_capabilities with "question" on the answer request, and handle a new question asset the same way as the first. Send its answer with the new asset_id .

Question statuses

To restore a conversation, read its question assets with Search AI message assets . Each question asset keeps its status:

Status Meaning
open Waiting for an answer.
answered Submitted. The asset gains answer.response with the submitted choices.
skipped Skipped. The asset gains answer.response with action: "skip" .
superseded The user sent a new message in the conversation instead of answering.

Show an answer form only for open question assets. A question asset takes one answer. If you answer a question asset that is no longer open , the request succeeds without running the agent. The reply text is These questions are no longer waiting for your answer. , in the request's locale_id .

Handle errors

The API checks the answer before it starts the stream, so these errors return as a normal error response:

Status Message Cause
400Invalid properties schema. … The request does not match the schema. The message names the field. For example, if answer has no conversation_id , or the agent is not auto , the message includes "answer" needs the "conversation_id" of the question it answers, and the universal agent.
404Conversation not found. The conversation_id does not exist.
403You can only create messages in your own conversations. The token is for a different user than the one who started the conversation.
404There is no such question in this conversation. The asset_id is not in this conversation, or the question asset came from a request with a different agent_id .
400Choice questions are not enabled, so there is no question to answer. Clarifying questions are not available for this user. Contact Luzmo support.
400The answer is for choice questions, but <asset_id> is an <type>. The asset_id points to another kind of asset, such as a chart.
400The box has no question "<id>".answers has a key that is not a question ID.
400"<title>" has no answer. A question is missing from answers .
400"<title>" has no option "<id>". An option ID does not exist in that question.
400"<title>" has option "<id>" more than once. The same option ID appears twice.
400"<title>" takes 1 choice, got 2. The number of choices, counting Other, is outside the allowed range. For a range, the message reads takes 1 to 3 choices .
Did this page help you?
Yes No