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

Webchat Integration #18

Merged
merged 194 commits into from
Jan 15, 2025
Merged

Webchat Integration #18

merged 194 commits into from
Jan 15, 2025

Conversation

rockwellll
Copy link
Collaborator

@rockwellll rockwellll commented Jan 8, 2025

This PR introduces a new set of classes and modules that allow the integration of WebChats to be used via the JS client.

Configuration

It adds a new WebChat configuration in core/configuration/web_chat that allow to set (or override) values of the WebChat, the API for initializing a WebChat looks like this,

Hellotext.initialize('PUBLIC_BUSINESS_ID', {
  webChat: {
    id,
    container,
    placement,
    classes,
    triggerClasses,
    style: {
      primaryColor,
      secondaryColor,
      typography
    },
    behaviour,
  }
})

Read more on the docs https://github.com/hellotext/hellotext.js/blob/webchat/docs/webchat.md.

WebSockets

It introduces a parent application_channel that is used to establish WebSocket connections to Hellotext. And, it adds a web_chat_channel that inherits from it and subscribes to WS for webchat channel, which includes messages sent from the Inbox, and conversation assignment state changes.

subscribe() {
const params = {
channel: "WebChatChannel",
id: this.id,
session: this.session
}
this.send( { command: 'subscribe', identifier: params })
}

Controllers

Then, the webchat controller hooks into these and does something on each event,

this.webChatChannel.onMessage(this.onMessageReceived)
this.webChatChannel.onConversationAssignment(this.onConversationAssignment)
this.webChatChannel.onAgentOnline(this.onAgentOnline)

  • It supports pagination
  • It has an attachment tool
  • It has an emoji tool

Mixins

It extracts a usePopover mixin that is used by both the WebChat and the Emoji tool to display a dropdown popover listing their content.

@rockwellll rockwellll merged commit a87a730 into main Jan 15, 2025
2 checks passed
@rockwellll rockwellll deleted the webchat branch January 15, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants