3.6.2 • Published 2 years ago

jovo-client-web v3.6.2

Weekly downloads
119
License
Apache-2.0
Repository
-
Last release
2 years ago

Jovo Web Client

To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-client-web

The Jovo Web Client enables you to build voice and conversational experiences for the web. Use this package (vanilla JavaScript, find the Vue.js client here) in your frontend web app and connect it to your Jovo backend using the Jovo Core Platform.

Introduction

Jovo Client and Jovo Core Platform

Jovo Clients are used as a frontend that collects user input. This input (e.g. speech or text) is then passed to the Jovo Core Platform that handles the conversational logic.

The "Jovo for Web" client can be used on websites and web apps. It comes with helpful features that make it easier to capture speech input, detect when a user stops speaking, and display information that is returned from the Jovo app. The client is open source and fully customizable.

Installation

Install the client into your web project like this:

$ npm install jovo-client-web

Quickstart

You can find starters for our Vue.js client at github.com/jovotech/jovo-client-web-starters.

Configuration

To access the Jovo Web Client, you have to create a new client object:

const client = new window.JovoWebClient.Client(endpointUrl: string);

The endpointUrl specifies the url of your Jovo app. For local development you can use http://localhost:3000/webhook.

Sending a Request to the Jovo App

To send a request to the Jovo app, you can use the $client object:

client.createRequest({ type: RequestType.Text, body: { 'Hello World' } }).send();

Recording Voice Input

To record the user's voice input and automatically send it to the Jovo app, you can use the startInputRecording() and stopInputRecording() methods. Here's a sample implementation of a microphone button that will record the audio as long as the button is pushed down and send the audio as soon as it's released:

<button @mousedown="onMouseDown" @touchstart="onMouseDown"></button>
async onMouseDown(event: MouseEvent | TouchEvent) {
  if (!client.isInitialized) {
    await client.initialize();
  }
  if (client.isRecordingInput) {
    return;
  }
  if (event instanceof MouseEvent) {
    window.addEventListener('mouseup', this.onMouseUp);
  } else {
    window.addEventListener('touchend', this.onMouseUp);
  }
  await client.startInputRecording();
}

private onMouseUp(event: MouseEvent | TouchEvent) {
  window.removeEventListener('mouseup', this.onMouseUp);
  client.stopInputRecording();
}

Event Listeners

You can use listeners to react to events of the Jovo app from within your Vue component

import { ClientEvent } from 'jovo-client-web-vue';
import { Component, Vue } from 'vue-property-decorator';

@Component({
  name: 'overlay'
})
export default class Overlay extends Vue {
  mounted() {
    client.on(ClientEvent.Request, this.onRequest);
    client.on(ClientEvent.Response, this.onResponse);
    client.on(ClientEvent.Action, this.onAction);
  }

  beforeDestroy() {
    client.off(ClientEvent.Request, this.onRequest);
    client.off(ClientEvent.Response, this.onResponse);
    client.off(ClientEvent.Action, this.onAction);
  }

The following event types are supported:

NameDescriptionParsed Parameters
Requesttriggered when the request is received by the Jovo app. Parses the request(req: WebRequest)
Responsetriggered when the Jovo app sends out the response. Parses the response(res: WebResponse)
Actiontriggered when the Jovo app's response contains an action. Parses the action(action: Action)
Reprompttriggered when a reprompt is triggered. Parses the reprompt actions(repromptActions: Action[])

SpeechRecognizer

The SpeechRecognizer uses Google Chrome's ASR and has its own set of listeners:

import { SpeechRecognizerEvent } from 'jovo-client-web-vue';
import { Component, Vue } from 'vue-property-decorator';

@Component({
  name: 'overlay'
})
export default class Overlay extends Vue {
  mounted() {
    client.$speechRecognizer.on(
      SpeechRecognizerEvent.SpeechRecognized,
      this.onSpeechRecognized,
    );
  }

  beforeDestroy() {
    client.$speechRecognizer.off(
      SpeechRecognizerEvent.SpeechRecognized,
      this.onSpeechRecognized,
    );
  }
NameDescriptionParsed Parameters
StartDetectedtriggered when the speech input has started()
SpeechRecognizedtriggered when the speech input has been collected(event: SpeechRecognitionEvent)
Endtriggered when the SpeechRecognizer has ended (after SpeechRecognized)(event: SpeechRecognitionEvent)
Timeouttriggered when the SpeechRecognizer has timed out()
SilenceDetectedtriggered when the SpeechRecognizer detected silence()
Errortriggered when the SpeechRecognizer encountered an error(error: Error)

The AudioHelper class can be used to get the transcript from the SpeechRecognizerEvent:

import { AudioHelper } from 'jovo-client-web-vue';

//...
onSpeechRecognized(event: SpeechRecognitionEvent) {
  this.inputText = AudioHelper.textFromSpeechRecognition(event);
}
3.6.2

2 years ago

3.6.1

2 years ago

3.6.0

2 years ago

3.5.3

3 years ago

3.5.2

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.7

3 years ago

3.2.6

3 years ago

3.2.5

3 years ago

3.2.4

3 years ago

3.2.3

3 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.5-alpha.2

4 years ago

3.1.5-alpha.1

4 years ago

3.1.5-alpha.0

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.0

4 years ago

3.0.32

4 years ago

3.0.31

4 years ago

3.0.30

4 years ago

3.0.29

4 years ago

3.0.28

4 years ago

3.0.27

4 years ago

3.0.26

4 years ago

3.0.24

4 years ago

3.0.25

4 years ago

3.0.23

4 years ago

3.0.22

4 years ago

3.0.21

4 years ago

3.0.20

4 years ago

3.0.19

4 years ago

3.0.18

4 years ago

3.0.17

4 years ago

3.0.16

4 years ago

3.0.15

4 years ago

3.0.14

4 years ago

3.0.12

4 years ago

3.0.13

4 years ago

3.0.11

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago