Can I deploy fulfillment in my own server with Actions SDK?

元气小坏坏 提交于 2019-12-05 08:00:57

问题


I'm a beginner, and I can't understand something about building fulfillment with the Node.js client library (Actions SDK). The development document use the Actions SDK by firebase, but I don't want to deploy fulfillment by firebase.

So I don't know how to deploy fulfillment in my own server with Actions SDK. Please tell me how to do it. Thanks!


回答1:


Here is one working example with nodeJs library

'use strict';

var express = require('express');
var bodyParser = require('body-parser');
var exps = express();

const ApiAiApp = require('actions-on-google').ApiAiApp;

exps.use(bodyParser.json());

// API.AI actions
const WELCOME_ACTION = 'input.welcome';

exps.post('/hook', function(request, response) {
  const app = new ApiAiApp({request, response});
  function greetUser (app) {
    app.tell("Hello World!");
  }

  let actionMap = new Map();
  actionMap.set(WELCOME_ACTION, greetUser);

  app.handleRequest(actionMap);
});

exps.listen((process.env.PORT || 7001), function() {
    console.log("App up and running, listening.")
})

above example will return "Hello World"

You also need to keep in mind that api.ai & actions-on-google only accept https fulfillment. Without SSL you won't be able to connect to your webhook.



来源:https://stackoverflow.com/questions/45807482/can-i-deploy-fulfillment-in-my-own-server-with-actions-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!