client.api.ask

Ask APIs, available as client.api.ask.

Instance properties

client.api.ask.userHistory

User history APIs, for the user's past conversation threads.

Type: UserHistory

Instance methods

client.api.ask.answers(payload, [options])

Get the answers of multiple questions at once, as they are generated. Each iteration yields an array of the answers that were still unfinished, so a finished answer is not polled again. Once all are finished, the iteration yields undefined and ends.

Pass an array of question IDs as a shortcut of { question_ids }.

Parameter Type Description
payload Object or string[] Request payload, or an array of question IDs.
options Object Request options, including the polling options of IterableApiStub. Optional.

Returns Promise<IterableApiStub>.

client.api.ask.autocomplete(payload, [options])

Get autocomplete suggestions for a partial question.

Parameter Type Description
payload Object
options Object Request options. Optional.

Returns Promise<Object>.

client.api.ask.querySuggestion(payload, [options])

Get query suggestions.

Parameter Type Description
payload Object
options Object Request options. Optional.

Returns Promise<Object>.

client.api.ask.questions(payload, [options])

Ask a question, and get the answer as it is generated.

Pass a question ID instead of a payload to follow an existing question, without asking again.

Parameter Type Description
payload Object or string Request payload, or a question ID.
options Object Request options, including the polling options of IterableApiStub. Optional.

Returns Promise<IterableApiStub>: The answer, which has a questionId property.

const answer = await client.api.ask.questions({ question: "What is Miso?" });
for await (const response of answer) {
  console.log(response.answer);
}

client.api.ask.relatedQuestions(payload, [options])

Get questions related to a given question.

Parameter Type Description
payload Object
options Object Request options. Optional.

Returns Promise<Object>.

client.api.ask.search(payload, [options])

Search with a query, with an answer generated over time.

If the response comes with a question ID, it is returned as an IterableApiStub with the response fields (such as the search results) on it, to follow the answer. Otherwise the response is returned as is.

Pass a question ID instead of a payload to follow an existing search.

Parameter Type Description
payload Object or string Request payload, or a question ID.
options Object Request options, including the polling options of IterableApiStub. Optional.

Returns Promise<IterableApiStub | Object>.

client.api.ask.searchAutocomplete(payload, [options])

Get autocomplete suggestions for a partial search query.

Parameter Type Description
payload Object
options Object Request options. Optional.

Returns Promise<Object>.

client.api.ask.trendingQuestions(payload, [options])

Get trending questions.

Parameter Type Description
payload Object
options Object Request options. Optional.

Returns Promise<Object>.