1. Classes

QuestionsAnswersWidgetItem

Version:
TypeClass
ExtendsRuleWidgetItem
Import path@sitecore-cloudsdk/search/browser

A widget item for a questions-answers widget.

Constructor

QuestionsAnswersWidgetItem(
  entity: string,
  widgetId: string,
  questionsAnswersOptions: QuestionsAnswersOptions,
  sources?: ArrayOfAtLeastOne<string>
)

Parameters

NameTypeDescription
entitystringRequired.

The entity associated with the widget.
widgetIdstringRequired.

The unique identifier of the widget.

For questions and answers widgets, use the rfkid of the relevant question group. This rfkid is automatically generatedwhen you create a group, and can be found in the Question and Answer Groups menu. For example, rfkid_mygroup.
questionsAnswersOptionsQuestionsAnswersOptionsOptions for retrieving AI-powered questions and answers.
sourcesstring[]Optional.

A list of source IDs that identify the sources to include results from. Useful for filtering results by source, for example, when managing multiple sites.

To find source IDs in Sitecore Search, on the menu bar, click Sources.

If set, the response will contain results only from the specified sources.

If unset, the response will return results from all sources.

Example: ["1062132", "1081839"]

Minimum length: 1.

Properties

NameTypeDescription
_keyphrasestringThe text the site visitor enters in the search field to perform a search.

Minimum length: 1.

Maximum length: 100.
_exactAnswerExactAnswerOptionsOptional.

Options to retrieve a single answer to the site visitor's query. Used in the questions-answers object of a widget item.
_relatedQuestionsRelatedQuestionsOptionsOptional.

Options to retrieve AI-generated question-and-answer pairs relevant to the site visitor's query. Used in the questions-answers object of a widget item.

Accessors

The following properties are available to get and set:

get keyphrase

get keyphrase(): string

Returns the keyphrase property of the QuestionsAnswersWidgetItem instance.

set keyphrase

set keyphrase(keyphrase: string)

Sets the keyphrase property of the QuestionsAnswersWidgetItem instance.

Parameters

NameTypeDescription
keyphrasestringThe text the site visitor enters in the search field to perform a search.

Minimum length: 1.

Maximum length: 100.

Errors

get exactAnswer

get exactAnswer(): ExactAnswerOptions | undefined

Returns the exactAnswer property of the QuestionsAnswersWidgetItem instance.

set exactAnswer

set exactAnswer(exactAnswer: ExactAnswerOptions)

Sets the exactAnswer property of the QuestionsAnswersWidgetItem instance.

Parameters

NameTypeDescription
exactAnswerExactAnswerOptionsOptions to retrieve a single answer to the site visitor's query. Used in the questions-answers object of a widget item.

get relatedQuestions

get relatedQuestions(): RelatedQuestionsOptions | undefined

Returns the relatedQuestions property of the QuestionsAnswersWidgetItem instance.

set relatedQuestions

set relatedQuestions(relatedQuestions: RelatedQuestionsOptions)

Sets the relatedQuestions property of the QuestionsAnswersWidgetItem instance.

Parameters

NameTypeDescription
relatedQuestionsRelatedQuestionsOptionsOptions to retrieve AI-generated question-and-answer pairs relevant to the site visitor's query. Used in the questions-answers object of a widget item.

Methods

_validateRelatedQuestions

Validates the provided relatedQuestions.

Signature

private _validateRelatedQuestions(relatedQuestions: RelatedQuestionsOptions): void

Parameters

NameTypeDescription
relatedQuestionsRelatedQuestionsOptionsOptions to retrieve AI-generated question-and-answer pairs relevant to the site visitor's query. Used in the questions-answers object of a widget item.

Return value

Returns void.

Errors

resetExactAnswer

Resets exactAnswer to undefined.

Signature

exactAnswer(): void

Return value

Returns void.

resetRelatedQuestions

Resets relatedQuestions to undefined.

Signature

resetRelatedQuestions(): void

Return value

Returns void.

toDTO

Maps the QuestionsAnswersWidgetItem instance to its DTO (data transfer object) format.

Signature

toDTO(): QuestionsAnswersWidgetItemDTO

Return value

Returns the QuestionsAnswersWidgetItem instance in a standardized DTO format.

If you have suggestions for improving this article, let us know!