Amjad
Amjad

Reputation: 157

Resource handler returned message: "Invalid request (Service: Connect, Status Code: 400)

I am trying to create Amazon Connect Contact flows using the cloudformation template and Amazon Contact flow language which is new for me. But I am facing this issue and the stack fails to create. I am not sure If I am having syntax errors in my yml file. Complete error message

Resource handler returned message: "Invalid request (Service: Connect, Status Code: 400, Request ID: aa1e1049-47bb-43ea-8065-0f8b1cf503d2)" (RequestToken: ff62940b-0e60-2308-d33d-917eeb399402, HandlerErrorCode: InvalidRequest)

Here is the cloud formation template

---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Amazon Connect - Contact Flow"

Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: "General Information"
        Parameters:
          - SystemName
          - EnvironmentName
      - Label:
          default: "Amazon Connect Information"
        Parameters:
          - InstanceID
          - ContactFlowName

Parameters:
  SystemName:
    Type: String
  EnvironmentName:
    Type: String
    AllowedValues: [prd, stg, dev]
  InstanceID:
    Type: String
    Description: "Enter the Amazon Connect Instance ID (e.g. 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx')"
  ContactFlowName:
    Type: String
    Description: "Enter the Name of the Contact flow" 
    
Resources:
  ContactFlow:
    Type: 'AWS::Connect::ContactFlow'
    Properties:
      Name: !Sub "${ContactFlowName}"
      Description: Example contact flow
      InstanceArn: !Sub "arn:aws:connect:${AWS::Region}:${AWS::AccountId}:instance/${InstanceID}"
      Type: CONTACT_FLOW
      Content: |
        {
          "Version": "2019-10-30",
            "StartAction": "c8275c19-08aa-4ee5-9b42-bcc47d32e914",
            "Metadata": {
            "entryPointPosition": {
                "x": 20,
                "y": 20
            },
            "snapToGrid": false,
            "ActionMetadata": {
                "5c47b68e-d790-45eb-a0bd-654027af4868": {
                "position": {
                    "x": 463,
                    "y": 491
                },
                "useDynamic": false
                },
                "c8275c19-08aa-4ee5-9b42-bcc47d32e914": {
                "position": {
                    "x": 180,
                    "y": 20
                },
                "conditionMetadata": [
                    {
                    "id": "6a7b09ef-d441-4183-8ef3-2f0f360ba747",
                    "value": "1"
                    },
                    {
                    "id": "f3516737-c758-4d6f-8d31-ea43d1e27990",
                    "value": "2"
                    },
                    {
                    "id": "21ad3977-2559-4449-ba54-b84d4a0521b6",
                    "value": "3"
                    }
                ],
                "useDynamic": false,
                "useLexBotDropdown": true,
                "useDynamicLexBotArn": false
                },
                "c36d9f86-780d-4c44-8c79-80c8353a699a": {
                "position": {
                    "x": 1068,
                    "y": 317
                }
                },
                "14837518-cc08-4d54-ac93-ea7e063481a8": {
                "position": {
                    "x": 492,
                    "y": 340
                },
                "overrideConsoleVoice": false,
                "defaultVoice": "Standard"
                },
                "1e435e5f-7b62-4938-8c9f-fa05106c72b3": {
                "position": {
                    "x": 501,
                    "y": 174
                },
                "overrideConsoleVoice": false,
                "defaultVoice": "Standard"
                },
                "98768cdb-f5e6-4642-90e3-6e06fd6813e8": {
                "position": {
                    "x": 478,
                    "y": 21
                },
                "overrideConsoleVoice": false,
                "defaultVoice": "Conversational",
                "fragments": {
                    "SetContactData": "bc981918-e0b3-4840-afa5-12b6d7078248"
                }
                },
                "bc981918-e0b3-4840-afa5-12b6d7078248": {
                "position": {
                    "x": 0,
                    "y": 0
                }
                },
                "3a521089-edfe-4821-8156-19014b7b8926": {
                "position": {
                    "x": 716,
                    "y": 45
                },
                "useDynamic": false,
                "ContactFlow": {
                    "id": "arn:aws:connect:eu-central-1:132387760551:instance/a65f970f-0f59-444e-b421-5ec6ec74c116/contact-flow/d727e34f-6707-437f-8013-20e4f2a867d6",
                    "text": "Transaction Banking Authentication"
                }
                }
            }
            },
            "Actions": [
            {
                "Identifier": "5c47b68e-d790-45eb-a0bd-654027af4868",
                "Parameters": {
                "Text": "An Error Occured!"
                },
                "Transitions": {
                "NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
                "Errors": [
                    {
                    "NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
                    "ErrorType": "NoMatchingError"
                    }
                ],
                "Conditions": []
                },
                "Type": "MessageParticipant"
            },
            {
                "Identifier": "c8275c19-08aa-4ee5-9b42-bcc47d32e914",
                "Parameters": {
                "Text": "To continue in English press 1, Ukuqhubeka ngesiZulu cindezela u- 2, Vir Afrikaans Druk 3.",
                "StoreInput": "False",
                "InputTimeLimitSeconds": "5"
                },
                "Transitions": {
                "NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
                "Errors": [
                    {
                    "NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
                    "ErrorType": "NoMatchingError"
                    },
                    {
                    "NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
                    "ErrorType": "NoMatchingCondition"
                    },
                    {
                    "NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
                    "ErrorType": "InputTimeLimitExceeded"
                    }
                ],
                "Conditions": [
                    {
                    "NextAction": "98768cdb-f5e6-4642-90e3-6e06fd6813e8",
                    "Condition": {
                        "Operator": "Equals",
                        "Operands": [
                        "1"
                        ]
                    }
                    },
                    {
                    "NextAction": "1e435e5f-7b62-4938-8c9f-fa05106c72b3",
                    "Condition": {
                        "Operator": "Equals",
                        "Operands": [
                        "2"
                        ]
                    }
                    },
                    {
                    "NextAction": "14837518-cc08-4d54-ac93-ea7e063481a8",
                    "Condition": {
                        "Operator": "Equals",
                        "Operands": [
                        "3"
                        ]
                    }
                    }
                ]
                },
                "Type": "GetParticipantInput"
            },
            {
                "Identifier": "c36d9f86-780d-4c44-8c79-80c8353a699a",
                "Type": "DisconnectParticipant",
                "Parameters": {},
                "Transitions": {}
            },
            {
                "Identifier": "14837518-cc08-4d54-ac93-ea7e063481a8",
                "Parameters": {
                "TextToSpeechVoice": "Lotte"
                },
                "Transitions": {
                "NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
                "Errors": [],
                "Conditions": []
                },
                "Type": "UpdateContactTextToSpeechVoice"
            },
            {
                "Identifier": "1e435e5f-7b62-4938-8c9f-fa05106c72b3",
                "Parameters": {
                "TextToSpeechVoice": "Marlene"
                },
                "Transitions": {
                "NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
                "Errors": [],
                "Conditions": []
                },
                "Type": "UpdateContactTextToSpeechVoice"
            },
            {
                "Identifier": "98768cdb-f5e6-4642-90e3-6e06fd6813e8",
                "Parameters": {
                "TextToSpeechVoice": "Joanna"
                },
                "Transitions": {
                "NextAction": "bc981918-e0b3-4840-afa5-12b6d7078248",
                "Errors": [],
                "Conditions": []
                },
                "Type": "UpdateContactTextToSpeechVoice"
            },
            {
                "Identifier": "bc981918-e0b3-4840-afa5-12b6d7078248",
                "Parameters": {
                "LanguageCode": "en-US"
                },
                "Transitions": {
                "NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
                "Errors": [
                    {
                    "NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
                    "ErrorType": "NoMatchingError"
                    }
                ],
                "Conditions": []
                },
                "Type": "UpdateContactData"
            },
            {
                "Identifier": "3a521089-edfe-4821-8156-19014b7b8926",
                "Parameters": {
                "ContactFlowId": "arn:aws:connect:eu-central-1:132387760551:instance/a65f970f-0f59-444e-b421-5ec6ec74c116/contact-flow/d727e34f-6707-437f-8013-20e4f2a867d6"
                },
                "Transitions": {
                "NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
                "Errors": [
                    {
                    "NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
                    "ErrorType": "NoMatchingError"
                    }
                ],
                "Conditions": []
                },
                "Type": "TransferToFlow"
            }
            ]
      Tags:
        - Key: System
          Value: !Ref SystemName
        - Key: Environment
          Value: !Ref EnvironmentName

Any kinda help will Appreciated

Upvotes: 0

Views: 6798

Answers (2)

Stephen Smith
Stephen Smith

Reputation: 352

So I had the same problem as Mjad, except that I actually configured the contact flow manually, and then exported it and used that JSON object.

The issue was was that in my "Update Contact Attributes" I have a string that I was continually updated every time certain actions were made. So for example, the string was, "Customer_Journey" and then it had a "" for every update within a flow. AWS' system obviously didn't like that character going through whatever system they have.

If you have a slash, change the character. This is the case in spite of the fact that I even tried adding, "\" to fix the issue.

Upvotes: 0

ledge
ledge

Reputation: 474

Okay, looks like the Content object is not valid. For starters it ends with a ] character instead of a } But even fixing that it has issues.

I'd suggest creating a flow in the gui and export it, then use the json from that as a template.

Also, check the Flow language documentation to get the syntax and structure correct.

Upvotes: 1

Related Questions