3.6.2 • Published 2 years ago

jovo-platform-googleassistant v3.6.2

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

Google Assistant Platform Integration

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

Learn more about Google Assistant specific features that can be used with the Jovo Framework.

Introduction

Installation

$ npm install --save jovo-platform-googleassistant

Import the installed module, initialize and add it to the app object:

// @language=javascript

// src/app.js
const { GoogleAssistant } = require('jovo-platform-googleassistant');

app.use(new GoogleAssistant());

// @language=typescript

// src/app.ts
import { GoogleAssistant } from 'jovo-platform-googleassistant';

app.use(new GoogleAssistant());

Quickstart

Install the Jovo CLI

We highly recommend using the Jovo CLI if you want to benefit from all the features coming with Jovo. You can learn more and find alternatives on our installation page.

$ npm install -g jovo-cli

Create a new Jovo Project

You can create a Jovo project into a new directory with the following command:

// @language=javascript

# Create default Jovo project (Alexa and Google Assistant)
$ jovo3 new <directory>

# Create Google Assistant only Jovo project
$ jovo3 new <directory> --template google


// @language=typescript

# Create default Jovo project (Alexa and Google Assistant)
$ jovo3 new <directory> --language typescript

# Create Google Assistant only Jovo project
$ jovo3 new <directory> --template google --language typescript

This will create a new folder, download the Jovo "Hello World" template, and install all the necessary dependencies so you can get started right away.

This is how a typical Jovo project looks like:

// @language=javascript

models/
  └── en-US.json
src/
  |── app.js
  |── config.js
  └── index.js
project.js

// @language=typescript

models/
  └── en-US.json
src/
  |── app.ts
  |── config.ts
  └── index.ts
project.js

Find out more about the Jovo project structure here.

Run and Test the Code

To test the logic of your code, you can use the local development server provided by Jovo, and the Jovo Debugger.

To get started, use the following command:

// @language=javascript

# Run local development server
$ jovo3 run

// @language=typescript

# Run compiler
$ npm run tsc

# Run local development server
$ jovo3 run

This will start the development server on port 3000 and create a Jovo Webhook URL that can be used for local development. Copy this link and open it in your browser to use the Jovo Debugger.

Jovo Debugger

In the Debugger, you can quickly test if the flow of your voice app works. For this example, click on the LAUNCH button, and then specify a name on the MyNameIsIntent button. The Debugger will create requests and run them against your local webhook.

Find out more about requests and responses here.

$googleAction Object

The $googleAction object holds references to every Google Action specific feature:

// @language=javascript

this.$googleAction

// @language=typescript

this.$googleAction!

Jovo Language Model

For a general understanding of the Jovo Language Model, check out the platform-independent docs

You can add a dialogflow object at the root of the Jovo Language Model to add Dialogflow specific stuff using their original syntax. While building, it will be merged with the platform-independent stuff:

"dialogflow": {
	"intents": [
		{
			"name": "Default Fallback Intent",
			"auto": true,
			"webhookUsed": true,
			"fallbackIntent": true
		},
		{
			"name": "Default Welcome Intent",
			"auto": true,
			"webhookUsed": true,
			"events": [
				{
					"name": "WELCOME"
				}
			]
		}
	]
},

Session Entities

Session Entities work similar to Alexa Dynamic Entities in that you can enhance your existing static entities with dynamic ones to react to changes in user data or context. You can even choose whether to supplement or replace existing entities by providing an optional EntityOverrideMode.

Here is the official reference by Google: Session Entities.

Session Entities are stored for 20 minutes, although we recommend to clear every session entity as soon as the user session ends.

// You can use either of these functions, depending on your use case.

// Adds a single session entity.
this.$googleAction.addSessionEntityType({
	name: 'FruitInput',
	entities: [
		{
			value: 'apple',
			synonyms: ['red apple', 'sweet apple']
		},
		{
			value: 'banana',
			synonyms: ['yellow banana']
		}
	],
	entityOverrideMode: 'ENTITY_OVERRIDE_MODE_SUPPLEMENT'
});

