Reputation: 95
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!
Upvotes: 0
Views: 711
Reputation: 670
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.
Upvotes: 2