0.0.76 • Published 8 months ago

@broadreachalliance/q-assistant v0.0.76

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Q-Assistant

Q-Assistant is an NPM package that provides voice assistant capabilities for Contract Q web application. It includes a UI component for selecting and saving voice settings, as well as a custom hook for managing voice interactions.

Installation

To install the package, run:

npm install @broadreachalliance/q-assistant

or with Yarn:

yarn add @broadreachalliance/q-assistant

Usage

Importing Components

import { AssistantVoiceSettings, useAssistant } from "@broadreachalliance/q-assistant";

Example Implementation

function App() {
  const { startListening, stopListening, state } = useAssistant();

  const handleToggleListening = () => {
    if (state === "listening") {
      stopListening();
    } else {
      startListening();
    }
  };

  return (
    <div>
      <AssistantVoiceSettings />
      <button 
        onClick={handleToggleListening} 
        className="w-[20%] bg-[#1f4745] ml-auto text-white text-sm py-2 rounded-md shadow-md hover:bg-[#2ba49e]"
      >
        {state === "listening" ? "Stop Recording" : "Start Recording"}
      </button>
      <div>{state}</div>
    </div>
  );
}

Environment Variables

The assistant API endpoint should be defined in the .env file:

NEXT_PUBLIC_AI_ASSISTANT_HOST=<your-api-endpoint>

Local Storage Requirements

  • User Data: Must be stored in local storage under the key currentUser and should contain a userID.
  • Authorization Token: The customer's authorization token must be available in local storage under the key token.

API Reference

AssistantVoiceSettings

A UI component that allows users to select and save a preferred voice to local storage. The saved voice is used for chatbot response playback.

useAssistant Hook

A custom hook that provides functions and state for voice interaction.

State

  • idle - No active voice interaction.
  • listening - Actively capturing voice input.
  • responding - Processing a response.
  • processing - Handling voice data.

Functions

  • startListening() - Begins capturing voice input.
  • stopListening() - Stops capturing voice input.

License

MIT

0.0.76

8 months ago

0.0.75

8 months ago

0.0.74

8 months ago

0.0.73

9 months ago

0.0.72

9 months ago

0.0.71

9 months ago

0.0.70

9 months ago

0.0.69

9 months ago

0.0.68

9 months ago

0.0.67

9 months ago

0.0.66

9 months ago

0.0.65

9 months ago

0.0.64

9 months ago

0.0.63

9 months ago

0.0.62

9 months ago

0.0.61

9 months ago

0.0.60

10 months ago

0.0.59

10 months ago

0.0.58

10 months ago

0.0.57

10 months ago

0.0.56

10 months ago

0.0.55

10 months ago

0.0.54

10 months ago

0.0.53

10 months ago

0.0.52

10 months ago

0.0.51

10 months ago

0.0.50

10 months ago

0.0.49

10 months ago

0.0.48

10 months ago

0.0.47

10 months ago

0.0.46

10 months ago

0.0.45

10 months ago

0.0.44

10 months ago

0.0.43

10 months ago

0.0.42

10 months ago

0.0.41

10 months ago

0.0.39

10 months ago

0.0.38

10 months ago

0.0.37

10 months ago

0.0.36

10 months ago

0.0.35

10 months ago

0.0.34

10 months ago

0.0.33

10 months ago

0.0.32

10 months ago

0.0.31

10 months ago

0.0.30

10 months ago

0.0.29

10 months ago

0.0.28

10 months ago

0.0.27

10 months ago

0.0.26

10 months ago

0.0.25

10 months ago

0.0.24

10 months ago

0.0.23

10 months ago

0.0.22

10 months ago

0.0.21

10 months ago

0.0.20

10 months ago

0.0.19

10 months ago

0.0.18

10 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago