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,});// get chat detailssession.getChatDetails();// download an attachmenttry{awaitsession.downloadAttachment({attachmentId: "some-id",});}catch(e){console.error(e);}// get the chat transcripttry{awaitsession.getTranscript({});}catch(e){console.error(e);}// send an attachmenttry{awaitsession.sendAttachment({attachment: newFile(["Hello World!"],"hello.txt"),});}catch(e){console.error(e);}// send typing eventtry{awaitsession.sendEvent({contentType: "application/vnd.amazonaws.connect.event.typing",});}catch(e){console.error(e);}// send a messagetry{awaitsession.sendMessage({contentType: "text/plain",message: "Hello World!",});}catch(e){console.error(e);}
Expected result:
All the try/catch blocks after the session.getChatDetails() invocation fail with an Error indicating that the session.connect() method must be invoked first.
Alternatively, the first try/catch block implicitly invokes the connect() method.
Actual result:
All the try/catch blocks after the session.getChatDetails() invocation fail with the following Error:
TypeError: Cannot read properties of undefined (reading 'getConnectionToken')
Analysis:
The failure is because each of these methods invoke this.connectionHelper.getConnectionToken() in ChatController:
This error is confusing for users, since they don't know the reason for failure is because the connect() method must be called first.
Proposed fix:
Similarly to #126, add a field in ChatController that indicates whether the connect() method has been successfully invoked and validate it on each method that internally uses this.connectionHelper.getConnectionToken().
The text was updated successfully, but these errors were encountered:
Steps to reproduce:
Expected result:
All the
try/catch
blocks after thesession.getChatDetails()
invocation fail with anError
indicating that thesession.connect()
method must be invoked first.Alternatively, the first
try/catch
block implicitly invokes theconnect()
method.Actual result:
All the
try/catch
blocks after thesession.getChatDetails()
invocation fail with the followingError
:Analysis:
The failure is because each of these methods invoke
this.connectionHelper.getConnectionToken()
inChatController
:amazon-connect-chatjs/src/core/chatController.js
Lines 118 to 121 in d85c517
amazon-connect-chatjs/src/core/chatController.js
Lines 165 to 180 in d85c517
amazon-connect-chatjs/src/core/chatController.js
Lines 107 to 111 in d85c517
amazon-connect-chatjs/src/core/chatController.js
Lines 128 to 132 in d85c517
amazon-connect-chatjs/src/core/chatController.js
Lines 96 to 100 in d85c517
However,
this.connectionHelper
is initialized inChatController.prototype.connect()
:amazon-connect-chatjs/src/core/chatController.js
Lines 192 to 199 in d85c517
amazon-connect-chatjs/src/core/chatController.js
Lines 207 to 215 in d85c517
This error is confusing for users, since they don't know the reason for failure is because the
connect()
method must be called first.Proposed fix:
Similarly to #126, add a field in
ChatController
that indicates whether theconnect()
method has been successfully invoked and validate it on each method that internally usesthis.connectionHelper.getConnectionToken()
.The text was updated successfully, but these errors were encountered: