npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@datasqrl/acorn-chatbot

v1.4.2

Published

This package is part of the datasqrl website. It is responsible for displaying the Acorn Chatbot UI.

Downloads

22

Readme

Acorn Chatbot

A chatbot for the default acorn agent implementation that's used by the cloud-frontend and the Acorn docker image.

Usage

Plain JS

Load script and css styles to your file. Then use AcornChatbot.create method to initialize a graph in selected DOM node.

<head>
  <title>DataSQRL Acorn ChatBot</title>
  <script src="https://unpkg.com/@datasqrl/acorn-chatbot/dist/umd/index.js"></script>
  <link
    rel="stylesheet"
    href="https://unpkg.com/@datasqrl/acorn-chatbot/dist/index.css"
  />
  <link
    rel="stylesheet"
    href="https://unpkg.com/@datasqrl/acorn-chatbot/dist/data-grid.css"
  />
</head>
<body>
  <div id="chatbot"></div>
  <script>
    // Fill user info
    const user = {
      userid: "",
      username: "",
      orgid: "",
      orgname: "",
      projectid: "",
      deploymentid: "",
    };

    const config = {
      history: {
        initialView: {
          logoUrl: "./bot.svg",
        },
        assistant: {
          imageUrl: "./bot.svg",
        },
      },
      messageInput: {
        onPostMessage: async (userMessageText) => {
          const res = await fetch("https://example.com/message", {
            method: "POST",
            body: JSON.stringify({
              content: userMessageText,
              ...user,
            }),
          });
          const data = await res.json();

          const responseMessage = {
            type: "chatbotTextMessage",
            content: data.content,
          };
          if (data.clientFunction) {
            // Test if response message contains Chart
            if (data.clientFunction.name === "data_visualization") {
              responseMessage.type = "chatbotChartMessage";
              responseMessage.chart =
                AcornChatbot.defaultDataTransformers.dataVisualization(
                  data.clientFunction.arguments,
                );
            } else {
              throw new Error(
                "Unrecognized function call: " + data.clientFunction.name,
              );
            }
          }
          return responseMessage;
        },
      },
      auth: {
        enabled: false,
        user: {
          imageUrl: "./user.svg",
        },
      },
    };

    const chatbot = AcornChatbot.create(
      document.getElementById("chatbot"),
      config,
    );
  </script>
</body>

React

Install @datasqrl/acorn-chatbot package and render <Chatbot /> with config passed as props.

import { Chatbot } from '@datasqrl/acorn-chatbot';

// You can use the same config object as in example above
const config = {};
return <Chatbot {...config} />;

Data format

The config object presented in usage examples may contain the following properties (but none of them are required):

auth

  • enabled?: boolean; - Should user see login form after Chatbot initialization. true by default.

  • onAuthentication?: (userId: string) => MaybePromise<ChatbotUser | undefined> - Triggers callback on form submission. You can throw Error with a message field to abort form submission and display error to end user. When user object is returned, chatbot config is automatically updated with this user.

  • user?: ChatbotUser; - Currently authenticated user

  • form.title?: string; - Form title. Log in with User ID by default.

  • form.submitButton.text: string; - Text of the Submit button. Login by default.

  • form.submitButton.text: inProgressText; - Text of the Submit button displayed while onAuthentication function is executing. Login... by default.

  • form.field.label - User Id field label. Hidden by default.

  • form.field.placeholder - Placeholder for the input field. User Id by default.

history

  • initialMessages?: Message[]; - Set messages initially displayed to the user instead of an InitialView component.

  • persistMessageHistory.location?: "localStorage" | "sessionStorage"; - Saves history in session or local storage. the "Clear History" feature should be configured when turned on.

  • persistMessageHistory.storageKey?: string - The key used to save and access data in selected storage. acornChatbot by default.

  • persistMessageHistory.clearHistoryButton.enabled?: boolean - Displays the "Clear messages" button on UI. true by default.

  • persistMessageHistory.clearHistoryButton.text?: string - Text the "Clear messages" button. Clear messages by default.

scrollToBottom

  • enabled?: boolean; - Display "Scroll to bottom" button when message history is scrolled to the top. true by default.

  • text?: string; - Text displayed on a button. by default.

  • title?: string; - Title text displayed on hover. Scroll to bottom by default.

messageInput

  • onPostMessage?: (content: string, user: ChatbotUser | null) => MaybePromise<Message>; - Handle process of submitting user message to the backend and receiving a response message. You can throw Error with a message field to abort form submission and display error message to end user. When response message object is returned it is automatically added to the end of the history.

  • form.submitButton.show - Should Message submit button be displayed. false by default.

  • form.submitButton.text - Text of the Submit button.

  • form.submitButton.inProgressText - Text of the Submit button displayed while onAuthentication function is executing.

  • form.field.label - Input field label. Hidden by default.

  • form.field.placeholder - Placeholder for the input field. Message your Assistant by default.

  • form.field.label - Should textarea height be automatically adjusted according to the content. true by default.

suggestedMessages

  • enabled?: boolean; - Display suggested button when message history is scrolled to the top. true by default.

  • onFetchSuggested?: () => MaybePromise<SuggestedMessage[]>; - When this function is passed, it will be executed on a chat mount. Returns array of suggested messages to be shown to the user.

  • initialMessages?: SuggestedMessage[]; - Set suggested messages initially displayed to the user instead of an InitialView component.