microsoft / microsoft/BotFramework-WebChat
Clearing DirectLineJS responsibility
Open
@compulim is already working on this.
Since Sep 14, 2020.
backlog
feature-request
front-burner
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 1.6k
- Avg merge
- 22h 58m
- Merged PRs (30d)
- 2
Description
Feature Request
Today, some of Web Chat code is used to clean up the result from DLJS. We should clearing up these responsibilities and put them back to DLJS, or put it in a shim that wrap DLJS.
This is the list of responsibilities we should move to DLJS (or via a pseudo adapter). This issue will be expanded into multiple work items:
- Rectifying user ID
- Today, in
connectSaga.js, we will tell downstreamer (onCONNECT_*action) what is our user ID - If the token contains user ID, we will use it, otherwise
- We check if both token and props have user ID, if yes, we will give a warning and use user ID from token
- If the dev pass user ID from props, we will use it, otherwise
- We will generate a new user ID
- User ID should be handled by Direct Line JS
- Web Chat may not need to know about the user ID
- Today, in
- Assigning
role- Today, Web Chat use
activity.roleto determine whether the activity is from us or not - Since
activity.roleis not available from DLJS, Web Chat filled that in based on knowledge of user ID - Tomorrow, DLJS should fill
activity.rolebefore sending the activity to Web Chat - Tomorrow, Web Chat should clear up
activity.rolebefore sending out an activity
- Today, Web Chat use
- Read receipt for
postActivity- Today, Web Chat assume the channel will echo back the message for read receipt
- We use
activity.channelData.clientActivityIdto track echo back message for read receipt - Tomorrow, DLJS's
postActivityfunction should give us signals on two scenario:- The activity has queued on the server
- The activity is being read by the bot
- Clockskew
- Today, Web Chat use
activity.timestampto insert-sort egress activities (before read receipt) - We should do the clockskew
- Today, Web Chat use
- Activity ID is optional (#1861)
- If activity ID is falsy, Web Chat may think its the same activity
- DLJS is doing the right job, but other adapters may not
Post activity timeoutEvery outgoing activity could have different timeout settingsDLJS should responsible on making the decision about the timeout
Action items
- First, build a DLJS shim, that will wrap everything from the original DLJS into this new shim adapter
- The new adapter is going to be bundled inside Web Chat, we will left DLJS untouched
- Initially, the new adapter is nothing but a very thin layer doing nothing but just passing function calls
- I.e. it will replace
createDirectLinefunction, and potentiallycreateDirectLineAppServiceExtensionfunction as well
- Then, we slowly move the every "responsibility" work, listed above, from Web Chat into this adapter
[Enhancement]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.