Explore — API Configuration
Choose how many questions Explore shows under an article and which articles they come from, and change the response before Explore shows it.
useApi takes the request body that Explore sends to the
Related Questions API. product_id
names the article, and the other fields control what comes back. For a page
with no article, see Trending Questions.
Number of questions
rows sets how many questions to ask for. The default is 5.
workflow.useApi({
product_id: "art_001",
rows: 3,
});
Miso returns fewer than rows questions when it has fewer for that article.
Filter the source articles
fq restricts which articles Miso draws the questions from. It takes the same
filter syntax as every other Miso endpoint.
workflow.useApi({
product_id: "art_001",
fq: 'categories:"Markets"',
});
Render the filter from your CMS, the same way as product_id. To keep each
article's questions inside its own section, write that section into the
filter.
Filter values are matched exactly. Check yours against the rules for case and quoting.
Change the response
useDataProcessor takes a function that gets each response before Explore
renders it. data.value holds the
Related Questions API response, and
related_questions is the list of questions. Return data, changed or not.
This one drops the questions that are too long for a narrow column:
workflow.useDataProcessor((data) => {
const { value } = data;
if (!value || !value.related_questions) {
return data;
}
return {
...data,
value: {
...value,
related_questions: value.related_questions.filter((question) => question.text.length <= 80),
},
};
});
The SDK calls the function each time the data changes. Before the response
arrives, data.value is undefined. Check for the field you change, and
return data as it is when the field is missing.
Each call to useDataProcessor adds a function, and the functions run in the
order you add them. clearDataProcessor() removes the ones added on the same
object.
