iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 15
0
AI & Data

DialogFlow從零開始30天系列 第 15

DialogFlow從零開始15天-Webhook Node.js開發

  • 分享至 

  • xImage
  •  

前言:

   選定了第一種架構圖和開發語言Node.js,那就開始寫codig。

開發工具:

  1.下載Node.js  https://nodejs.org/en/  (後面是用Mac示範)
  2.下載Visual Studio Code  https://code.visualstudio.com/?wt.mc_id=vscom_downloads

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(8080)

意圖處理(intent_process)

// ... app code start here
//build an app instance in your fulfillment webhook, follow these steps:
//step1:Call the require() function
// Import the service function and various response classes
const {
  dialogflow,
  actionssdk,
  Image,
  Table,
  Carousel,
  Payload,
  Permission
} = require('actions-on-google');


//step2:configure the app instance
const app = dialogflow({
  debug: true
});

//intent process
app.intent('intent_name', (conv) => {

	conv.ask('How are you?'); //回覆文字

});

// ... app code end here

//external API start

//external API end
使用心得:
     利用上面的方法,就可以輕鬆專注的開發意圖處理(intent_process)。

參考:
https://github.com/actions-on-google/assistant-conversation-nodejs
https://github.com/googleapis/nodejs-dialogflow
https://developers.google.com/assistant/conversational/df-asdk/reference/nodejsv2/overview


上一篇
DialogFlow從零開始14天-Webhook開發資源
下一篇
DialogFlow從零開始16天-Webhook Node.js開發-詢問地理位置
系列文
DialogFlow從零開始30天30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言