0

I am using Actions SDK and I have different configurations to get the simulator to invoke my custom intent! It seems that the simulator refuses to trigger any action other than MAIN, not even TEXT. Below is my action.json:

{
  "actions": [
    {
      "description": "Default Welcome Intent",
      "name": "MAIN",
      "fulfillment": {
        "conversationName": "SHOPPING"
      },
      "intent": {
        "name": "actions.intent.MAIN",
        "trigger": {
          "queryPatterns": [
            "Talk to stroller shopping expert"
          ]
        }
      }
    },
    {
      "description": "Listing strollers for a specified age group",
      "name": "SHOPPING",
      "fulfillment": {
        "conversationName": "SHOPPING"
      },
      "intent": {
        "name": "SHOPPING",
        "trigger": {
          "queryPatterns": [
            "I am looking for a jogging stroller",
            "I am shopping for a jogging stroller"
          ]
        }
      }
    }
  ],
  "conversations": {

    "SHOPPING": {
      "name": "SHOPPING",
      "url": "SOME_URL (I have a valid URL BTW)",
      "fulfillmentApiVersion": 2
    }
  }
}

I am using firebase and in the firebase log I cannot see any logs from my custom or TEXT intent. Here are part of my index.json code:

'use strict';

process.env.DEBUG = 'actions-on-google:*';

const ActionsSdkApp = require('actions-on-google').ActionsSdkApp;
const functions = require('firebase-functions');

const NO_INPUTS = [
    'Padon me, I didn\'t hear that.',
    'If you\'re still there, would you please say that again.',
    'We can stop here. Good luck with your shopping.'
];

const SHOPPING_INTENT = 'SHOPPING';

exports.shopStrollers = functions.https.onRequest((request, response) => {
    const app = new ActionsSdkApp({request, response});


    function handleMainInput(app) {
        console.log('mainIntent is invoked!');
        console.log("The input is %s", app.getRawInput());
        console.log("It seems that %s is never invoked!", app.StandardIntents.TEXT)

        let inputPrompt = app.buildInputPrompt(true, '<speak>Hi! <break time="1"/> ' +
            'I can help with finding strollers. How old is your baby?</speak>', NO_INPUTS);
        app.ask(inputPrompt);
    }

    function handleTextInput(app) {
        console.log('TEXT is invoked!');
        console.log("The input is %s", app.getRawInput());
        console.log("Finally TEXT HANDLER got invoked")

        if (app.getRawInput() === 'bye') {
            app.tell('Hope you found the service helpful and best of luck with your shopping, please come back again, goodbye!');
        } else {
            let inputPrompt = app.buildInputPrompt(true, '<speak>Here is a list of top' +
                ' <say-as interpret-as="ordinal">10</say-as>strollers' +
                ', say next for the next batch</speak>', NO_INPUTS);
            app.ask(inputPrompt);
        }
    }


    let actionMap = new Map();
    actionMap.set(SHOPPING_INTENT, handleTextInput);
    actionMap.set(app.StandardIntents.MAIN, handleMainInput);
    actionMap.set(app.StandardIntents.TEXT, handleTextInput);

    app.handleRequest(actionMap);
});

Does anybody have a clue what might be wrong, I would appreciate any help.

Ali
  • 379
  • 4
  • 4
  • Does your NLU is working correctly? – Bruno Araújo Jan 18 '18 at 16:48
  • If you look at the handleTextInput function in index.js, I just want to log something and prompt a message. There is no further NLU function in place yet! Once I get beyond this hurdle I will connect this to my NLU components. – Ali Jan 18 '18 at 17:28
  • Feel free to ignore me - this comment drips with subjectivity. But IMO ease of debugging is one reason I like to start these things without benefit of Firebase. If you know how to build a Node and Express server, and if you install ngrok as a reverse proxy/tunnel to your dev machine then you can use ngrok's built-in logging to see what is and is not on the wire between you and AoG to diagnose the problem fairly easily. If you are careful you can share code between the non-Firebase and Firebase versions in just a few lines. – William DePalo Jan 19 '18 at 01:32
  • I guess I will have to do this, I was hoping to avoid it. I will share the results later. – Ali Jan 19 '18 at 01:55
  • @WilliamDePalo I created a simple express app and created a mock response. The simulator invokes my local express app through ngrok, but the subsequent request is never sent to my app. I had the same problem with the firebase app. So, it seems the problem is not with Firebase or my local app. I am missing something in the action.json and I cannot figure out what it is?!! Do I need to create a new conversation for every intent? – Ali Jan 19 '18 at 20:39
  • Well, even after adding a new conversation for the intent, the simulator refuses to send a request to my service! It seems the simulator only and only sends one request to outside service and then subsequent requests are routed somewhere else! Has anybody else experienced a similar issue? – Ali Jan 19 '18 at 20:54

1 Answers1

0

Problem solved. I had to enable web history.

I was using a business email and I had to go through a convoluted configuration process to "turn on web history"! Now everything works fine through ngrok and my express app. I would imagine it should work on firebase as well. So, action.json and index.js were good, the issue was with incomplete configuration for the business email!

Here is the steps I followed: https://productforums.google.com/forum/#!msg/apps/-52VibOcvrY/wUow1QOJ3VQJ

Ali
  • 379
  • 4
  • 4