-
Notifications
You must be signed in to change notification settings - Fork 10
CHI-3768, CHI-3773: Fix Aselo webchat participant names #4115
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
base: CHI-3641-channel_type_convo_attribute
Are you sure you want to change the base?
Changes from all commits
456f42b
9b77067
411914e
ea16514
068b329
7338808
23bc1a1
2eec22b
bd74e45
9eda176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,10 @@ import { LocalStorageUtil } from './utils/LocalStorage'; | |
| import { generateMixPanelHeaders, generateSecurityHeaders } from './utils/generateHeaders'; | ||
| import { ConfigState } from './store/definitions'; | ||
| import { store } from './store/store'; | ||
| import { localizeKey } from './localization/localizeKey'; | ||
|
|
||
| export const LOCALSTORAGE_SESSION_ITEM_ID = 'TWILIO_WEBCHAT_WIDGET'; | ||
| const CUSTOMER_DEFAULT_NAME = 'Customer'; | ||
| const CUSTOMER_DEFAULT_NAME_KEY = 'Conversation-Participants-CustomerDefaultName'; | ||
|
|
||
| type SessionDataStorage = TokenResponse & { | ||
| loginTimestamp: string | null; | ||
|
|
@@ -189,19 +190,25 @@ class SessionDataHandler { | |
| }); | ||
|
|
||
| try { | ||
| const { config } = store.getState(); | ||
| const payload: InitWebchatAPIPayload = { | ||
| DeploymentKey: this.getDeploymentKey(), | ||
| CustomerFriendlyName: (formData?.friendlyName as string) || CUSTOMER_DEFAULT_NAME, | ||
| CustomerFriendlyName: (() => { | ||
| const localizedName = localizeKey(config.translations[config.currentLocale ?? config.defaultLocale])( | ||
| CUSTOMER_DEFAULT_NAME_KEY, | ||
| ); | ||
| return ( | ||
| (formData?.friendlyName as string) || | ||
| (localizedName === CUSTOMER_DEFAULT_NAME_KEY ? 'Anonymous' : localizedName) | ||
| ); | ||
| })(), | ||
| PreEngagementData: JSON.stringify(formData), | ||
|
Comment on lines
+193
to
205
|
||
| }; | ||
|
|
||
| if (customerIdentity) { | ||
| payload.Identity = customerIdentity; | ||
| } | ||
| newTokenData = await contactBackend(store.getState().config)<TokenResponse>( | ||
| '/webchatAuthentication/initWebchat', | ||
| payload, | ||
| ); | ||
| newTokenData = await contactBackend(config)<TokenResponse>('/webchatAuthentication/initWebchat', payload); | ||
| } catch (e) { | ||
| logger.error('No results from server'); | ||
| throw Error('No results from server'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| { | ||
| "Conversation-Participants-CustomerDefaultName": "Anonymous", | ||
| "Header-CloseChatButtons-EndChatButtonLabel": "End Chat", | ||
| "Header-CloseChatButtons-EndChatConfirmDialogMessageFromChat": "End the current chat? Your messages will be lost.", | ||
| "Header-CloseChatButtons-EndChatConfirmDialogMessageFromPreEngagement": "Abandon the current chat?", | ||
| "Header-CloseChatButtons-QuickExitButtonLabel": "Quick Exit", | ||
| "Header-CloseChatButtons-QuickExitDescription": "Need to leave immediately?", | ||
| "Header-TitleBar-Title": "Live Chat", | ||
| "MessagePhase-MessageList-ChatStartMessage": "Chat Started" | ||
| "MessagePhase-MessageList-ChatStartMessage": "Chat Started", | ||
| "MessagePhase-MessageBubble-OtherParticipantMessageSenderName": "Counsellor", | ||
| "MessagePhase-MessageBubble-OwnMessageSenderName": "You" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import { | |
| createConversation, | ||
| CreateFlexConversationParams, | ||
| } from '../conversation/createConversation'; | ||
| import { isErr } from '../Result'; | ||
|
|
||
| export const findExistingConversation = async ( | ||
| client: Twilio, | ||
|
|
@@ -75,7 +76,7 @@ export const removeConversation = async ( | |
| }: { | ||
| conversationSid: ConversationSID; | ||
| }, | ||
| ) => client.conversations.v1.conversations(conversationSid).remove(); | ||
| ) => client.conversations.v1.conversations.get(conversationSid).remove(); | ||
|
|
||
| export { AseloCustomChannel, isAseloCustomChannel } from './aseloCustomChannels'; | ||
|
|
||
|
|
@@ -125,26 +126,28 @@ export const sendConversationMessageToFlex = async ( | |
| let conversationSid = await findExistingConversation(client, uniqueUserName); | ||
|
|
||
| if (!conversationSid) { | ||
| const { conversationSid: newConversationSid, error } = await createConversation( | ||
| client, | ||
| { | ||
| studioFlowSid, | ||
| channelType, | ||
| twilioNumber, | ||
| uniqueUserName, | ||
| senderScreenName, | ||
| onMessageAddedWebhookUrl, | ||
| conversationFriendlyName, | ||
| testSessionId, | ||
| }, | ||
| ); | ||
| const createConversationResult = await createConversation(client, { | ||
| studioFlowSid, | ||
| channelType, | ||
| twilioNumber, | ||
| uniqueUserName, | ||
|
Comment on lines
128
to
+133
|
||
| senderScreenName, | ||
| onMessageAddedWebhookUrl, | ||
| conversationFriendlyName, | ||
| testSessionId, | ||
| }); | ||
|
|
||
| if (error) { | ||
| await removeConversation(client, { | ||
| conversationSid: newConversationSid, | ||
| }); | ||
| throw error; | ||
| if (isErr(createConversationResult)) { | ||
| const { conversationSid: newConversationSid, cause } = | ||
| createConversationResult.error; | ||
| if (newConversationSid) { | ||
| await removeConversation(client, { | ||
| conversationSid: newConversationSid, | ||
| }); | ||
| } | ||
| throw cause; | ||
| } | ||
| const { conversationSid: newConversationSid } = createConversationResult.data; | ||
|
|
||
| conversationSid = newConversationSid; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces new i18n keys (
MessagePhase-MessageBubble-OwnMessageSenderName/...OtherParticipant...) and unconditionally runs them throughlocalizeKey(currentTranslations). OnlytranslationsSrc/en.jsondefines these keys right now;es.json,fr.json,mt.json, etc. don’t, so users on those locales will see the raw key strings rendered in the UI.Add these keys to the other locale files (even if temporarily untranslated) or implement a fallback to
defaultLocale/English when a key is missing from the current locale.