Skip to content

Commit f9e4e7d

Browse files
committed
Add configurable parameter to control delay between transcript message send on startup to Connect. Workaround Connect problem with respect to out of order delivery of sent messages.
1 parent ae7baba commit f9e4e7d

File tree

12 files changed

+61
-21
lines changed

12 files changed

+61
-21
lines changed

build/update-lex-web-ui-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ const lexV2BotLocaleVoices = {
146146
'CONNECT_START_LIVE_CHAT_LABEL',
147147
'CONNECT_START_LIVE_CHAT_ICON',
148148
'CONNECT_END_LIVE_CHAT_LABEL',
149-
'CONNECT_END_LIVE_CHAT_ICON' ,
149+
'CONNECT_END_LIVE_CHAT_ICON',
150+
'CONNECT_TRANSCRIPT_MESSAGE_DELAY_IN_MSEC',
150151
'APP_DOMAIN_NAME',
151152
'UI_TOOLBAR_TITLE',
152153
'UI_TOOLBAR_LOGO',

config/base.env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
chatEndedMessage: process.env.CONNECT_CHAT_ENDED_MESSAGE,
2424
attachChatTranscript: process.env.CONNECT_ATTACH_CHAT_TRANSCRIPT,
2525
liveChatTerms: process.env.CONNECT_LIVE_CHAT_TERMS,
26+
transcriptMessageDelayInMsec: process.env.CONNECT_TRANSCRIPT_MESSAGE_DELAY_IN_MSEC,
2627
},
2728
lex: {
2829
v2BotId: process.env.V2_BOT_ID,

config/env.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export CONNECT_START_LIVE_CHAT_LABEL ?= $()
3636
export CONNECT_START_LIVE_CHAT_ICON ?= $()
3737
export CONNECT_END_LIVE_CHAT_LABEL ?= $()
3838
export CONNECT_END_LIVE_CHAT_ICON ?= $()
39+
export CONNECT_TRANSCRIPT_MESSAGE_DELAY_IN_MSEC ?= $()
3940
export BOT_INITIAL_TEXT ?= $()
4041
export BOT_INITIAL_SPEECH ?= $()
4142
export BOT_INITIAL_UTTERANCE ?= $()

lex-web-ui/package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lex-web-ui/src/config/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ const configDefault = {
7474
waitingForAgentMessageIntervalSeconds: 60,
7575
// Terms to start live chat
7676
liveChatTerms: 'live chat',
77+
// The delay to use between sending transcript blocks to connect
78+
transcriptMessageDelayInMsec: 150,
7779
},
7880
lex: {
7981
// Lex V2 fields

lex-web-ui/src/store/live-chat-handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const initLiveChatHandlers = (context, session) => {
6666
const transcriptArray = context.getters.liveChatTextTranscriptArray();
6767
transcriptArray.forEach((text, index) => {
6868
var formattedText = "Bot Transcript: (" + (index + 1).toString() + "\\" + transcriptArray.length + ")\n" + text;
69-
sendChatMessageWithDelay(session, formattedText, index * 150);
69+
sendChatMessageWithDelay(session, formattedText, index * context.state.config.connect.transcriptMessageDelayInMsec);
7070
console.info((index + 1).toString() + "-" + formattedText);
7171
});
7272

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/lex-web-ui-loader-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"agentJoinedMessage": "",
1010
"agentLeftMessage": "",
1111
"chatEndedMessage": "",
12-
"attachChatTranscript": ""
12+
"attachChatTranscript": "",
13+
"transcriptMessageDelayInMsec": ""
1314
}
1415
}

templates/codebuild-deploy.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ Parameters:
217217
Icon to use in menu and toolbar to end connect live chat
218218
Default: "call_end"
219219

220+
ConnectTranscriptMessageDelayInMsec:
221+
Type: Number
222+
Description: >
223+
Delay to insert between each transcript message send to Connect in msec.
224+
Default: 150
225+
220226
LexV2BotId:
221227
Description: >
222228
Bot ID (not bot name) of an existing Lex V2 Bot to be used by the web ui. NOTE: You must
@@ -711,6 +717,8 @@ Resources:
711717
Value: !Ref ConnectEndLiveChatLabel
712718
- Name: CONNECT_END_LIVE_CHAT_ICON
713719
Value: !Ref ConnectEndLiveChatIcon
720+
- Name: CONNECT_TRANSCRIPT_MESSAGE_DELAY_IN_MSEC
721+
Value: !Ref ConnectTranscriptMessageDelayInMsec
714722
- Name: APP_USER_POOL_CLIENT_ID
715723
Value: !Ref CognitoAppUserPoolClientId
716724
- Name: APP_USER_POOL_NAME
@@ -827,6 +835,7 @@ Resources:
827835
ConnectStartLiveChatIcon: !Ref ConnectStartLiveChatIcon
828836
ConnectEndLiveChatLabel: !Ref ConnectEndLiveChatLabel
829837
ConnectEndLiveChatIcon: !Ref ConnectEndLiveChatIcon
838+
ConnectTranscriptMessageDelayInMsec: !Ref ConnectTranscriptMessageDelayInMsec
830839
WebAppBucket: !Ref WebAppBucket
831840
LexV2BotId: !Ref LexV2BotId
832841
LexV2BotAliasId: !Ref LexV2BotAliasId

templates/master-pipeline.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWSTemplateFormatVersion: 2010-09-09
22
Description: |
3-
Master Pipeline Lex Web UI CloudFormation template (v0.19.7)
3+
Master Pipeline Lex Web UI CloudFormation template (v0.19.8)
44
The Lex Web Ui can be deployed to operate against either a Lex V2 Bot OR a Lex V1 Bot BUT NOT BOTH.
55
Please configure either the Lex V2 bot information OR the Lex V1 bot information and leave the other
66
version input parameters as defaulted.
@@ -368,6 +368,12 @@ Parameters:
368368
Icon to use in menu and toolbar to end connect live chat
369369
Default: "call_end"
370370

371+
ConnectTranscriptMessageDelayInMsec:
372+
Type: Number
373+
Description: >
374+
Delay to insert between each transcript message send to Connect in msec.
375+
Default: 150
376+
371377
Rules:
372378
ValidateEitherV1orV2:
373379
RuleCondition: !Not
@@ -459,7 +465,7 @@ Resources:
459465
NamePrefix: !Ref BotNamePrefix
460466
ShouldDeleteBot: !Ref ShouldDeleteBot
461467
CustomResourceCodeBucket: !Ref BootstrapBucket
462-
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.19.7.zip"
468+
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.19.8.zip"
463469

464470
CognitoIdentityPool:
465471
Type: AWS::CloudFormation::Stack
@@ -503,8 +509,8 @@ Resources:
503509
- !GetAtt CognitoIdentityPool.Outputs.CognitoIdentityPoolId
504510
- !Ref CognitoIdentityPoolId
505511
SourceBucket: !Ref BootstrapBucket
506-
SourceObject: !Sub "${BootstrapPrefix}/src-v0.19.7.zip"
507-
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.19.7.zip"
512+
SourceObject: !Sub "${BootstrapPrefix}/src-v0.19.8.zip"
513+
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.19.8.zip"
508514

509515
Pipeline:
510516
Type: AWS::CloudFormation::Stack
@@ -535,8 +541,8 @@ Resources:
535541
ParentOrigin: !Ref WebAppParentOrigin
536542
CustomResourceCodeBucket: !Ref BootstrapBucket
537543
CustomResourceCodePrefix: !Ref BootstrapPrefix
538-
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.19.7.zip"
539-
InitiateChatLambdaCodeObject: !Sub "${BootstrapPrefix}/initiate-chat-lambda-v0.19.7.zip"
544+
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.19.8.zip"
545+
InitiateChatLambdaCodeObject: !Sub "${BootstrapPrefix}/initiate-chat-lambda-v0.19.8.zip"
540546
CleanupBuckets: !Ref CleanupBuckets
541547
CognitoAppUserPoolClientId:
542548
!If
@@ -570,6 +576,7 @@ Resources:
570576
ConnectStartLiveChatIcon: !Ref ConnectStartLiveChatIcon
571577
ConnectEndLiveChatLabel: !Ref ConnectEndLiveChatLabel
572578
ConnectEndLiveChatIcon: !Ref ConnectEndLiveChatIcon
579+
ConnectTranscriptMessageDelayInMsec: !Ref ConnectTranscriptMessageDelayInMsec
573580

574581
CognitoIdentityPoolConfig:
575582
Type: AWS::CloudFormation::Stack
@@ -583,7 +590,7 @@ Resources:
583590
CodeBuildProjectName: !Ref CodeBuildName
584591
CognitoUserPool: !GetAtt CognitoIdentityPool.Outputs.CognitoUserPoolId
585592
CognitoUserPoolClient: !GetAtt CognitoIdentityPool.Outputs.CognitoUserPoolClientId
586-
Timestamp: 1678465363
593+
Timestamp: 1683124094
587594

588595
Outputs:
589596
BotName:

0 commit comments

Comments
 (0)