amazon-connect / amazon-connect-chat-interface

Amazon Connect Chat Interface - a browser-based customer chat widget for your website integrating with Amazon Connect ChatJS
https://docs.aws.amazon.com/connect/latest/adminguide/what-is-amazon-connect.html
MIT No Attribution
33 stars 35 forks source link

Change default ChatDurationInMinutes #106

Closed PabloApser closed 1 year ago

PabloApser commented 1 year ago

Hi, I´m using the chat widget fron connect embedded in a web page and I have this error: { "data": { "statusCode": { "code": 429, "msg": "Service Quota Exceeded" } } } In the doc say a 429 error occurs in the following situations:

API rate limit is exceeded. API TPS throttling returns a TooManyRequests exception. Active chat throttling returns a LimitExceededException.

I assume in backend is ussing StartChatContact API

I wanna know if its possible to change the default parameter "ChatDurationInMinutes" to the minimun through this amazon-connect-chat-interface solution and minimize the impact on the service.

Thanks !

spencerlepine commented 1 year ago

Hi @PabloApser, the latest bundle file (amazon-connect-chat-interface.js) for chat-interface supports chatDurationInMinutes key,

You can set custom chat duration by updating the initiateChat() config:

connect.ChatInterface.initiateChat({
    ...backendEndpoints,
    // ...
+   chatDurationInMinutes: 1500, // min 60, max 10080 - default 1500 (25 hours)
    // ...
});

The startChatContactAPI solution also passes ChatDurationInMinutes with the StartChat request now, added in PR#92

// startChatContact.js
// https://github.com/amazon-connect/amazon-connect-chat-ui-examples/blob/master/cloudformationTemplates/startChatContactAPI/js/startChatContact.js

var startChat = {
    "InstanceId": instanceId == "" ? process.env.INSTANCE_ID : instanceId,
    "ContactFlowId": contactFlowId == "" ? process.env.CONTACT_FLOW_ID : contactFlowId,
    "Attributes": {
        "customerName": body["ParticipantDetails"]["DisplayName"]
    },
    "ParticipantDetails": {
        "DisplayName": body["ParticipantDetails"]["DisplayName"]
    },
   // ...
+   ...(!!body["ChatDurationInMinutes"] && { "ChatDurationInMinutes": body["ChatDurationInMinutes"] })
};

connect.startChatContact(startChat, function(err, data) {
    // ...
});

Could you provide more details on the chat widget solution you are using, if this doesn't resolve the throttling?

Thanks, Spencer

spencerlepine commented 1 year ago

Hi @PabloApser, any updates on this issue?

If there are any further concerns please let us know. Would like to confirm before closing the issue.

Thanks, Spencer

PabloApser commented 1 year ago

Hi @spencerlepine,

I used the solution you commented. I did not do maximum load tests, but from what I saw it worked correctly.

Thank you so much !

spencerlepine commented 1 year ago

Awesome, glad to hear that! I will go ahead and resolve the issue for now.

Feel free to reach out or re-open if you have more questions or items to discuss.

Thanks, Spencer