chat method

Future<ChatOutput> chat({
  1. required String applicationId,
  2. String? clientToken,
  3. String? conversationId,
  4. ChatInputStream? inputStream,
  5. String? parentMessageId,
  6. List<String>? userGroups,
  7. String? userId,
})

Starts or continues a 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 a streaming Amazon Q Business conversation.

Parameter clientToken : A token that you provide to identify the chat input.

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

Parameter inputStream : The streaming input for the Chat API.

Parameter parentMessageId : The identifier used to associate a user message with a AI generated response.

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.

Implementation

Future<ChatOutput> chat({
  required String applicationId,
  String? clientToken,
  String? conversationId,
  ChatInputStream? inputStream,
  String? parentMessageId,
  List<String>? userGroups,
  String? userId,
}) async {
  final $query = <String, List<String>>{
    if (clientToken != null) 'clientToken': [clientToken],
    if (conversationId != null) 'conversationId': [conversationId],
    if (parentMessageId != null) 'parentMessageId': [parentMessageId],
    if (userGroups != null) 'userGroups': userGroups,
    if (userId != null) 'userId': [userId],
  };
  final response = await _protocol.sendRaw(
    payload: inputStream,
    method: 'POST',
    requestUri:
        '/applications/${Uri.encodeComponent(applicationId)}/conversations',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  final $json = await _s.jsonFromResponse(response);
  return ChatOutput(
    outputStream: ChatOutputStream.fromJson($json),
  );
}