Chat component and CRM integration

The chat component on the Hundredjack platform is an integral part of the CRM, designed to facilitate seamless communication between users and the Hundredjack team. While the CRM is still a work in progress, the chat functionality is fully operational. Here's a detailed explanation of how the chat component works and its integration within the CRM:

User Interaction

  1. Guest and Logged-In Users:

    • Logged-Out Users: When a user who is not logged in accesses the chat, they are presented with a page prompting them to either log in or chat as a visitor.

    • Visitor Chat: If a user opts to chat as a visitor, they are assigned a limited visitor account with a dummy email and name. This visitor account allows them to ask questions via the chat but does not grant the ability to order products or log in.

  • Logged-In Users: Users who are logged in can use the chat with their own accounts, enabling personalized and authenticated interactions.

  1. Visitor Account Management:

    • Visitor accounts are temporary and are automatically deleted after one day via a backend workflow, ensuring that the system remains clean and uncluttered with inactive accounts.

Chat Functionality

  1. Data Structure:

    • Data Types and Fields: The chat system is built around a new data type in the database with fields for content, recipient, sender, seen status, and replied status. The seen and replied fields help manage multiple team members responding to messages, allowing the system to track who has replied to which messages.

    • Message Storage: Messages are stored with references to both sender and recipient, facilitating the retrieval of conversation threads.

  2. Message Display:

    • Repeating Groups: The chat interface utilizes repeating groups to display messages. One repeating group searches for all direct messages where the recipient matches the current user or the sender matches the current user, merging these results to show the complete conversation.

    • Sidebar for User List: The CRM includes a sidebar listing all users who have sent at least one message. This list is generated by first grouping users by roles (clients, visitors, and doctors, with admins excluded) and then searching for direct messages where the sender matches the client's name.

  3. Team Response:

    • The Hundredjack team can respond to messages directly from their CRM. Each message's seen and replied status helps ensure that team responses are coordinated and no message is overlooked.

  1. Operational Hours:

    • The chat functionality is restricted to business hours. If a user attempts to send a message outside of these hours, the chat is turned off, preventing any further communication until business hours resume.

Technical Implementation

  1. Chat Page on Bubble:

    • Data Type Creation: A new data type is created in the database with fields for message content, recipient, sender, seen status, and replied status.

    • Repeating Group for Messages: A repeating group is set up to display messages by searching for direct messages that match the recipient's name or the sender's name.

    • User List in CRM: A sidebar in the CRM displays all users who have sent messages, grouped by user roles. Another repeating group searches direct messages to match senders' names to clients who have sent at least one message.

  1. Visitor Account Handling:

    • When a visitor initiates a chat, a backend workflow creates a temporary visitor account with a dummy email and name. This account is automatically deleted after 24 hours to maintain database hygiene.

  2. Business Hours Enforcement:

    • A script checks the current time against Hundredjack's business hours. If the current time is outside of these hours, the chat is disabled, preventing users from sending messages.

Last updated