// Adds an array of session entities.
this.$googleAction.addSessionEntityTypes([
	{
		name: 'FruitInput',
		entities: [
			{
				value: 'peach',
				synonyms: ['soft peach']
			}
		]
	}
]);

// Add a single session entity by providing the most basic properties as arguments.
this.$googleAction.addSessionEntity(
    'FruitInput', 
    'strawberry', 
    [ 'red strawberry' ]
);

User Data & Permissions

There are a lot of Google Action specific user data and permissions that your voice app can use, such as:

  • Contact Information
  • Location
  • Date and Time
  • Account Linking

You can find out more about your Google Action user's data here.

Google Action Interfaces

Google Transactions

The Google Transactions feature allows you to sell digital and physical goods in your Google Actions. You can find the documentation here.

Output

Besides the platform independent basic output capabilities and the ones specified in the Interfaces section of the docs, the Google Action platform supports the following two features:

Multiple Reprompts

Google Assistant allows to add multiple reprompts that are spoken out in order if there is no response by the user. Here is the official reference by Google: Static Reprompts.

The reprompts can be added to the ask method adding more parameters:

this.ask(speech, reprompt1, reprompt2, goodbyeMessage);

The first two messages are usually reprompt messages, the third one is used to say goodbye to the user.

Confirmation

You can ask your user to confirm something using the following method:

// @language=javascript

this.$googleAction.askForConfirmation(text);

// Example
this.$googleAction.askForConfirmation('Is this correct?');

// @language=typescript

this.$googleAction!.askForConfirmation(text: string);

// Example
this.$googleAction!.askForConfirmation('Is this correct?');

The question should be one which can be answered with yes or no.

The user's response will be mapped to the ON_CONFIRMATION intent, where you can check wether they confirmed or not using this.$googleAction.isConfirmed():

// @language=javascript

ON_CONFIRMATION() {
    if (this.$googleAction.isConfirmed()) {
        this.tell('Confirmed')
    } else {
        this.tell('Not confirmed');
    }
}

// @language=typescript

ON_CONFIRMATION() {
    if (this.$googleAction!.isConfirmed()) {
        this.tell('Confirmed')
    } else {
        this.tell('Not confirmed');
    }
}
3.6.2

2 years ago

3.6.1

2 years ago

3.6.0

2 years ago

3.5.4

3 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.4

3 years ago

3.2.3

3 years ago

3.2.2

3 years ago

3.2.1

4 years ago

3.2.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.25

4 years ago

3.0.24

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.14

4 years ago

3.0.15

4 years ago

3.0.13

4 years ago

3.0.12

4 years ago

3.0.10

4 years ago

3.0.11

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

2.2.30

4 years ago

2.2.29

4 years ago

2.2.28

4 years ago

2.2.27

4 years ago

2.2.25

4 years ago

2.2.24

4 years ago

2.2.23

4 years ago

2.2.21

4 years ago

2.2.20

5 years ago

2.2.19

5 years ago

2.2.18

5 years ago

2.2.17

5 years ago

2.2.16

5 years ago

2.2.15

5 years ago

2.2.14

5 years ago

2.2.13

5 years ago

2.2.12

5 years ago

2.2.11

5 years ago

2.2.10

5 years ago

2.2.9

5 years ago

2.2.8

5 years ago

2.2.7

5 years ago

2.2.6

5 years ago

2.2.5

5 years ago

2.2.4

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.13

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.2-beta.10

5 years ago

2.0.2-beta.9

5 years ago

2.0.2-beta.8

5 years ago

2.0.2-beta.7

5 years ago

2.0.2-beta.6

5 years ago

2.0.2-beta.5

5 years ago

2.0.2-beta.4

5 years ago

2.0.2-beta.3

5 years ago

2.0.2-beta.2

5 years ago

2.0.2-beta.1

5 years ago

2.0.2-beta.0

5 years ago

2.0.1-alpha.13

5 years ago

2.0.1-alpha.12

5 years ago

2.0.1-alpha.11

5 years ago

2.0.1-alpha.4

5 years ago

2.0.1-alpha.3

5 years ago

2.0.1-alpha.0

5 years ago