Skip to content

Shopping Assistant API

POST
View MD

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:

  1. get the first question
  2. send back the user’s selected answers
  3. 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.

Send a POST request to the endpoint. Query parameters identify the tracker and assistant. The JSON body carries the dialogue state and runtime overrides.

ParameterTypeRequiredDescription
tracker_idstringYour 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_handlestringThe unique handle of the assistant to use.
user_idstringRecommendedThe 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.
ParameterTypeDescription
assistant_versioninteger

The version of the assistant to use. This parameter is required. Use -1 for the latest published version, or pass a specific published version when you need deterministic behavior.

stepsarray[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_handlestring

The handle of the next question to be presented to the user. If an option returns next_question_handle, pass it in your next request to continue that branch of the flow.

sizeinteger

The number of product results to return. Default: 10. Maximum: 200.

price_fieldstring

The product field used for calculating price ranges. Defaults to price_amount. If you want to use a different numeric field, specify it here. If the field does not exist or is not numeric, the request returns 400.

hit_fieldsstring

A comma-separated list of hit attributes to include in the response, for example title,sku,image_link. This controls fields inside each hit’s attributes object. Top-level hit fields such as url are always returned.

field_overridesobject

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 price_amount with price_amount_7 for a logged-in user. Source and target fields must exist and use compatible types.

sortstring

The sorting criteria for the product results, for example price:asc or price:desc,title:asc. If not provided, the default sorting is applied.

contextobject

An object that overrides fields used by search. The fields available for overriding are availability_field, availability_rank_field, freshness_field, boost_field, geo_location_field, margin_field, absolute_margin_field, and discount_field.

farray[string]

An array of OR filters to apply to the product results (for example category:electronics or price:1|5).

f_mustarray[string]

An array of AND filters that must match the product results (for example category:electronics or price:1|5 ).

neg_farray[string]

An array of OR filters to exclude product results (for example category:electronics or price:1|5).

neg_f_mustarray[string]

An array of AND filters to exclude the product results (for example category:electronics or price:1|5).

search_in_variantsboolean

A boolean value indicating whether to search in product variants. If set to true, the search includes variants of products. Defaults to the search setting configured in the app.

non_collapsed_variantsboolean

A boolean value indicating whether to return non-collapsed variants in the results. If set to true, variants are returned as separate items in the results. Works only when search_in_variants is allowed.

FieldTypeDescription
question_handlestringThe handle of the question the user answered.
option_handlesarray[string]An array of selected option handles for that question.
HeaderValueRequiredDescription
Content-Typeapplication/jsonThe content type of the request body.
Accept-Encodinggzip, deflateRecommendedThe accepted response compression formats.

The endpoint is stateful from your application’s perspective. Your frontend or backend keeps track of answered steps and resends them on every request.

  1. Start the flow with an empty steps array.
  2. Render the returned question and hits.
  3. Append the selected answer to steps.
  4. If the selected option included next_question_handle, send that exact value in the next request.
  5. Call the endpoint again with the updated state.
  6. Stop when question becomes null.

The endpoint returns the current result set and, when applicable, the next question in the assistant flow.

FieldDescription
assistant_handleThe handle of the assistant used for this response.
tracker_idThe Luigi’s Box tracker identifier.
hitsAn array of hit objects matching the current dialogue state.
important_attributesAn array of attribute names Luigi’s Box considers useful to highlight in the hit list.
avatar_image_linkThe URL of the assistant avatar image, if available.
intro_htmlThe introductory HTML for the assistant flow, if available.
questionThe next question to display, or null when the flow is finished.
stepsAn echo of the current step state, when applicable.
FieldDescription
hits[].urlThe URL of the matched product.
hits[].typeThe type of the returned hit.
hits[].attributesAn object containing the product attributes returned in the response. The exact keys depend on your catalog and hit_fields.
hits[].updated_atThe timestamp of the last hit update, if available.
FieldDescription
question.question_handleThe unique handle of the question.
question.title_htmlThe HTML-formatted title of the question.
question.description_htmlThe HTML-formatted description of the question, if available.
question.image_linkThe URL of the question image, if available.
question.typeThe type of the question: single_choice or multi_choice.
question.optionsAn array of options available for the next answer.
FieldDescription
option_handleThe unique handle of the option.
title_htmlThe HTML-formatted title of the option.
description_htmlThe HTML-formatted description of the option, if available.
parent_question_handleThe handle of the parent question, if available.
next_question_handleThe handle of the next question, if fixed by the assistant definition.
image_linkThe URL of the option image, if available.
color_codeThe color swatch value of the option, if available.
hits_countThe number of products matching the option.
price_rangeThe computed price range for the products behind that option.

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.

StatusMeaning
400 Bad RequestAn invalid request. This includes malformed input, incorrect data types, wrong HTTP method, or assistant lookup failures.
404 Not FoundA request to an endpoint path that does not exist. Assistant lookup failures are returned as 400, not 404.
500 Internal Server ErrorA temporary internal error. Retry with backoff, and log the Request-Id if the response includes one.