Skip to content

[AMAZON CONNECT + LEX QUESTION] Initialize bot with message with Lex in Get Customer Input block of Amazon Connect errors out during call

0

Why does Initialize bot with message with Lex in Get Customer Input block of Amazon Connect error out when I try the flow with a Call. It works when I am testing the flow with text chat.

Does this feature only work for text? I currently send it a session attribute from Lex. I can confirm that it is passes along as this works when I am testing the flow/bot with text chat.

Error log from Connect

{
    "Results": "Error",
    "ContactFlowName": "qic-selfservice-flow",
    "ContactFlowModuleType": "GetUserInput",
    "Timestamp": "2026-01-05T21:41:54.609Z",
    "Parameters": {
        "NoInputTimeout": "3000",
        "LexVersion": "V2",
        "BotAliasArn": "",
        "Parameter": "x-amz-lex:q-in-connect:ai-agent-arn=arn:aws:wisdom",
        "Voice": "Joanna",
        "MaxSpeechDuration": "12000",
        "LexInitialMessage": "press one for pharmacy first two for medical appointment"
    }
}

The LexInitialMessage is populated but this causes Error

asked 8 months ago320 views

2 Answers
0

Additional Solution for Voice Contacts:

Since the "Initialize bot with message" feature is chat-only, you can achieve similar functionality for voice contacts by using a Lambda function before your Get Customer Input block. Here's how:

Approach: Use Lex PutSession API

Add an "Invoke AWS Lambda function" block before your Get Customer Input block

In your Lambda function, use the Lex PutSession API to initialize the bot session with the desired message/intent:

AWS

answered 8 months ago

  • hi, @Thomas_R I'm trying to configure as your way, but the Lex always treats me as new conversation. Below is my sample code to get code from user, I ensure that the bot ID/AliasID are the same in Get User Input Block

    import json
    import boto3
    def lambda_handler(event, context):
        session_id = event['Details']['ContactData']['ContactId']
        client = boto3.client('lexv2-runtime')
        bot_id = 'FA3E6H142D'
        bot_alias_id = 'TSTALIASID'
        locale_id = 'en_US'
        target_intent_name = 'GetAuthenticatedigits'
        initial_bot_message = "get authenticate code from user"
        slot_to_elicit = 'AuthenticateCode'
        try:
            response = client.put_session(botId=bot_id, botAliasId=bot_alias_id, localeId=locale_id,
                sessionId=session_id,
                messages=[{
                    'content': initial_bot_message,
                    'contentType': 'PlainText'}],
                sessionState={
                    'dialogAction': {'type': 'ElicitSlot', 'slotToElicit': slot_to_elicit},
                    'intent': {
                        'name': target_intent_name,
                        'slots': {},
                        'state': 'InProgress'}})
            print(f"Successfully initialized session for intent: {target_intent_name}")
            return {"success": True}  
        except Exception as e:
            print(f"Error calling PutSession: {str(e)}")
            return {"success": False, "error": str(e)}
    

    Please help me check and let me know if there is any extra steps I need to do Thanks,

0

Hello,

I see that Initialize bot with message with Lex in the Get Customer Input block errors out when you use the flow with a call. However, it works as expected with a chat.

The "Initialize bot with message" feature is specifically designed for chat contacts only and is not supported for voice interactions. When this feature is used with a voice contact flow, it will result in an error and route the contact to the error branch, which is the behavior you are currently observing.

This is documented in the AWS documentation titled ‘Flow block in Amazon Connect: Get customer input’ [+], which states that entering a custom message manually or dynamically to initialize the Lex bot is only support by chat contacts.

[+] "How to configure this block" →"Configure for Amazon Lex input" → "Initialize bot with message" - https://docs.aws.amazon.com/connect/latest/adminguide/get-customer-input.html#get-customer-input-properties

I hope this information helps.

AWS
SUPPORT ENGINEER

answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.