1

I have made a Chat-Bot using Amazon's LEX.

Is there any way I can use that application using Google's Voice Assistant in my phone?

If not why?

varnit
  • 1,859
  • 10
  • 21
noobie
  • 751
  • 4
  • 13
  • 33
  • direct integration is not possible right now you have few options here you can use google voice to text library to convert voice into text and then send it to lex and get response back or you can use dialog flow by google if you need further help i'm open for discussion – varnit Nov 30 '18 at 11:41
  • @varnit can you please provide me some links on how to do that? – noobie Nov 30 '18 at 12:30
  • which approach you would prefer out of two ? – varnit Nov 30 '18 at 12:31
  • @varnit the first option that you've suggested – noobie Nov 30 '18 at 12:33
  • for that you need to create a custom app are you ok with that ? – varnit Nov 30 '18 at 12:43
  • I'm not familiar with this term "custom app". But please explain. – noobie Nov 30 '18 at 13:01
  • custom app means you have to create your own app in android and use lex and google speech to text libraries – varnit Nov 30 '18 at 13:26
  • it would be easy and better if you use DialogFlow instead of Amazon Lex, any particular reason you do not want to use DialogFlow? – sid8491 Dec 10 '18 at 10:46
  • @sid8491 I know about DialogFlow but my whole App-ecosystem is on AWS, I do not wan't to switch to GCP. – noobie Dec 10 '18 at 10:48

1 Answers1

1

Yes it is possible to use Google's voice assistant application with Amazon Lex as NLP engine.

  • Go to https://developers.google.com/actions/ and log in
  • Go to Actions Console using button on top left corner
  • Create an Amaaon Lex agent
  • In your actions's SDK use Lex's runtime library to postContent or postText function to call Lex and get intent name
  • Make your functions in Actions SDK to return fulfillment text

Pseudo Code in 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)

Please note that you will need to have understanding of action's sdk and lex runtime library to extend above code according to your need.
This is high level approach to achieve your goal.

Hope it helps.

sid8491
  • 6,622
  • 6
  • 38
  • 64
  • @noobie its amazon lex's run-time library, you need to use either postText or postContent functions from it. https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/LexRuntime.html – sid8491 Dec 17 '18 at 09:25