fix(channel-web): fix switching user language #5753
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the mapping between visitorId and userId logic inside the switchLanguage builtin action. This fixes changing the user language and updating the channel-web UI accordingly.
Another solution I tough about was to handle this logic inside the
forVisitor
function (packages/bp/src/core/realtime/payload-sdk-impl.ts). But I think it would be overkill to have to make sure the user sends a visitorId and if not, to check if the userId corresponds to some visitorId and then fetch this value.We could also expose a
getVisitorId
in the SDK but considering thatweb_user_map
is a temporary table and will be deprecated in the future, we might not want to go that route.Please, let me know if you have a better idea of what we could do here!
Fixes botpress/v12#1541
Closes DEV-1984
Type of change
How has this been tested?
Use the builtin/switchLanguage function and set the language to
fr
and thenen
. You will see the UI if the webchat change from English to French and then back to English.Checklist: