Skip to content
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

Livestreaming typing animation #5141

Merged
merged 65 commits into from May 15, 2024
Merged

Livestreaming typing animation #5141

merged 65 commits into from May 15, 2024

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Apr 20, 2024

Fixes #4876. Fixes #4939. Fixes #5184.

Changelog Entry

Added

  • Resolves #5184. Added channelData.webChat.styleOptions.typingIndicatorDuration to override the default typing indicator duration on a per-activity basis, by @compulim, in PR #5141
  • Resolves #4876 and #4939. Added support of livestreaming, by @compulim, in PR #5141

Description

Added livestreaming support and per-activity typing indicator duration.

Currently, we only support streaming contents. In future, we will support informative message indicating streaming status.

Design

Livestreaming

Add livestreaming support via "typing" activity with "text" field.

The following JSONs are not strictly enforced in Web Chat. However, for best compatibility across clients, bot authors are expected to follow the format.

Support of attachments and other features varies across clients. Bot authors should test their bot on individual clients.

Multiple simultaneous livestream session is supported. Make sure each session has its own unique ID.

First chunk

The first chunk indicates start of a livestream session.

{
  channelData: {
    streamSequence: 1,      // Must be a monotonic increasing positive integer
    streamType: 'streaming' // Must be "streaming"
  },
  text: 'A quick',          // Content of the first chunk
  type: 'typing'            // Must be "typing"
}

Subsequent chunks

{
  channelData: {
    streamId: '<activity ID of the first chunk>', // Must be activity ID of the first chunk
    streamSequence: 2,                            // Must be a monotonic increasing positive integer
    streamType: 'streaming'                       // Must be "streaming"
  },
  text: 'A quick brown fox',                      // Content must include past chunks
  type: 'typing'                                  // Must be "typing"
}

Final chunk

The final chunk will "close" the livestreaming session with a finalized message.

{
  channelData: {
    streamId: '<activity ID of the first chunk>',       // Must be activity ID of the first chunk
    streamType: 'final'                                 // Must be "final"
  },
  text: 'A quick brown fox jumped over the lazy dogs.', // The whole message
  type: 'message'                                       // Must be "message"
}

Per-activity typing indicator duration

Bot author can specify how long a typing indicator should show up for a specific activity via channelData.webChat.styleOptions.typingIndicatorDuration.

Currently, the channelData.webChat.styleOptions only supports typingIndicatorDuration. The broader support of styleOptions is being tracked by #5185.

Specific Changes

  • Added useGetActivitiesByKey to support "multiple activity revisions"
    • Livestream is more-or-less "multiple revisions of the same activity"
  • Added WebChatActivity.channelData.webChat.styleOptions.typingIndicatorDuration property
    • When specified, will override the styleOptions.typingIndicatorDuration for the specific activity
  • Added WebChatActivity.channelData.webChat.receivedAt property to indicate when the activity is received by Web Chat
  • Updated HOOKS.md to include the useGetActivitiesByKey and some missing hooks
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim changed the title Livestreaming typing animation [DRAFT] Livestreaming typing animation Apr 20, 2024
@compulim compulim changed the title [DRAFT] Livestreaming typing animation Livestreaming typing animation May 15, 2024
@compulim compulim marked this pull request as ready for review May 15, 2024 07:06
tdurnford
tdurnford previously approved these changes May 15, 2024
OEvgeny
OEvgeny previously approved these changes May 15, 2024
@compulim compulim dismissed stale reviews from OEvgeny and tdurnford via fd6c5ee May 15, 2024 22:58
@OEvgeny OEvgeny self-requested a review May 15, 2024 22:58
@compulim compulim merged commit 68b8b71 into main May 15, 2024
25 checks passed
@compulim compulim deleted the feat-livestream branch May 15, 2024 23:42
@anshumankmr
Copy link

Awesome. Can't wait to t try this out👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants