0.99.73 • Published 5 months ago

@thelias/smartdata-app v0.99.73

Weekly downloads
-
License
AGPL-3.0
Repository
-
Last release
5 months ago

npm license

Installation Guide: Embedded Agent

The @smartdatahq/embedded-agent package is a powerful tool for integrating AI-driven conversational agents into your web applications. This guide will walk you through the installation and setup process.

Prerequisites

Before using the @smartdatahq/embedded-agent package, ensure the following:

  1. You have Node.js (version 14 or higher) and npm installed on your system.
  2. You have a valid identifier to connect to the @smartdatahq/embedded-agent service. Make sure you contact us to get your identifier.

Installation

To install the package, use npm or yarn:

Using npm

npm install @smartdatahq/embedded-agent

Using yarn

yarn add @smartdatahq/embedded-agent

Basic Usage

Here is an example of how to integrate the embedded agent into your React application:

Import the Component
import { EmbeddedAgent } from "@smartdatahq/embedded-agent";
import "@smartdatahq/embedded-agent/dist/index.css";

If your application is mostly SSR, you might need to dynamically import the package since it needs to run on the browser. For example, in next.j, you would want to import it like this

const EmbeddedAgent = dynamic(
  () => import("@smartdatahq/embedded-agent").then((mod) => mod.EmbeddedAgent),
  {
    ssr: false,
  },
);
Configure the embedded agent

Use the following example to set up the agent in your application:

const App = () => {
  const [minimized, setMinimized] = useState(true)
  const handleSearchResults = (result: any) => {
    // Search Results
    console.log('Search Results:', result);
  };

  const handleContextUpdate = (schema: any) => {
    // Updated Context Schema to keep track of the filters applied/current state
    console.log('Updated Context Schema:', schema);
  };

  return (
    <div style={{ height: minimized ? 120 : 400 }}>
      <h1>My Embedded Agent Application</h1>
      <EmbeddedAgent
        identifier="YOUR_IDENTIFIER" // Replace with your unique identifier
        onConversationFeedback={handleSearchResults}
        onContextJsonUpdate={handleContextUpdate}
        minimized={minimized}
        onMinimizedChange={() => setMinimized(!minimized)}
        contextSchema={{
            "$schema": "http://json-schema.org/draft-07/schema#",
            "type": "object",
            "properties": {
                 "maximum_price": {
                  "type": ["integer", "null"],
                  "minimum": 0,
                  "description": "Maximum Price for the article. Optional."
                },
                "manufacturer": {
                    "type": "array",
                    "description": "Manufacturer name (e.g., Samsung, Apple).",
                    "items": {
                        "type": "string",
                         "enum": ["Samsung", "Apple", "Nokia", "Philips"],
                    },

                },
                "screen_type": {
                    "type": "string",
                    "enum": ["OLED", "LCD", "AMOLED"],
                    "description": "Type of screen (e.g., OLED, LCD, AMOLED)."
                },
                "color": {
                    "type": "string",
                    "description": "Color of the product (e.g., black, white)."
                },
                "size": {
                    "type": "string",
                    "description": "Size of the product (e.g., 13-inch, 15-inch)."
                },
                "manufacturing_date": {
                  "type": "string",
                  "format": "date",
                "description": "Manufacturing date of this product"
                },
            },
            "required": ["price", "manufacturer", "manufacturing_date", "screen_type", "color", "size"],
        }}
      />
    </div>
  );
};

API

identifier (Required)
type: string
Description: Unique identifier for connecting to the embedded agent server.
contextSchema
type: Record<string, any>
Description: Defines the schema for extracting parameters from the conversation.

Notes: The contextSchema is defined in compliance with JSON Schema draft-07. This ensures the agent uses a well-defined schema for extracting and validating context data. Learn more here: https://tour.json-schema.org/

onContextJsonUpdate
Type: (schema: any) => void
Description: Callback function triggered when the context schema updates.
onConversationFeedback
Type: (result: any) => void
Description: Callback function triggered with a result when the agent resolves the user’s request.

Additionnal API

You can also customize the embedded agent with additional props, including:\ className: Custom class for styling the embedded agent container.\ minimized: Default minimized state of the embedded agent. If being used, you need to update it to match the value you get from the onMinimizedChange function.\ onMinimizedChange: Callback for changes in the minimized state.\ conversationId: Unique conversation ID for the session. This is generated internally if not provided. It should preferably be a UUID string.\ existingFilters: Existing filters to be applied to the conversation.\ isRendered: boolean. You can set this to false if you don't want the agent to show on render. Instead, we will display a message that can be clicked to load the agent\ onChatbotRender: This function is called when the agent is rendered. It only runs if you set render to false and manually click the message that displays in place of the agent.\ onError: Callback for handling errors.

0.99.66

5 months ago

0.99.68

5 months ago

0.99.69

5 months ago

0.99.61

5 months ago

0.99.62

5 months ago

0.99.63

5 months ago

0.99.64

5 months ago

0.99.65

5 months ago

0.99.70

5 months ago

0.99.71

5 months ago

0.99.72

5 months ago

0.99.73

5 months ago

0.99.60

5 months ago

0.99.44

6 months ago

0.99.45

6 months ago

0.99.46

6 months ago

0.99.47

6 months ago

0.99.48

5 months ago

0.99.49

5 months ago

0.99.43

6 months ago

0.99.55

5 months ago

0.99.56

5 months ago

0.99.57

5 months ago

0.99.58

5 months ago

0.99.59

5 months ago

0.99.50

5 months ago

0.99.51

5 months ago

0.99.52

5 months ago

0.99.53

5 months ago

0.99.54

5 months ago

0.99.33

6 months ago

0.99.34

6 months ago

0.99.35

6 months ago

0.99.36

6 months ago

0.99.37

6 months ago

0.99.38

6 months ago

0.99.39

6 months ago

0.99.40

6 months ago

0.99.41

6 months ago

0.99.42

6 months ago

0.99.22

7 months ago

0.99.23

7 months ago

0.99.24

7 months ago

0.99.25

7 months ago

0.99.26

7 months ago

0.99.27

7 months ago

0.99.28

7 months ago

0.99.29

7 months ago

0.99.30

7 months ago

0.99.31

7 months ago

0.99.32

7 months ago

0.99.20

8 months ago

0.99.21

8 months ago

0.99.19

9 months ago

0.99.17

9 months ago

0.99.18

9 months ago

0.99.16

9 months ago

0.99.15

9 months ago

0.99.13

9 months ago

0.99.12

9 months ago

0.99.11

9 months ago

0.99.9

9 months ago

0.99.8

10 months ago

0.99.7

10 months ago

0.99.6

10 months ago

0.99.4

10 months ago

0.99.3

10 months ago

0.99.2

10 months ago

0.99.1

10 months ago

0.99.0

10 months ago

0.97.0

10 months ago

0.96.0

10 months ago

0.95.0

11 months ago

0.94.0

11 months ago

0.93.0

11 months ago

0.92.0

11 months ago

0.91.0

11 months ago

0.90.0

11 months ago

0.89.0

11 months ago

0.88.0

11 months ago

0.87.0

11 months ago

0.86.0

11 months ago

0.85.0

11 months ago

0.84.0

11 months ago

0.83.0

11 months ago

0.82.0

11 months ago

0.81.0

11 months ago

0.80.0

11 months ago

0.79.0

11 months ago

0.78.0

11 months ago

0.77.0

11 months ago

0.76.0

11 months ago

0.75.0

11 months ago

0.74.0

11 months ago

0.73.0

11 months ago

0.72.0

11 months ago

0.71.0

11 months ago

0.70.0

11 months ago

0.69.0

11 months ago

0.68.0

11 months ago

0.67.0

11 months ago

0.66.0

11 months ago

0.65.0

11 months ago

0.64.0

11 months ago

0.63.0

11 months ago

0.62.0

11 months ago

0.61.0

11 months ago

0.60.0

11 months ago

0.59.0

11 months ago

0.58.0

11 months ago

0.57.0

11 months ago

0.56.0

11 months ago

0.55.0

11 months ago

0.54.0

11 months ago

0.53.0

11 months ago

0.52.0

11 months ago

0.51.0

11 months ago

0.50.0

11 months ago

0.49.0

11 months ago

0.48.0

11 months ago

0.47.0

11 months ago

0.46.0

11 months ago

0.45.0

11 months ago

0.44.0

11 months ago

0.43.0

11 months ago

0.42.0

12 months ago

0.41.0

12 months ago

0.40.0

12 months ago

0.39.0

12 months ago

0.38.0

12 months ago

0.37.0

12 months ago

0.36.0

12 months ago

0.35.0

12 months ago

0.34.0

12 months ago

0.33.0

12 months ago

0.32.0

12 months ago

0.31.0

12 months ago

0.30.0

12 months ago

0.29.0

12 months ago

0.28.0

12 months ago

0.27.0

12 months ago

0.26.0

12 months ago

0.25.0

12 months ago

0.24.0

12 months ago

0.23.0

12 months ago

0.22.0

12 months ago

0.21.0

12 months ago

0.20.0

12 months ago

0.19.0

12 months ago

0.18.0

12 months ago

0.17.0

12 months ago

0.16.0

12 months ago

0.15.0

12 months ago

0.14.0

12 months ago

0.13.0

12 months ago

0.12.0

12 months ago

0.11.0

12 months ago

0.10.0

12 months ago

0.9.0

12 months ago

0.8.0

12 months ago

0.7.0

12 months ago

0.6.0

12 months ago

0.5.0

12 months ago

0.4.0

12 months ago

0.3.0

12 months ago

0.2.0

12 months ago

0.1.0

12 months ago