【问题标题】:Can I use Amazon LEX with Google assistant?我可以将 Amazon LEX 与 Google 助理一起使用吗?
【发布时间】:2018-11-30 11:09:38
【问题描述】:

我使用亚马逊的LEX 制作了一个聊天机器人。

有什么方法可以在我的手机中使用 Google 的Voice Assistant 来使用该应用程序?

如果不是为什么?

【问题讨论】:

  • 现在无法直接集成,您在这里几乎没有选择,您可以使用 google voice to text library 将语音转换为文本,然后将其发送到 lex 并获得回复,或者您可以通过以下方式使用对话流谷歌如果你需要进一步的帮助我愿意讨论
  • @varnit 你能给我一些关于如何做到这一点的链接吗?
  • 两种方法中你更喜欢哪一种?
  • @varnit 您建议的第一个选项
  • 为此您需要创建一个自定义应用程序,您可以吗?

标签: amazon-web-services amazon-lex google-voice assistant


【解决方案1】:

是的,可以将 Google 的语音助手应用程序与 Amazon Lex 一起用作 NLP 引擎。

  • 转到https://developers.google.com/actions/并登录
  • 使用左上角的按钮转到操作控制台
  • 创建一个 Amaaon Lex 代理
  • 在您的操作的 SDK 中,使用 Lex's runtime librarypostContentpostText 函数来调用 Lex 并获取意图名称
  • 在 Actions SDK 中创建函数以返回执行文本

Nodejs 中的伪代码:

const {actionssdk} = require('actions-on-google');
const express = require('express');
const bodyParser = require('body-parser');
const rp = require('request-promise');


const app = actionssdk({debug: true});

app.intent('actions.intent.MAIN', (conv) => {
  conv.ask('Hi!');
});

app.intent('actions.intent.TEXT', (conv, input) => {
  // here you will write code to call amazon lex and pass input text
  intent_name = lex_library(input) 

  return rp({
    intent_name
  })
  .then((res) => {
    // create an intent-action mapper
    const actionMap = {
      name: nameIntent,
      help: helpIntent,
    };
    // check the intent name from Lex
    if (res.intent_name && res.intent_name !== 'None') {

      // Map intents to functions for different responses
      actionMap[res['intent_name']](conv);

    } else {      
      conv.ask('Sorry, I don\'t understand what you mean.');
    }
  })
  .catch((e) => {
    console.log('Error =>', e);
  });
});

function nameIntent(conv) {
  conv.ask('My name is noobie. Hope you are fine!');
} 

function helpIntent(conv) {
  conv.ask('Help response');
}

express().use(bodyParser.json(), app).listen(8888)

请注意,您需要了解 action 的 sdk 和 lex 运行时库,才能根据需要扩展上述代码。
这是实现目标的高级方法。

希望对你有帮助。

【讨论】:

猜你喜欢
  • 2019-01-31
  • 2015-12-21
  • 1970-01-01
  • 1970-01-01
  • 2018-05-28
  • 1970-01-01
  • 1970-01-01
  • 2019-06-30
  • 2014-09-08
相关资源
最近更新 更多