@assistant/conversation

中文文档
3.8.1发布于 2021/07/08Apache-2.0TypeScriptCommonJS近 30 天下载 5733

Actions SDK Fulfillment Library for Node.js

原始使用文档
文档目录9 节
  1. Setup Instructions
  2. Example Usage
  3. Frameworks
  4. Next Steps
  5. Library Development Instructions
  6. Functionality
  7. References & Issues
  8. Make Contributions
  9. License

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.

版本与发布记录

@assistant/conversation 共发布 12 个版本,首次发布于 2020/06/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.8.1latest2021/07/085 年前
3.8.02021/06/195 年前
3.7.12021/05/195 年前
3.7.02021/05/195 年前
3.6.02021/04/235 年前
3.5.02021/04/205 年前

关于 @assistant/conversation 的常见问题

@assistant/conversation 是什么?

Actions SDK Fulfillment Library for Node.js

如何安装 @assistant/conversation?

在项目目录运行 npm install @assistant/conversation,或使用 pnpm add / yarn add / bun add。

@assistant/conversation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@assistant/conversation 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@assistant/conversation 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10.18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@assistant/conversation 可以商用吗?

@assistant/conversation 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@assistant/conversation 的下载量有多少?

根据 npm 官方下载统计,@assistant/conversation 在 2026/10/07 – 2026/11/05 这 30 天内被下载 5,733 次,日均约 191 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@assistant/conversation 还在维护吗?

最新版本 3.8.1 发布于 2021/07/08(5 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/06/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。