AI answers
AI answers turn a question into a short answer written from your own records, with numbered citations. “How long does delivery take to Dubai?” gets two or three sentences from your shipping page, with a link to it, rather than a list of ten results to read.
How an answer is made
Section titled “How an answer is made”- Retrieve. Shoof AI searches the app with the question, in hybrid mode,
leaving out the words that only ask (“tell me about”, “do you have”), and
takes the top results (6 by default, setting
answers.maxSources, up to 12) as sources, with the passages of their text that match best. Translations of an item count once: sources are in the question’s language when there are any, so an English question doesn’t get the Arabic copy as another item. - Write. Claude writes an answer from those sources only, in the language
of the question, citing them inline as
[1],[2]. If the sources don’t answer the question, it says so and suggests what to search for instead. - Stream. The sources arrive first, then the answer as it’s written.
If Claude isn’t available, the answer falls back to an extractive one: the sentences from the sources that best match the question, with their citations. If nothing relevant is found, there’s no answer.
Ask a question
Section titled “Ask a question”POST /answer streams server-sent events.
const result = await client.answer( { q: "how long does delivery take to Dubai?", lang: "en" }, { onSources: (sources) => renderSources(sources), onDelta: (_chunk, full) => (answerEl.textContent = full), },);curl -sN "https://api.shoofai.co/v1/apps/$SHOOF_APP/answer" \ -H "x-shoof-api-key: $SHOOF_SEARCH_KEY" -H "content-type: application/json" \ -d '{ "q": "how long does delivery take to Dubai?", "lang": "en" }'The stream:
event: sourcesdata: {"sources":[{"n":1,"id":"page-shipping-en","title":"Shipping and delivery","url":"https://example.com/shipping"},{"n":2,"id":"faq-12-en","title":"Express delivery","url":"https://example.com/faq#express"}],"queryId":"Qk81…"}
event: deltadata: {"text":"Orders to Dubai arrive in 1–2 working days "}
event: deltadata: {"text":"[1], or the same day with express delivery if you order before 2 pm [2]."}
event: donedata: {"mode":"llm","stopReason":"end_turn"}| Event | Data | When |
|---|---|---|
sources |
{sources: [{n, id, title, url?}], queryId, query?} |
First, always. n is the number citations use. |
delta |
{text} |
The next piece of the answer. Append them in order. |
done |
{mode, stopReason?} |
Last. mode is llm, extractive, or none when no source was found. |
error |
{message} |
Instead of the rest, if the answer failed. |
Rendering citations
Section titled “Rendering citations”Answers are plain text with citations like [2] or [1][3]. Turn each into a
link to sources[n - 1].url:
const html = escapeHtml(result.text).replace(/\[(\d+)\]/g, (m, n) => { const s = result.sources[Number(n) - 1]; return s?.url ? `<a href="${s.url}" title="${escapeHtml(s.title)}">[${n}]</a>` : m;});With EventSource
Section titled “With EventSource”Browsers’ EventSource can only send GET requests, so there’s a GET variant with
the key in the URL:
const url = new URL(`https://api.shoofai.co/v1/apps/my-store/answer`);url.search = new URLSearchParams({ q: "how long does delivery take?", lang: "en", apiKey: "shf_pub_…" });
const es = new EventSource(url);es.addEventListener("delta", (e) => (answerEl.textContent += JSON.parse(e.data).text));es.addEventListener("done", () => es.close());Follow-up questions
Section titled “Follow-up questions”The server keeps no conversation. To ask a follow-up, send the earlier turns,
oldest first, in messages (up to 20):
{ "q": "is it waterproof?", "messages": [ { "role": "user", "content": "which trail shoe is best for mud?" }, { "role": "assistant", "content": "The Speedcross 6 has the deepest lugs for mud [1]." } ]}“Is it waterproof?” alone would retrieve nothing useful, so the question is first
rewritten into a standalone query from the conversation, such as “Speedcross 6
waterproof”. The sources event reports it as query. Without Claude, the
previous question is added to a short or referring follow-up instead.
Asked for similar items, the query is the kind of item (“trail running shoes”) rather than the one already discussed, so other items are found. Asked for cheaper ones, it carries the price as a bound (“trail running shoes under 400”), which applies as a price filter.
Claude sees the earlier turns to understand what the question refers to, but takes facts only from the new sources.
Narrow the sources
Section titled “Narrow the sources”Answers take the same filters as search. To answer only from help articles, for example:
{ "q": "can I return a sale item?", "filters": { "type": ["faq", "page"] } }A secured key’s filters apply too, so answers never cite records the visitor can’t see.
Settings and plans
Section titled “Settings and plans”| Setting | Default | Does |
|---|---|---|
answers.enabled |
true |
The app’s toggle. Off, /answer returns 403 feature_disabled and the widget hides its AI button. |
answers.maxSources |
6 | Sources per answer, 1 to 12. More sources give broader answers, at a higher cost per answer. |
Every plan includes AI answers, with a monthly allowance (300 on Free). Only
answers Claude wrote count: extractive answers and answers with no sources are
free. The allowance is a hard cap on every plan (402 quota_exceeded); paid
plans can buy a pack of 1,000 answers to go past it. See Plans.