Explore — Trending Questions
Show the questions trending across your site on a page with no article, such as a homepage or a section front.
Explore asks for related questions by default, and those need an article. Below we switch the workflow to trending questions, choose how many to show, and limit them to one brand.
You need a working Explore page first. See Explore — Quick Start.
Ask for trending questions
Give useApi the API name as the first argument, and the request body as the
second. Leave out product_id:
workflow.useApi("trending_questions", {
rows: 5,
});
Call useApi before start(). The elements, useLink and start() stay as
they are in the quick start.
The body takes the fields of the Trending Questions API:
| Field | Default | What it does |
|---|---|---|
rows | 10 | How many questions to ask for. |
_meta.site | — | Limits the questions to one site or brand, for a multi-brand app. |
Limit the questions to one brand
In an app that holds more than one brand, set _meta.site to the brand of the
page:
workflow.useApi("trending_questions", {
rows: 5,
_meta: { site: "markets" },
});
Render the value from your CMS, so each brand's homepage passes its own.
Change the response
The response puts the questions in related_questions, the same key as the
Related Questions API. A
useDataProcessor function from
API Configuration works for
both APIs without a change.
If it does not work
| Symptom | Cause |
|---|---|
| No questions appear | Explore is not enabled for this environment. |
The request fails with product_id is required | useApi has no API name, so the workflow asks for related questions. |
| Questions from another brand appear | The body has no _meta.site. |
Next
- API Configuration — the options for related questions, and how to change the response.
- UI Customization — change the parts around the questions, and when they show.
- Trending Questions API — get the questions from your own back end.
