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

Chatbot #2679

Merged
merged 3 commits into from
Sep 4, 2024
Merged

Chatbot #2679

merged 3 commits into from
Sep 4, 2024

Conversation

alonp99
Copy link
Collaborator

@alonp99 alonp99 commented Sep 4, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a chatbot interface for enhanced user interaction.
    • Added functionality to toggle the visibility of the chat feature.
    • Integrated customer data checks to determine chatbot availability.
  • Enhancements

    • Updated schemas to support chatbot functionality, including properties for enabling/disabling the chatbot.
  • Bug Fixes

    • Improved loading states for customer data to ensure a smoother user experience.

Copy link

changeset-bot bot commented Sep 4, 2024

⚠️ No Changeset found

Latest commit: 96d8959

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Sep 4, 2024

Walkthrough

The changes introduce a chatbot feature to the backoffice-v2 application by adding new dependencies, a React component for the chatbot interface, and schema modifications to support chatbot functionality. The integration allows for user interaction through a web chat interface, enhancing the application's capabilities. Additionally, updates to the configuration schemas ensure flexibility in enabling or disabling the chatbot feature.

Changes

File Path Change Summary
apps/backoffice-v2/package.json Added dependencies: @botpress/webchat and @botpress/webchat-generator.
apps/backoffice-v2/src/domains/chat/chatbot-opengpt.tsx Introduced Chatbot React component for web chat integration.
apps/backoffice-v2/src/domains/customer/fetchers.ts Added isChatbotEnabled boolean property to CustomerSchema.
apps/backoffice-v2/src/pages/Root/Root.page.tsx Introduced ChatbotLayout component to conditionally render the Chatbot.
services/workflows-service/src/workflow/schemas/zod-schemas.ts Added optional isChatbotEnabled boolean property to ConfigSchema.
services/workflows-service/prisma/data-migrations Updated subproject commit identifier from 753b994eaa166fa54d450fd10930ce18724543da to 1347e799b3be4540364aa2780149b4dd7ba383d1.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatbotLayout
    participant Chatbot

    User->>ChatbotLayout: Request to open chat
    ChatbotLayout->>User: Check if chatbot is enabled
    alt Chatbot enabled
        ChatbotLayout->>Chatbot: Render Chatbot component
        Chatbot->>User: Display chat interface
    else Chatbot disabled
        ChatbotLayout->>User: Display nothing
    end
Loading

🐰 In the garden where I hop and play,
A chatbot’s here to brighten the day!
With messages quick and answers so neat,
Come chat with me, it’ll be a treat!
So let’s hop on in, don’t be shy,
A world of wonders awaits, oh my! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Omri-Levy Omri-Levy enabled auto-merge (squash) September 4, 2024 11:58
@alonp99 alonp99 disabled auto-merge September 4, 2024 11:58
@alonp99 alonp99 merged commit 0037633 into dev Sep 4, 2024
2 checks passed
@alonp99 alonp99 deleted the chatbot branch September 4, 2024 11:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ee62d2c and 96d8959.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (6)
  • apps/backoffice-v2/package.json (1 hunks)
  • apps/backoffice-v2/src/domains/chat/chatbot-opengpt.tsx (1 hunks)
  • apps/backoffice-v2/src/domains/customer/fetchers.ts (1 hunks)
  • apps/backoffice-v2/src/pages/Root/Root.page.tsx (2 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/workflow/schemas/zod-schemas.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • services/workflows-service/prisma/data-migrations
Additional context used
Gitleaks
apps/backoffice-v2/src/domains/chat/chatbot-opengpt.tsx

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (10)
apps/backoffice-v2/src/domains/customer/fetchers.ts (1)

22-22: LGTM!

The addition of the isChatbotEnabled property to the CustomerSchema object is consistent with the PR objective of introducing a chatbot feature. The property is correctly typed as a boolean and has a sensible default value of false. The property is also nested within the config object, which is nullable and has a default value, ensuring that the isChatbotEnabled property will have a default value even if the config object is not provided.

apps/backoffice-v2/src/pages/Root/Root.page.tsx (3)

5-7: LGTM!

The import statements are correctly added to support the new ChatbotLayout component.


17-29: LGTM!

The ChatbotLayout component is correctly implemented and handles the loading state and conditional rendering based on the customer data.


37-37: LGTM!

The ChatbotLayout component is correctly integrated into the Root component to display the chatbot alongside the existing layout components.

services/workflows-service/src/workflow/schemas/zod-schemas.ts (1)

65-65: LGTM!

The new optional boolean property isChatbotEnabled is added correctly to the ConfigSchema object. It follows the existing schema structure and conventions.

The optional nature of the property ensures backward compatibility and flexibility in the configuration, allowing the chatbot feature to be enabled or disabled as needed.

apps/backoffice-v2/src/domains/chat/chatbot-opengpt.tsx (3)

13-13: Verify that the clientId constant is not an actual API key.

The static analysis tool flagged the clientId constant as a potential API key. It is important to ensure that the clientId is not an actual API key and is safe to be exposed in the client-side code. If it is an API key, it should be moved to a server-side configuration and not exposed in the client-side code.

Please verify that the clientId constant is not an actual API key and is safe to be exposed in the client-side code. If it is an API key, please move it to a server-side configuration and update the code to fetch the clientId from the server-side configuration.

Tools
Gitleaks

13-13: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


82-82: Accessibility attributes used correctly.

The component uses the aria-label attribute to provide an accessible label for the chatbot toggle button and the alt attribute to provide an alternative text for the chatbot logo image, which is a good practice for accessibility. Good job on making the component accessible!

Also applies to: 84-88


20-31: useEffect hook used correctly for updating user data in the chatbot client.

The component uses the useEffect hook to update the user data in the chatbot client whenever the authenticated user's data changes, which is a good practice for keeping the chatbot client in sync with the application state. The useEffect hook also checks if the session variable has a user property before updating the user data in the chatbot client, which prevents errors if the session variable is undefined or does not have a user property. Good job on keeping the chatbot client in sync with the application state!

apps/backoffice-v2/package.json (2)

59-59: LGTM!

The addition of @botpress/webchat dependency with version ^2.1.10 is approved. It aligns with the PR objective of introducing a chatbot feature to the application.


60-60: Please provide more information about the usage of @botpress/webchat-generator dependency.

It is unclear how this dependency is used in the application based on the provided context. Could you please explain its purpose and how it integrates with the chatbot feature?

Comment on lines +68 to +81
style={{
width: '60px',
height: '60px',
borderRadius: '50%',
background: 'none',
border: 'none',
cursor: 'pointer',
position: 'fixed',
bottom: '20px',
right: '20px',
zIndex: 1000,
padding: 0,
overflow: 'hidden',
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the inline styles into a separate CSS file or using a CSS-in-JS library.

The component uses inline styles to style the chatbot toggle button and the chatbot container, which is not ideal for maintainability and reusability. Inline styles make it difficult to reuse the styles across multiple components and make it harder to maintain the styles as the codebase grows.

Consider extracting the inline styles into a separate CSS file or using a CSS-in-JS library like styled-components or emotion. This will make it easier to reuse the styles across multiple components and make it easier to maintain the styles as the codebase grows.

Also applies to: 92-104

Copy link

sentry-io bot commented Sep 4, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ Error: Unexpected state: user_creating d(src/domains/chat/chatbot-opengpt) View Issue

Did you find this useful? React with a 👍 or 👎

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