在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):actions-on-google/actions-on-google-nodejs开源软件地址(OpenSource Url):https://github.com/actions-on-google/actions-on-google-nodejs开源编程语言(OpenSource Language):TypeScript 99.0%开源软件介绍(OpenSource Introduction):Actions on Google Client LibraryThis client library makes it easy to create Actions for the Google Assistant and supports Dialogflow, Actions SDK (v2), and Smart Home fulfillment.
Setup InstructionsInstall the library with either Developer PreviewTo support features under Developer Preview, the library has a special This is installed with either The You can use the Developer Preview version to experience exciting new features that we’re still testing to make sure we have the best developer experience, and help us providing feedback on the API design and feature set. The APIs offered in Developer Preview have not matured to General Availability yet, which means:
Conversational ServicesDialogflow// Import the appropriate service and chosen wrappers
const {
dialogflow,
Image,
} = require('actions-on-google')
// Create an app instance
const app = dialogflow()
// Register handlers for Dialogflow intents
app.intent('Default Welcome Intent', conv => {
conv.ask('Hi, how is it going?')
conv.ask(`Here's a picture of a cat`)
conv.ask(new Image({
url: 'https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg',
alt: 'A cat',
}))
})
// Intent in Dialogflow called `Goodbye`
app.intent('Goodbye', conv => {
conv.close('See you later!')
})
app.intent('Default Fallback Intent', conv => {
conv.ask(`I didn't understand. Can you tell me something else?`)
}) Actions SDK// Import the appropriate service and chosen wrappers
const {
actionssdk,
Image,
} = require('actions-on-google')
// Create an app instance
const app = actionssdk()
// Register handlers for Actions SDK intents
app.intent('actions.intent.MAIN', conv => {
conv.ask('Hi, how is it going?')
conv.ask(`Here's a picture of a cat`)
conv.ask(new Image({
url: 'https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg',
alt: 'A cat',
}))
})
app.intent('actions.intent.TEXT', (conv, input) => {
if (input === 'bye' || input === 'goodbye') {
return conv.close('See you later!')
}
conv.ask(`I didn't understand. Can you tell me something else?`)
}) Notes about the code snippet
Dialogflow
Actions SDK
Smart Home// Import the appropriate service
const { smarthome } = require('actions-on-google')
// Create an app instance
const app = smarthome()
// Register handlers for Smart Home intents
app.onExecute((body, headers) => {
return {
requestId: 'ff36...',
payload: {
// ...
},
}
})
app.onQuery((body, headers) => {
return {
requestId: 'ff36...',
payload: {
// ...
},
}
})
app.onSync((body, headers) => {
return {
requestId: 'ff36...',
payload: {
// ...
},
}
}) Notes about the code snippet
FrameworksExport or run for your appropriate framework: Firebase Functionsconst functions = require('firebase-functions')
// ... app code here
exports.fulfillment = functions.https.onRequest(app) Dialogflow Inline Editorconst functions = require('firebase-functions')
// ... app code here
// name has to be `dialogflowFirebaseFulfillment`
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app) Self Hosted Express Serverconst 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// ... app code here
exports.fulfillment = app Next StepsTake a look at the docs and samples linked at the top to get to know the platform and supported functionalities. Library Development InstructionsThis library uses Install the library dependencies with FunctionalityPublic interfaces, classes, functions, objects, and properties are labeled with the JSDoc This library supports the following Services:
Actions SDKThis library supports only Actions SDK fulfillment version 2. To ensure that your fulfillment uses version 2, set the References & Issues
Make ContributionsPlease read and follow the steps in the CONTRIBUTING.md. LicenseSee LICENSE. TermsYour use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论