Shopping Assistant API
POSTOverview
Section titled “Overview”Use the Shopping Assistant API to power a question-and-answer product finder on your own site.
You define the assistant in the Luigi’s Box app. Your integration then calls this endpoint to:
- get the first question
- send back the user’s selected answers
- receive the next question together with the currently matching products
In other words, this endpoint does not just return products. It returns the current state of the guided flow: the next question to show and the product list that matches the answers collected so far.
Luigi’s Box Assistant can learn from user interactions when Luigi’s Box analytics is integrated with your site. For click, add-to-cart, and conversion tracking, see Shopping Assistant analytics.
Request
Section titled “Request”Send a POST request to the endpoint. Query parameters identify the tracker and assistant. The JSON body carries the dialogue state and runtime overrides.
Query parameters
Section titled “Query parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tracker_id | string | ✓ | Your site identifier within Luigi’s Box. You can find this identifier in every URL in the Luigi’s Box app once you are logged in. |
assistant_handle | string | ✓ | The unique handle of the assistant to use. |
user_id | string | Recommended | The unique identifier of the end-user. If it matches the user ID collected in analytics, it can connect assistant requests to the same user or session and support personalization where available. |
Request body parameters
Section titled “Request body parameters”| Parameter | Type | Description |
|---|---|---|
assistant_version | integer | The version of the assistant to use. This parameter is required. Use
|
steps | array[object] | An array of previous interactions (questions and answers) in the dialogue. Each step contains the question handle and one or more selected option handles. Send an empty array or omit this field for the first request. |
next_question_handle | string | The handle of the next question to be presented to the user. If an
option returns |
size | integer | The number of product results to return. Default: |
price_field | string | The product field used for calculating price ranges. Defaults to
|
hit_fields | string | A comma-separated list of hit attributes to include in the response, for
example |
field_overrides | object | An object that replaces fields used by the assistant’s filters and
facets with other indexed fields at request time. A typical use case is
runtime pricing, for example replacing |
sort | string | The sorting criteria for the product results, for example
|
context | object | An object that overrides fields used by search. The fields available for
overriding are |
f | array[string] | An array of |
f_must | array[string] | An array of |
neg_f | array[string] | An array of |
neg_f_must | array[string] | An array of |
search_in_variants | boolean | A boolean value indicating whether to search in product variants. If set
to |
non_collapsed_variants | boolean | A boolean value indicating whether to return non-collapsed variants in
the results. If set to |
Step object fields
Section titled “Step object fields”| Field | Type | Description |
|---|---|---|
question_handle | string | The handle of the question the user answered. |
option_handles | array[string] | An array of selected option handles for that question. |
Request headers
Section titled “Request headers”| Header | Value | Required | Description |
|---|---|---|---|
Content-Type | application/json | ✓ | The content type of the request body. |
Accept-Encoding | gzip, deflate | Recommended | The accepted response compression formats. |
How to make a request
Section titled “How to make a request”The endpoint is stateful from your application’s perspective. Your frontend or backend keeps track of answered steps and resends them on every request.
- Start the flow with an empty
stepsarray. - Render the returned
questionandhits. - Append the selected answer to
steps. - If the selected option included
next_question_handle, send that exact value in the next request. - Call the endpoint again with the updated state.
- Stop when
questionbecomesnull.
HTTP response
Section titled “HTTP response”The endpoint returns the current result set and, when applicable, the next question in the assistant flow.
Top-level fields
Section titled “Top-level fields”| Field | Description |
|---|---|
assistant_handle | The handle of the assistant used for this response. |
tracker_id | The Luigi’s Box tracker identifier. |
hits | An array of hit objects matching the current dialogue state. |
important_attributes | An array of attribute names Luigi’s Box considers useful to highlight in the hit list. |
avatar_image_link | The URL of the assistant avatar image, if available. |
intro_html | The introductory HTML for the assistant flow, if available. |
question | The next question to display, or null when the flow is finished. |
steps | An echo of the current step state, when applicable. |
Hit fields
Section titled “Hit fields”| Field | Description |
|---|---|
hits[].url | The URL of the matched product. |
hits[].type | The type of the returned hit. |
hits[].attributes | An object containing the product attributes returned in the response. The exact keys depend on your catalog and hit_fields. |
hits[].updated_at | The timestamp of the last hit update, if available. |
Question fields
Section titled “Question fields”| Field | Description |
|---|---|
question.question_handle | The unique handle of the question. |
question.title_html | The HTML-formatted title of the question. |
question.description_html | The HTML-formatted description of the question, if available. |
question.image_link | The URL of the question image, if available. |
question.type | The type of the question: single_choice or multi_choice. |
question.options | An array of options available for the next answer. |
Option fields
Section titled “Option fields”| Field | Description |
|---|---|
option_handle | The unique handle of the option. |
title_html | The HTML-formatted title of the option. |
description_html | The HTML-formatted description of the option, if available. |
parent_question_handle | The handle of the parent question, if available. |
next_question_handle | The handle of the next question, if fixed by the assistant definition. |
image_link | The URL of the option image, if available. |
color_code | The color swatch value of the option, if available. |
hits_count | The number of products matching the option. |
price_range | The computed price range for the products behind that option. |
Errors
Section titled “Errors”The API uses standard HTTP status codes. Note that the format of the error response body can vary depending on the type of error.
Parse the status code first, then inspect the response body when one is present.
| Status | Meaning |
|---|---|
400 Bad Request | An invalid request. This includes malformed input, incorrect data types, wrong HTTP method, or assistant lookup failures. |
404 Not Found | A request to an endpoint path that does not exist. Assistant lookup failures are returned as 400, not 404. |
500 Internal Server Error | A temporary internal error. Retry with backoff, and log the Request-Id if the response includes one. |
Was this page helpful?
Thanks.