---
title: "QuestionsAnswersWidgetItem"
slug: "cloud-sdk-search-qawidgetitem"
abstract: "The QuestionsAnswersWidgetItem class represents a questions-answers widget item."
---
# QuestionsAnswersWidgetItem

|     |     |
| --- | --- |
| Type | Class |
| Extends | `RuleWidgetItem` |
| Import path | `@sitecore-cloudsdk/search/browser` |

A widget item for a questions-answers widget.

## Constructor

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

### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `entity` | `string` | Required.<br><br>The entity associated with the widget. |
| `widgetId` | `string` | Required.<br><br>The unique identifier of the widget.<br><br>For questions and answers widgets, use the `rfkid` of the relevant question group. This `rfkid` is automatically generated[when you create a group](https://doc.sitecore.com/search/en/users/search-user-guide/en/the-questions-and-answers-capability.html), and can be found in the **Question and Answer Groups** menu. For example, `rfkid_mygroup`. |
| `questionsAnswersOptions` | [`QuestionsAnswersOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-questionsanswersoptions.html "QuestionsAnswersOptions") | Options for retrieving AI-powered questions and answers. |
| `sources` | `string[]` | Optional.<br><br>A list of source[^UUID-101b62f6-b640-ed11-1057-29646ebb9fb7_N6762bd56030ee] IDs that identify the [sources](https://doc.sitecore.com/search/en/users/search-user-guide/en/identify-the-required-source-type.html) to include results from. Useful for filtering results by source, for example, when managing multiple sites.<br><br>To find source IDs in Sitecore Search, on the menu bar, click **Sources**.<br><br>If set, the response will contain results only from the specified sources.<br><br>If unset, the response will return results from all sources.<br><br>Example: `["1062132", "1081839"]`<br><br>Minimum length: 1. |

## Properties

| Name | Type | Description |
| --- | --- | --- |
| `_keyphrase` | `string` | The text the site visitor enters in the search field to perform a search.<br><br>Minimum length: 1.<br><br>Maximum length: 100. |
| `_exactAnswer` | [`ExactAnswerOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-exactansweroptions.html "ExactAnswerOptions") | Optional.<br><br>Options to retrieve a single answer to the site visitor's query. Used in the questions-answers object of a widget item. |
| `_relatedQuestions` | [`RelatedQuestionsOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-relatedquestionsoptions.html "RelatedQuestionsOptions") | Optional.<br><br>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 { .notintoc }

```typescript
get keyphrase(): string
```

Returns the `keyphrase` property of the `QuestionsAnswersWidgetItem` instance.

### set keyphrase { .notintoc }

```typescript
set keyphrase(keyphrase: string)
```

Sets the `keyphrase` property of the `QuestionsAnswersWidgetItem` instance.

#### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `keyphrase` | `string` | The text the site visitor enters in the search field to perform a search.<br><br>Minimum length: 1.<br><br>Maximum length: 100. |

#### Errors { .notintoc }

- [`IV-0009`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/classes/troubleshooting-the-cloud-sdk.html#UUID-e753bca7-34cd-82c3-cb33-6c1996ac600f_section-idm4566641646518433950839438956 "IV errors")

### get exactAnswer { .notintoc }

```typescript
get exactAnswer(): ExactAnswerOptions | undefined
```

Returns the `exactAnswer` property of the `QuestionsAnswersWidgetItem` instance.

### set exactAnswer { .notintoc }

```typescript
set exactAnswer(exactAnswer: ExactAnswerOptions)
```

Sets the `exactAnswer` property of the `QuestionsAnswersWidgetItem` instance.

#### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `exactAnswer` | [`ExactAnswerOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-exactansweroptions.html "ExactAnswerOptions") | Options to retrieve a single answer to the site visitor's query. Used in the questions-answers object of a widget item. |

### get relatedQuestions { .notintoc }

```typescript
get relatedQuestions(): RelatedQuestionsOptions | undefined
```

Returns the `relatedQuestions` property of the `QuestionsAnswersWidgetItem` instance.

### set relatedQuestions { .notintoc }

```typescript
set relatedQuestions(relatedQuestions: RelatedQuestionsOptions)
```

Sets the `relatedQuestions` property of the `QuestionsAnswersWidgetItem` instance.

#### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `relatedQuestions` | [`RelatedQuestionsOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-relatedquestionsoptions.html "RelatedQuestionsOptions") | 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. |

## Methods

### _validateRelatedQuestions

Validates the provided `relatedQuestions`.

#### Signature { .notintoc }

```typescript
private _validateRelatedQuestions(relatedQuestions: RelatedQuestionsOptions): void
```

#### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `relatedQuestions` | [`RelatedQuestionsOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-relatedquestionsoptions.html "RelatedQuestionsOptions") | 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. |

#### Return value { .notintoc }

Returns void.

#### Errors { .notintoc }

- [`IV-0007`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/classes/troubleshooting-the-cloud-sdk.html#UUID-e753bca7-34cd-82c3-cb33-6c1996ac600f_section-idm4566641646518433950839438956 "IV errors")
- [`IV-0008`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/classes/troubleshooting-the-cloud-sdk.html#UUID-e753bca7-34cd-82c3-cb33-6c1996ac600f_section-idm4566641646518433950839438956 "IV errors")

### resetExactAnswer

Resets `exactAnswer` to `undefined`.

#### Signature { .notintoc }

```typescript
exactAnswer(): void
```

#### Return value { .notintoc }

Returns void.

### resetRelatedQuestions

Resets `relatedQuestions` to `undefined`.

#### Signature { .notintoc }

```typescript
resetRelatedQuestions(): void
```

#### Return value { .notintoc }

Returns void.

### toDTO

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

#### Signature { .notintoc }

```typescript
toDTO(): QuestionsAnswersWidgetItemDTO
```

#### Return value { .notintoc }

Returns the `QuestionsAnswersWidgetItem` instance in a standardized DTO format.

[^UUID-101b62f6-b640-ed11-1057-29646ebb9fb7_N6762bd56030ee]: A connector that retrieves items from a specified website, document, or repository, and indexes them so they are searchable. A source can be, for example, a web crawler, an API crawler, or an API push.
