startChatContact method
- required String contactFlowId,
- required String instanceId,
- required ParticipantDetails participantDetails,
- Map<
String, String> ? attributes, - String? clientToken,
- ChatMessage? initialMessage,
Initiates a contact flow to start a new chat for the customer. Response of this API provides a token required to obtain credentials from the CreateParticipantConnection API in the Amazon Connect Participant Service.
When a new chat contact is successfully created, clients need to subscribe to the participant’s connection for the created chat within 5 minutes. This is achieved by invoking CreateParticipantConnection with WEBSOCKET and CONNECTION_CREDENTIALS.
A 429 error occurs in two situations:
-
API rate limit is exceeded. API TPS throttling returns a
TooManyRequests
exception from the API Gateway. -
The quota
for concurrent active chats is exceeded. Active chat throttling
returns a
LimitExceededException
.
May throw InvalidRequestException. May throw InvalidParameterException. May throw ResourceNotFoundException. May throw InternalServiceException. May throw LimitExceededException.
Parameter contactFlowId
:
The identifier of the contact flow for initiating the chat. To see the
ContactFlowId in the Amazon Connect console user interface, on the
navigation menu go to Routing, Contact Flows. Choose the
contact flow. On the contact flow page, under the name of the contact
flow, choose Show additional flow information. The ContactFlowId is
the last part of the ARN, shown here in bold:
arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/contact-flow/846ec553-a005-41c0-8341-xxxxxxxxxxxx
Parameter instanceId
:
The identifier of the Amazon Connect instance.
Parameter participantDetails
:
Information identifying the participant.
Parameter attributes
:
A custom key-value pair using an attribute map. The attributes are
standard Amazon Connect attributes, and can be accessed in contact flows
just like any other contact attributes.
There can be up to 32,768 UTF-8 bytes across all key-value pairs per contact. Attribute keys can include only alphanumeric, dash, and underscore characters.
Parameter clientToken
:
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request.
Parameter initialMessage
:
The initial message to be sent to the newly created chat.
Implementation
Future<StartChatContactResponse> startChatContact({
required String contactFlowId,
required String instanceId,
required ParticipantDetails participantDetails,
Map<String, String>? attributes,
String? clientToken,
ChatMessage? initialMessage,
}) async {
ArgumentError.checkNotNull(contactFlowId, 'contactFlowId');
_s.validateStringLength(
'contactFlowId',
contactFlowId,
0,
500,
isRequired: true,
);
ArgumentError.checkNotNull(instanceId, 'instanceId');
_s.validateStringLength(
'instanceId',
instanceId,
1,
100,
isRequired: true,
);
ArgumentError.checkNotNull(participantDetails, 'participantDetails');
_s.validateStringLength(
'clientToken',
clientToken,
0,
500,
);
final $payload = <String, dynamic>{
'ContactFlowId': contactFlowId,
'InstanceId': instanceId,
'ParticipantDetails': participantDetails,
if (attributes != null) 'Attributes': attributes,
'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
if (initialMessage != null) 'InitialMessage': initialMessage,
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri: '/contact/chat',
exceptionFnMap: _exceptionFns,
);
return StartChatContactResponse.fromJson(response);
}