sendMessage method
- required String assistantId,
- required MessageInput message,
- required String sessionId,
- required MessageType type,
- String? aiAgentId,
- String? clientToken,
- MessageConfiguration? configuration,
- ConversationContext? conversationContext,
- Map<
String, String> ? metadata, - String? orchestratorUseCase,
- String? originRequestId,
Submits a message to the Amazon Q in Connect session.
May throw AccessDeniedException.
May throw ConflictException.
May throw DependencyFailedException.
May throw RequestTimeoutException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter assistantId :
The identifier of the Amazon Q in Connect assistant.
Parameter message :
The message data to submit to the Amazon Q in Connect session.
Parameter sessionId :
The identifier of the Amazon Q in Connect session.
Parameter type :
The message type.
Parameter aiAgentId :
The identifier of the AI Agent to use for processing the message.
Parameter clientToken :
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request. If not provided, the AWS SDK populates this
field.For more information about idempotency, see Making retries safe with
idempotent APIs.
Parameter configuration :
The configuration of the SendMessage
request.
Parameter conversationContext :
The conversation context before the Amazon Q in Connect session.
Parameter metadata :
Additional metadata for the message.
Parameter orchestratorUseCase :
The orchestrator use case for message processing.
Parameter originRequestId :
Request identifier from the origin system, used for end-to-end tracing
across spans.
Implementation
Future<SendMessageResponse> sendMessage({
required String assistantId,
required MessageInput message,
required String sessionId,
required MessageType type,
String? aiAgentId,
String? clientToken,
MessageConfiguration? configuration,
ConversationContext? conversationContext,
Map<String, String>? metadata,
String? orchestratorUseCase,
String? originRequestId,
}) async {
final $payload = <String, dynamic>{
'message': message,
'type': type.value,
if (aiAgentId != null) 'aiAgentId': aiAgentId,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (configuration != null) 'configuration': configuration,
if (conversationContext != null)
'conversationContext': conversationContext,
if (metadata != null) 'metadata': metadata,
if (orchestratorUseCase != null)
'orchestratorUseCase': orchestratorUseCase,
if (originRequestId != null) 'originRequestId': originRequestId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/assistants/${Uri.encodeComponent(assistantId)}/sessions/${Uri.encodeComponent(sessionId)}/message',
exceptionFnMap: _exceptionFns,
);
return SendMessageResponse.fromJson(response);
}