Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Assistant

    The site's AI assistant: a visitor asks a question and gets an answer from the site's own knowledge base — with a link to a page under every statement.

    Type: wrapper Web only: the server that serves the site does the answering. In the app, in the editor's preview and on an exported site there is nobody to answer: the element draws its child, state is unavailable , ask does nothing.

    State @q:""
      Assistant question:$q consent:true ask:@ask state:@st message:@msg blocks:@blocks action:@next pending:@busy
        Column crossAxisAlignment:stretch size:min spacing:12
          TextField value:$q onSubmitted:(){ask()}
          ElevatedButton onPressed:(){ask()}
            Text "Ask"
          Text "The question is processed by an AI service and may be stored."
          Text "Searching…" if:$busy
          Text "The assistant is unavailable right now. Please try later." if:{st == "unavailable" && !busy}
            #style color:$theme.colors.error
          Text "Consent is required to ask." if:{st == "needsConsent" && !busy}
            #style color:$theme.colors.error
          Text $msg
          ListView.builder itemCount:{length(blocks)} shrinkWrap:true
            @Macros id:itemBuilder index:0
              Column crossAxisAlignment:stretch size:min
                Text {blocks[index]["text"]}
                Container
                  #web href:{blocks[index]["source"]["url"] ?? ""}
                  Text {blocks[index]["source"]["title"] ?? ""}
          Container
            #web href:{next["url"] ?? ""}
            Text {next["title"] ?? ""}

    What the assistant answers from, what it is for and what its limits are is not written in markup — it lives in the project directory: Site AI assistant .

    Parameters

    Parameter Type Description
    question string The visitor's question. Read at the moment ask is called — bind it to the field's variable
    consent bool Whether the visitor agreed to the question being processed. Read at the moment ask is called. No parameter means no consent
    ask output, function The button calls it. Sends the question
    state output, string One word, see below
    message output, string A phrase for the visitor when an answer cannot be shown. Already in their language
    blocks output, list The answer, in order. A block has a kind : text — a statement ( text , source with title and url ), anything else — a card from the owner's catalogue (see below)
    action output, object The next step the owner suggests: id , title , url — or empty
    pending output, bool true while the search is in progress
    history output, list Earlier answers to this visitor, newest first: question , at (time, ms), message , blocks , action . See “Memory”
    forget output, function Erases history . Give the visitor a button

    Cards in the answer

    An answer can be not only told but shown: next to the statements the assistant can display entries from the owner's catalogue — a plan, a service, a section. Each such entry arrives as a block with its own kind ( card by default) and the fields the owner wrote in the catalogue: title , text , image , url , a price — anything. Plus scenario and id .

    The card's layout is written by the page author. The list row switches it by kind :

    Assistant consent:true blocks:@blocks
      ListView.builder itemCount:{length(blocks)} shrinkWrap:true
        @Macros id:itemBuilder index:0
          Column crossAxisAlignment:stretch size:min
            // A statement with its source.
            Column crossAxisAlignment:stretch size:min if:{blocks[index]["kind"] == "text"}
              Text {blocks[index]["text"] ?? ""}
              Container
                #web href:{blocks[index]["source"]["url"] ?? ""}
                Text {blocks[index]["source"]["title"] ?? ""}
            // A card: everything written on it comes from the catalogue entry.
            Container if:{blocks[index]["kind"] == "card"}
              #web href:{blocks[index]["url"] ?? ""}
              Column crossAxisAlignment:stretch size:min
                Image src:{blocks[index]["image"] ?? ""} if:{blocks[index]["image"] != null}
                Text {blocks[index]["title"] ?? ""}
                Text {blocks[index]["text"] ?? ""}
    • A field the entry does not have arrives empty: read it with ?? "" , and show the picture only when there is one — otherwise an empty img is left on the page.
    • The model writes neither the title, nor the price, nor the picture, nor the address: it names entries by identifier, and the server fills in the fields. A made-up price in a card is impossible.
    • How to set up the catalogue is in the assistant description .

    States

    state When
    idle before the first question
    asking the search is in progress; it takes a few seconds — show pending
    answered the answer is in blocks
    notFound the question is on topic, but the base does not have it; message and action say where to turn
    offTopic the question is not about what the assistant is for
    paused the visitor has used up their answers for now
    needsConsent no consent — the question went nowhere
    unavailable the assistant is not answering; the page itself is intact

    Say the refusal yourself. For unavailable and needsConsent there is nothing in message : the assistant did not answer and had nothing to say it with. A page that shows only message stays silent in these states — the person pressed “Ask”, and nothing happened, like a broken button. Show your own text for them, in the error colour and next to the field, as you would show a form error; the example above does exactly that.

    On a site with a cookie banner the answer “accept all” is needed. The question is processed by a third-party service, and the answer sets a cookie that tells one visitor apart from another — “necessary only” does not cover that. Until the visitor has agreed to everything, the question does not go out: state becomes needsConsent , the banner comes back on screen, and when the visitor agrees, the very question they pressed the button for goes out. The assistant brings the banner with it: on a page with nothing else to ask about, it appears because of the assistant alone. A live code example ( reeel live ) follows the same rule. consent: is a separate condition on top of this: a checkbox or words next to the field.

    How it works

    • A wrapper. The element's outputs are seen only by its subtree: the field, the button and the answer lie inside. A button next to it will not ask the question.
    • No consent, no question. Bind consent: to a checkbox ( consent:$agreed ) or write consent:true if consent is stated in words next to the field and pressing the button is that consent.
    • No address, no key. The question goes to the address of this same site.
    • No need to write an “I am not a bot” check. A stranger, after the first question, passes an invisible check, and the question is repeated for them automatically; for the page it is still one asking . This is the platform's own check — the Captcha element and settings.captcha play no part in it.
    • The element announces the check itself. With the first check, a line “Bot protection — Yandex SmartCaptcha” appears under the element's content, with a link to the data processing policy — in the page's language, in the colour of the surrounding text. The service's badge at the window edge is hidden then. There is no need to write such a line in markup, and it cannot be removed: the service allows hiding the badge only to those who disclose the check another way. Before the first check there is no line.
    • The server holds the limits. How many questions can be asked and the pause for off-topic questions are not counted by the page: it receives paused .
    • The server builds the link under a statement. source.url leads to the page and section the statement was taken from; empty if the document has no page.

    Memory

    The answer does not vanish when the page reloads. A visitor asked, followed a link from the answer to read a section, came back — their answers are in place, in history .

    State @q:""
      Assistant question:$q consent:true ask:@ask history:@past forget:@forget
        Column crossAxisAlignment:stretch size:min
          ListView.builder itemCount:{length(past)} shrinkWrap:true
            @Macros id:itemBuilder index:0
              InkWell onTap:(){q = past[index]["question"]; ask()}
                Text {past[index]["question"]}
          TextButton onPressed:(){forget()} if:{length(past) > 0}
            Text "Clear history"
    • Where it is kept. In the visitor's browser ( localStorage ), not on the server: the ten latest answers per page language, no older than thirty days. Another browser and another device have their own history.
    • What is remembered. Only answers ( answered ). “Not found”, “off topic” and refusals are not saved.
    • A repeated question does not reach the server. The same question whose answer is already in the history is shown at once: state becomes answered without asking . That is why a history row opens as in the example — the question into the field and ask() . The answer is the one given back then: if the base has changed since, the visitor sees it no sooner than the entry expires or they erase it.
    • Consent. On a site that asks about cookies, the history is written and read only with consent to everything; withdrawing consent erases it entirely.
    • forget erases the history at the visitor's request — it is worth putting a button for it next to the list.
    • In the app history is an empty list and forget does nothing.

    A search field that invites a question

    This is how the search on this site is made:

    • sample questions are typed and erased in the empty field;
    • with the cursor in the field the sample goes quiet;
    • Enter sends the question;
    • while the search is in progress , instead of a progress bar, “thoughts” are typed out in words, and everything else is hidden;
    • under the field — questions already asked .
    State @q:"" @hints:["How do I connect a domain?", "What can AI search do?", "How do I publish a site?"] @thinking:["Leafing through the docs…", "Checking the sections…", "Putting the answer together…"]
      Assistant question:$q consent:true ask:@ask state:@st message:@msg blocks:@blocks pending:@busy history:@past forget:@forget
        Column crossAxisAlignment:stretch size:min spacing:12
          Animated loop:true duration:16500 value:@ht
            Focus @isFocused:false
              Stack
                Semantics label:"Ask a question"
                  TextField value:$q textInputAction:search onSubmitted:(){ask()}
                    #decoration
                      #border outline
                Positioned left:16 top:16 right:16 if:{q == "" && !isFocused}
                  IgnorePointer
                    Text {substring(hints[floor(ht * 3) % 3], 0, floor(length(hints[floor(ht * 3) % 3]) * clamp(min((ht * 3 - floor(ht * 3)) / 0.3, (0.95 - (ht * 3 - floor(ht * 3))) / 0.15), 0, 1)))} maxLines:1
                      #style fontSize:16 height:1.5
          Animated loop:true duration:16500 value:@wt if:$busy
            Text {substring(thinking[(floor(wt * 3) + length(q)) % 3], 0, floor(length(thinking[(floor(wt * 3) + length(q)) % 3]) * clamp(min((wt * 3 - floor(wt * 3)) / 0.3, (0.95 - (wt * 3 - floor(wt * 3))) / 0.15), 0, 1))) + "|"}
          Column crossAxisAlignment:stretch size:min if:{!busy}
            Text {msg ?? ""}
            ListView.builder itemCount:{length(blocks)} shrinkWrap:true
              @Macros id:itemBuilder index:0
                Text {blocks[index]["text"] ?? ""}
          ListView.builder itemCount:{length(past)} shrinkWrap:true if:{!busy}
            @Macros id:itemBuilder index:0
              InkWell onTap:(){q = past[index]["question"]; ask()}
                Text {past[index]["question"] ?? ""}
    • The sample is a Text over the field, not a hintText . A hintText driven by the clock moves too, but the browser keeps a placeholder on screen even with the cursor in the field — until the first letter. The overlay can go quiet on the cursor ( Focus @isFocused ).
    • Put the sample exactly where the typed text will be, otherwise the line jumps on the first letter. In a field with an outline border the text is 16 from the left and 16 from the top, with filled — 16 and 12, with an underline — 0 and 12, the same in the app and on the site. With your own #contentPadding — its numbers (plus 4 on the left for outline ), but a field without isDense is no lower than 48 and centres the text. The sample's font size is the field's: fontSize:16 height:1.5 .
    • The field's name comes from Semantics label: ; running text gives the field no name.
    • The typing formula: of n phrases, floor(t·n) % n is visible, its share p is the fractional part of t·n , and length × clamp(min(p / 0.3, (0.95 − p) / 0.15), 0, 1) characters are visible. Typing takes 30 % of the share, erasing the last 15 %.
    • While the search is in progress, show only the “thoughts”: an old answer under a new question reads as its answer.
    • Draw the answer and the history with ListView.builder … shrinkWrap:true , not Repeat : on the site Repeat is expanded when the page is built, and an answer that arrives later will not appear.
    • Do not put a link inside a link: a card link and a statement with a link to its source are two if: branches, not one tile.

    What not to do

    • Do not assemble the same thing from HttpData : the request will go out, but consent, the check and the visitor's counters will not.
    • Do not output text as markup or HTML: it is plain text.
    • Do not expect an answer in the editor's preview: the assistant is checked on the published site.