microsoft / microsoft/BotFramework-WebChat

Clearing DirectLineJS responsibility

Open
#2,665 0 comments 0 reactions 1 assignee View on GitHub

@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 (on CONNECT_* 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
  • Assigning role
    • Today, Web Chat use activity.role to determine whether the activity is from us or not
    • Since activity.role is not available from DLJS, Web Chat filled that in based on knowledge of user ID
    • Tomorrow, DLJS should fill activity.role before sending the activity to Web Chat
    • Tomorrow, Web Chat should clear up activity.role before sending out an activity
  • Read receipt for postActivity
    • Today, Web Chat assume the channel will echo back the message for read receipt
    • We use activity.channelData.clientActivityId to track echo back message for read receipt
    • Tomorrow, DLJS's postActivity function 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.timestamp to insert-sort egress activities (before read receipt)
    • We should do the clockskew
  • 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 timeout
    • Every outgoing activity could have different timeout settings
    • DLJS 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 createDirectLine function, and potentially createDirectLineAppServiceExtension function as well
  • Then, we slowly move the every "responsibility" work, listed above, from Web Chat into this adapter

[Enhancement]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.