sendMessage method
Sends a chat message and streams the response for the specified agent space execution
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter agentSpaceId :
The agent space identifier
Parameter content :
The user message content
Parameter executionId :
The execution identifier for the chat session
Parameter context :
Optional context for the message
Parameter userId :
User identifier. This field is deprecated and will be ignored — the
service resolves user identity from the authenticated session.
Implementation
Future<SendMessageResponse> sendMessage({
required String agentSpaceId,
required String content,
required String executionId,
SendMessageContext? context,
String? userId,
}) async {
final $payload = <String, dynamic>{
'content': content,
'executionId': executionId,
if (context != null) 'context': context,
if (userId != null) 'userId': userId,
};
final response = await _protocol.sendRaw(
payload: $payload,
method: 'POST',
requestUri:
'/agents/agent-space/${Uri.encodeComponent(agentSpaceId)}/chat/sendMessage',
hostPrefix: 'dp.',
exceptionFnMap: _exceptionFns,
);
final $json = await _s.jsonFromResponse(response);
return SendMessageResponse(
events: SendMessageEvents.fromJson($json),
);
}