我可以使用Actions SDK在自己的服务器中部署实现吗? [英] Can I deploy fulfillment in my own server with Actions SDK?

查看:60
本文介绍了我可以使用Actions SDK在自己的服务器中部署实现吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个初学者,我对使用Node.js客户端库(Actions SDK)建立充实感不甚了解。开发文档使用Firebase的Actions SDK,但我不想按Firebase部署实现。

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.

因此,我不知道如何使用Actions SDK在自己的服务器中部署实现。请告诉我该怎么做。谢谢!

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

推荐答案

这是一个使用nodeJs库的工作示例

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.")
})

上面的示例将返回 Hello World

above example will return "Hello World"

您还需要记住api.ai& Google行动仅接受https履行。没有SSL,您将无法连接到Webhook。

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.

这篇关于我可以使用Actions SDK在自己的服务器中部署实现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