You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import"amazon-connect-chatjs";// v1.3.1import{ConnectClient,StartChatContactCommand,}from"@aws-sdk/client-connect";// v3.254.0// start a chat contactconstclient=newConnectClient({region: "us-east-1",credentials: {accessKeyId: "...",secretAccessKey: "...",sessionToken: "...",},});const{ ContactId, ParticipantId, ParticipantToken }=awaitclient.send(newStartChatContactCommand({InstanceId: "...",ContactFlowId: "...",ParticipantDetails: {DisplayName: "Customer"},}));// create chat sessionconstsession=connect.ChatSession.create({chatDetails: {contactId: ContactId,participantId: ParticipantId,participantToken: ParticipantToken,},options: {region: "us-east-1"},type: connect.ChatSession.SessionTypes.CUSTOMER,});// setup a message handler that will execute once for a messageletonce=true;session.onMessage(async(event)=>{if(event.data.Type==="MESSAGE"&&once){once=false;// attempt to send a read receiptconst{Id: messageId}=event.data;console.log("Sending read receipt for message:",messageId);try{awaitsession.sendEvent({contentType: "application/vnd.amazonaws.connect.event.message.read",content: JSON.stringify({ messageId }),});console.log("Sent read receipt for message:",messageId);}catch(e){console.error(`Failed to send read receipt for message '${messageId}':`,e);}}});// connect to the chatawaitsession.connect();
Expected result:
The read receipt can is sent successfully since read/delivered receipts are enabled by default.
Actual result:
The read receipt fails to be sent because read/delivered receipts are disabled:
//Control switch for enabling/disabling message-receipts (Read/Delivered) for messages
//message receipts use sendEvent API for sending Read/Delivered events https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_SendEvent.html
features: {
messageReceipts: {
shouldSendMessageReceipts:true, // DEFAULT: true, set to false to disable Read/Delivered receipts
throttleTime:5000//default throttle time - time to wait before sending Read/Delivered receipt.
}
}
});
This default only applies when the setGlobalConfig() method is invoked at least once:
Steps to reproduce:
Expected result:
The read receipt can is sent successfully since read/delivered receipts are enabled by default.
Actual result:
The read receipt fails to be sent because read/delivered receipts are disabled:
Analysis:
Even thought the documentation in
README.md
indicates that read/delivery receipts are enabled by default:amazon-connect-chatjs/README.md
Lines 98 to 106 in d85c517
This default only applies when the
setGlobalConfig()
method is invoked at least once:amazon-connect-chatjs/src/core/chatSession.js
Lines 170 to 192 in d85c517
Additionally, the error message when the feature is disabled is not very readable due to the expression used in the error message:
amazon-connect-chatjs/src/core/chatController.js
Lines 139 to 143 in d85c517
Proposed fix:
Read/delivered receipts should be enabled regardless of whether
setGlobalConfig()
is invoked or not.Additionally, the error message when the feature is disabled should be improved with something like the following:
The text was updated successfully, but these errors were encountered: