GetRecommendationsCommand

  • GetRecommendations API will be discontinued starting June 1, 2024. To receive generative responses after March 1, 2024 you will need to create a new Assistant in the Connect console and integrate the Amazon Q in Connect JavaScript library (amazon-q-connectjs) into your applications.

This API will be discontinued starting June 1, 2024. To receive generative responses after March 1, 2024, you will need to create a new Assistant in the Amazon Connect console and integrate the Amazon Q in Connect JavaScript library (amazon-q-connectjs) into your applications.

Retrieves recommendations for the specified session. To avoid retrieving the same recommendations in subsequent calls, use NotifyRecommendationsReceived . This API supports long-polling behavior with the waitTimeSeconds parameter. Short poll is the default behavior and only returns recommendations already available. To perform a manual query against an assistant, use QueryAssistant .

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { QConnectClient, GetRecommendationsCommand } from "@aws-sdk/client-qconnect"; // ES Modules import
// const { QConnectClient, GetRecommendationsCommand } = require("@aws-sdk/client-qconnect"); // CommonJS import
const client = new QConnectClient(config);
const input = { // GetRecommendationsRequest
  assistantId: "STRING_VALUE", // required
  sessionId: "STRING_VALUE", // required
  maxResults: Number("int"),
  waitTimeSeconds: Number("int"),
  nextChunkToken: "STRING_VALUE",
};
const command = new GetRecommendationsCommand(input);
const response = await client.send(command);
// { // GetRecommendationsResponse
//   recommendations: [ // RecommendationList // required
//     { // RecommendationData
//       recommendationId: "STRING_VALUE", // required
//       document: { // Document
//         contentReference: { // ContentReference
//           knowledgeBaseArn: "STRING_VALUE",
//           knowledgeBaseId: "STRING_VALUE",
//           contentArn: "STRING_VALUE",
//           contentId: "STRING_VALUE",
//           sourceURL: "STRING_VALUE",
//           referenceType: "STRING_VALUE",
//         },
//         title: { // DocumentText
//           text: "STRING_VALUE",
//           highlights: [ // Highlights
//             { // Highlight
//               beginOffsetInclusive: Number("int"),
//               endOffsetExclusive: Number("int"),
//             },
//           ],
//         },
//         excerpt: {
//           text: "STRING_VALUE",
//           highlights: [
//             {
//               beginOffsetInclusive: Number("int"),
//               endOffsetExclusive: Number("int"),
//             },
//           ],
//         },
//       },
//       relevanceScore: Number("double"),
//       relevanceLevel: "STRING_VALUE",
//       type: "STRING_VALUE",
//       data: { // DataSummary
//         reference: { // DataReference Union: only one key present
//           contentReference: {
//             knowledgeBaseArn: "STRING_VALUE",
//             knowledgeBaseId: "STRING_VALUE",
//             contentArn: "STRING_VALUE",
//             contentId: "STRING_VALUE",
//             sourceURL: "STRING_VALUE",
//             referenceType: "STRING_VALUE",
//           },
//           generativeReference: { // GenerativeReference
//             modelId: "STRING_VALUE",
//             generationId: "STRING_VALUE",
//           },
//         },
//         details: { // DataDetails Union: only one key present
//           contentData: { // ContentDataDetails
//             textData: { // TextData
//               title: {
//                 text: "STRING_VALUE",
//                 highlights: [
//                   {
//                     beginOffsetInclusive: Number("int"),
//                     endOffsetExclusive: Number("int"),
//                   },
//                 ],
//               },
//               excerpt: {
//                 text: "STRING_VALUE",
//                 highlights: [
//                   {
//                     beginOffsetInclusive: Number("int"),
//                     endOffsetExclusive: Number("int"),
//                   },
//                 ],
//               },
//             },
//             rankingData: { // RankingData
//               relevanceScore: Number("double"),
//               relevanceLevel: "STRING_VALUE",
//             },
//           },
//           generativeData: { // GenerativeDataDetails
//             completion: "STRING_VALUE", // required
//             references: [ // DataSummaryList // required
//               {
//                 reference: {//  Union: only one key present
//                   contentReference: "<ContentReference>",
//                   generativeReference: {
//                     modelId: "STRING_VALUE",
//                     generationId: "STRING_VALUE",
//                   },
//                 },
//                 details: {//  Union: only one key present
//                   contentData: {
//                     textData: {
//                       title: "<DocumentText>",
//                       excerpt: "<DocumentText>",
//                     },
//                     rankingData: {
//                       relevanceScore: Number("double"),
//                       relevanceLevel: "STRING_VALUE",
//                     },
//                   },
//                   generativeData: {
//                     completion: "STRING_VALUE", // required
//                     references: [ // required
//                       "<DataSummary>",
//                     ],
//                     rankingData: {
//                       relevanceScore: Number("double"),
//                       relevanceLevel: "STRING_VALUE",
//                     },
//                   },
//                   intentDetectedData: { // IntentDetectedDataDetails
//                     intent: "STRING_VALUE", // required
//                     intentId: "STRING_VALUE", // required
//                   },
//                   sourceContentData: { // SourceContentDataDetails
//                     id: "STRING_VALUE", // required
//                     type: "STRING_VALUE", // required
//                     textData: {
//                       title: "<DocumentText>",
//                       excerpt: "<DocumentText>",
//                     },
//                     rankingData: {
//                       relevanceScore: Number("double"),
//                       relevanceLevel: "STRING_VALUE",
//                     },
//                     citationSpan: { // CitationSpan
//                       beginOffsetInclusive: Number("int"),
//                       endOffsetExclusive: Number("int"),
//                     },
//                   },
//                   generativeChunkData: { // GenerativeChunkDataDetails
//                     completion: "STRING_VALUE",
//                     references: [
//                       "<DataSummary>",
//                     ],
//                     nextChunkToken: "STRING_VALUE",
//                   },
//                 },
//               },
//             ],
//             rankingData: {
//               relevanceScore: Number("double"),
//               relevanceLevel: "STRING_VALUE",
//             },
//           },
//           intentDetectedData: {
//             intent: "STRING_VALUE", // required
//             intentId: "STRING_VALUE", // required
//           },
//           sourceContentData: {
//             id: "STRING_VALUE", // required
//             type: "STRING_VALUE", // required
//             textData: {
//               title: "<DocumentText>",
//               excerpt: "<DocumentText>",
//             },
//             rankingData: "<RankingData>", // required
//             citationSpan: {
//               beginOffsetInclusive: Number("int"),
//               endOffsetExclusive: Number("int"),
//             },
//           },
//           generativeChunkData: {
//             completion: "STRING_VALUE",
//             references: [
//               "<DataSummary>",
//             ],
//             nextChunkToken: "STRING_VALUE",
//           },
//         },
//       },
//     },
//   ],
//   triggers: [ // RecommendationTriggerList
//     { // RecommendationTrigger
//       id: "STRING_VALUE", // required
//       type: "STRING_VALUE", // required
//       source: "STRING_VALUE", // required
//       data: { // RecommendationTriggerData Union: only one key present
//         query: { // QueryRecommendationTriggerData
//           text: "STRING_VALUE",
//         },
//       },
//       recommendationIds: [ // RecommendationIdList // required
//         "STRING_VALUE",
//       ],
//     },
//   ],
// };

GetRecommendationsCommand Input

See GetRecommendationsCommandInput for more details

Parameter
Type
Description
assistantId
Required
string | undefined

The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

sessionId
Required
string | undefined

The identifier of the session. Can be either the ID or the ARN. URLs cannot contain the ARN.

maxResults
number | undefined

The maximum number of results to return per page.

nextChunkToken
string | undefined

The token for the next set of chunks. Use the value returned in the previous response in the next request to retrieve the next set of chunks.

waitTimeSeconds
number | undefined

The duration (in seconds) for which the call waits for a recommendation to be made available before returning. If a recommendation is available, the call returns sooner than WaitTimeSeconds. If no messages are available and the wait time expires, the call returns successfully with an empty list.

GetRecommendationsCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
recommendations
Required
RecommendationData[] | undefined

The recommendations.

triggers
RecommendationTrigger[] | undefined

The triggers corresponding to recommendations.

Throws

Name
Fault
Details
AccessDeniedException
client

You do not have sufficient access to perform this action.

ResourceNotFoundException
client

The specified resource does not exist.

ValidationException
client

The input fails to satisfy the constraints specified by a service.

QConnectServiceException
Base exception class for all service exceptions from QConnect service.