Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@assistant/conversation

actions-on-google8.3kApache-2.03.8.1TypeScript support: included

Actions SDK Fulfillment Library for Node.js

google, google actions, google assistant, assistant conversation, fulfillment library, client library

readme

Actions SDK Node.js Fulfillment Library

This fulfillment library exposes a developer friendly way to fulfill Actions SDK handlers for the Google Assistant.

NPM Version Build Status

Setup Instructions

Make sure Node.js >=10.18.0 is installed.

Install the library with either npm install @assistant/conversation or yarn add @assistant/conversation if you use yarn.

Example Usage

// Import the appropriate service and chosen wrappers
const {
  conversation,
  Image,
} = require('@assistant/conversation')

// Create an app instance
const app = conversation()

// Register handlers for Actions SDK

app.handle('<YOUR HANDLER NAME>', conv => {
  conv.add('Hi, how is it going?')
  conv.add(new Image({
    url: 'https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg',
    alt: 'A cat',
  }))
})

Frameworks

Export or run for your appropriate framework:

Firebase Functions

const functions = require('firebase-functions')

// ... app code here

exports.fulfillment = functions.https.onRequest(app)

Actions Console Inline Editor

const functions = require('firebase-functions')

// ... app code here

// name has to be `ActionsOnGoogleFulfillment`
exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app)

Self Hosted Express Server

const express = require('express')
const bodyParser = require('body-parser')

// ... app code here

const expressApp = express().use(bodyParser.json())

expressApp.post('/fulfillment', app)

expressApp.listen(3000)

AWS Lambda API Gateway HTTP proxy integration

// ... app code here

exports.fulfillment = app

Next Steps

Take a look at the docs and samples linked at the top to get to know the platform and supported functionalities.

Library Development Instructions

This library uses yarn to run commands. Install yarn using instructions from https://yarnpkg.com/en/docs/install or with npm: npm i -g yarn.

Install the library dependencies with yarn. If you want to run any of the sample apps, follow the instructions in the sample README.

Functionality

Public interfaces, classes, functions, objects, and properties are labeled with the JSDoc @public tag and exported at the top level. Everything that is not labeled @public and exported at the top level is considered internal and may be changed.

References & Issues

Make Contributions

Please read and follow the steps in the CONTRIBUTING.md.

License

See LICENSE.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

[3.8.1]

Added

  • Add missing home storage capability.

[3.8.0]

Added

  • Add continueTtsDuringTouch to Canvas, which is used to continue TTS output when a user interacts with a Canvas element.

[3.7.1]

Changed

  • Fixed linting errors

[3.7.0]

Added

  • Add enableFullScreen to Canvas, allowing the canvas application to occupy the full screen, and not have a header at the top.

Changed

  • Enhanced reference docs with detailed comments and examples

[3.6.0]

Added

  • Add timezone field to Device

[3.5.0]

Added

  • Add MediaContext index and Media prompt items
  • Add location field to Device

[3.4.0] - 2021-03-10

Added

  • Add playlist features to media prompt

[3.3.0] - 2021-02-01

Added

  • Add request verification

Changed

  • Update library Typedoc settings based on breaking changes

3.2.0 - 2020-10-09

Added

  • Support for Collection Browse.

Changed

  • Conversation to accept custom logger interface.
  • google-auth-library to new major version.

Fixed

  • PromptItem type errors.

3.1.0 - 2020-08-26

Added

  • Support for Canvas state.

Fixed

  • Options not existing for public interface.

3.0.1 - 2020-06-17

Fixed

  • Logs were incorrectly prefixed with "assistant-conversation-nodejs" instead of "assistant-conversation".

3.0.0 - 2020-06-17

Added

  • Support for Actions Builder and Actions SDK.
  • Support for new media features like media controls and media progress.
  • Support for home storage.

Changed

  • Simplify and align the names of the raw JSON API and fulfillment library.
  • Redesign API objects to be based directly on raw JSON objects.
  • Update type code generation to use published JSON schema.
  • Merge conv.ask and conv.close into conv.add to reflect conversation exits being defined by the Actions Builder console.

Removed

  • Support for Node <10.
  • Support for the legacy Actions SDK.
  • Support for Dialogflow.
  • Smart home support (continued support in actions-on-google).