Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contactAttributes #21

Closed
nbaillie opened this issue Jul 8, 2020 · 0 comments
Closed

contactAttributes #21

nbaillie opened this issue Jul 8, 2020 · 0 comments

Comments

@nbaillie
Copy link

nbaillie commented Jul 8, 2020

I found that ContactAttributes were not being passed via the Lambda behind the API to Connect.

From the Readme...

connect.ChatInterface.initiateChat({
  name: customerName,
  username: username,
  region: ${region},
  apiGatewayEndpoint: "https://${apiId}.execute-api.${region}.amazonaws.com/Prod",
  contactAttributes: JSON.stringify({
    "customerName": customerName
  }),
  contactFlowId: "${contactFlowId}",
  instanceId: "${instanceId}"
},successHandler, failureHandler)

I made the change bellow in the startChatContactAPI-StartChatLambda Lambda and it works now as i would have expected.
"Attributes": body["Attributes"],

return new Promise(function (resolve, reject) {
        var startChat = {
            "InstanceId": instanceId == "" ? process.env.INSTANCE_ID : instanceId,
            "ContactFlowId": contactFlowId == "" ? process.env.CONTACT_FLOW_ID : contactFlowId,
            // "Attributes": {
            //     "customerName": body["ParticipantDetails"]["DisplayName"]
            // },
            "Attributes": body["Attributes"],
            "ParticipantDetails": {
                "DisplayName": body["ParticipantDetails"]["DisplayName"]
            }
        };

and now works with

connect.ChatInterface.initiateChat({
                    name: customerName,
                    region: "eu-west-2", // TODO: Fill in
                    apiGatewayEndpoint: apiGatewayEndpoint,
                    contactAttributes: JSON.stringify({
                        "customerName": customerName,
                        "language_code": language_code
                    }),
                    contactFlowId: contactFlowId,
                    instanceId: instanceId
                }, successHandler, failureHandler);

Hope this might help others, i am using this to pass a language option in my case.
Could be this can be changed or perhaps it has a reason for being like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants