chatSync method

Future<ChatSyncOutput> chatSync({
  1. required String applicationId,
  2. ActionExecution? actionExecution,
  3. List<AttachmentInput>? attachments,
  4. AttributeFilter? attributeFilter,
  5. AuthChallengeResponse? authChallengeResponse,
  6. ChatMode? chatMode,
  7. ChatModeConfiguration? chatModeConfiguration,
  8. String? clientToken,
  9. String? conversationId,
  10. String? parentMessageId,
  11. List<String>? userGroups,
  12. String? userId,
  13. String? userMessage,
})

Starts or continues a non-streaming Amazon Q Business conversation.

May throw AccessDeniedException. May throw ConflictException. May throw ExternalResourceException. May throw InternalServerException. May throw LicenseNotFoundException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter applicationId : The identifier of the Amazon Q Business application linked to the Amazon Q Business conversation.

Parameter actionExecution : A request from an end user to perform an Amazon Q Business plugin action.

Parameter attachments : A list of files uploaded directly during chat. You can upload a maximum of 5 files of upto 10 MB each.

Parameter attributeFilter : Enables filtering of Amazon Q Business web experience responses based on document attributes or metadata fields.

Parameter authChallengeResponse : An authentication verification event response by a third party authentication server to Amazon Q Business.

Parameter chatMode : The chatMode parameter determines the chat modes available to Amazon Q Business users:

  • RETRIEVAL_MODE - If you choose this mode, Amazon Q generates responses solely from the data sources connected and indexed by the application. If an answer is not found in the data sources or there are no data sources available, Amazon Q will respond with a "No Answer Found" message, unless LLM knowledge has been enabled. In that case, Amazon Q will generate a response from the LLM knowledge
  • CREATOR_MODE - By selecting this mode, you can choose to generate responses only from the LLM knowledge. You can also attach files and have Amazon Q generate a response based on the data in those files. If the attached files do not contain an answer for the query, Amazon Q will automatically fall back to generating a response from the LLM knowledge.
  • PLUGIN_MODE - By selecting this mode, users can choose to use plugins in chat to get their responses.
For more information, see Admin controls and guardrails, Plugins, and Response sources.

Parameter chatModeConfiguration : The chat mode configuration for an Amazon Q Business application.

Parameter clientToken : A token that you provide to identify a chat request.

Parameter conversationId : The identifier of the Amazon Q Business conversation.

Parameter parentMessageId : The identifier of the previous system message in a conversation.

Parameter userGroups : The group names that a user associated with the chat input belongs to.

Parameter userId : The identifier of the user attached to the chat input.

Parameter userMessage : A end user message in a conversation.

Implementation

Future<ChatSyncOutput> chatSync({
  required String applicationId,
  ActionExecution? actionExecution,
  List<AttachmentInput>? attachments,
  AttributeFilter? attributeFilter,
  AuthChallengeResponse? authChallengeResponse,
  ChatMode? chatMode,
  ChatModeConfiguration? chatModeConfiguration,
  String? clientToken,
  String? conversationId,
  String? parentMessageId,
  List<String>? userGroups,
  String? userId,
  String? userMessage,
}) async {
  final $query = <String, List<String>>{
    if (userGroups != null) 'userGroups': userGroups,
    if (userId != null) 'userId': [userId],
  };
  final $payload = <String, dynamic>{
    if (actionExecution != null) 'actionExecution': actionExecution,
    if (attachments != null) 'attachments': attachments,
    if (attributeFilter != null) 'attributeFilter': attributeFilter,
    if (authChallengeResponse != null)
      'authChallengeResponse': authChallengeResponse,
    if (chatMode != null) 'chatMode': chatMode.value,
    if (chatModeConfiguration != null)
      'chatModeConfiguration': chatModeConfiguration,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (conversationId != null) 'conversationId': conversationId,
    if (parentMessageId != null) 'parentMessageId': parentMessageId,
    if (userMessage != null) 'userMessage': userMessage,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/applications/${Uri.encodeComponent(applicationId)}/conversations?sync',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ChatSyncOutput.fromJson(response);
}