createSession method

Future<CreateSessionResponse> createSession({
  1. required String assistantId,
  2. required String name,
  3. Map<AIAgentType, AIAgentConfigurationData>? aiAgentConfiguration,
  4. String? clientToken,
  5. String? contactArn,
  6. String? description,
  7. List<OrchestratorConfigurationEntry>? orchestratorConfigurationList,
  8. bool? removeOrchestratorConfigurationList,
  9. TagFilter? tagFilter,
  10. Map<String, String>? tags,
})

Creates a session. A session is a contextual container used for generating recommendations. Amazon Connect creates a new Amazon Q in Connect session for each contact on which Amazon Q in Connect is enabled.

May throw AccessDeniedException. May throw ConflictException. May throw DependencyFailedException. May throw ResourceNotFoundException. May throw UnauthorizedException. May throw ValidationException.

Parameter assistantId : The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

Parameter name : The name of the session.

Parameter aiAgentConfiguration : The configuration of the AI Agents (mapped by AI Agent Type to AI Agent version) that should be used by Amazon Q in Connect for this Session.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Parameter contactArn : The Amazon Resource Name (ARN) of the email contact in Amazon Connect. Used to retrieve email content and establish session context for AI-powered email assistance.

Parameter description : The description.

Parameter orchestratorConfigurationList : The list of orchestrator configurations for the session being created.

Parameter removeOrchestratorConfigurationList : The list of orchestrator configurations to remove from the session.

Parameter tagFilter : An object that can be used to specify Tag conditions.

Parameter tags : The tags used to organize, track, or control access for this resource.

Implementation

Future<CreateSessionResponse> createSession({
  required String assistantId,
  required String name,
  Map<AIAgentType, AIAgentConfigurationData>? aiAgentConfiguration,
  String? clientToken,
  String? contactArn,
  String? description,
  List<OrchestratorConfigurationEntry>? orchestratorConfigurationList,
  bool? removeOrchestratorConfigurationList,
  TagFilter? tagFilter,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    if (aiAgentConfiguration != null)
      'aiAgentConfiguration':
          aiAgentConfiguration.map((k, e) => MapEntry(k.value, e)),
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (contactArn != null) 'contactArn': contactArn,
    if (description != null) 'description': description,
    if (orchestratorConfigurationList != null)
      'orchestratorConfigurationList': orchestratorConfigurationList,
    if (removeOrchestratorConfigurationList != null)
      'removeOrchestratorConfigurationList':
          removeOrchestratorConfigurationList,
    if (tagFilter != null) 'tagFilter': tagFilter,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/assistants/${Uri.encodeComponent(assistantId)}/sessions',
    exceptionFnMap: _exceptionFns,
  );
  return CreateSessionResponse.fromJson(response);
}