0

I keep getting an error when testing my app on the simulator.
It gives: "APP NAME, isn't responding right now, try again soon" What am I doing wrong here?

ACTION.JSON

{
"accountLinking": {
    "clientId": "",          // SENSITIVE INFORMATION BLANK
    "clientSecret": "",       // SENSITIVE INFORMATION BLANK
    "grantType": "AUTH_CODE", 
  "authenticationUrl": "",      // SENSITIVE INFORMATION BLANK
  "accessTokenUrl": ""          // SENSITIVE INFORMATION BLANK


  },
  "actions": [{
        "description": "",
        "name": "MAIN",
        "fulfillment": {
            "conversationName": "PASS TEXT"
        },
        "intent": {
            "name": "actions.intent.MAIN",
            "trigger": {
                "queryPatterns": [
                    "talk to APP NAME"
                ]
            }
        }
    }],

 "conversations": {
        "PASS TEXT": {
            "name": "PASS TEXT",
            "url": ""  // MY FULFILLMENT END POINT
            "fulfillmentApiVersion": 2
        }
    }
}

This is just a sample to return "Sure, thing" to the user.

Fulfillment End Point PHP FILE

 header('Content-Type: application/json');
$a = array (
  'conversationToken' => '{"state":null,"data":{}}',
  'expectUserResponse' => true,
  'expectedInputs' => 
  array (
    0 => 
    array (
      'inputPrompt' => 
      array (
        'richInitialPrompt' => 
        array (
          'items' => 
          array (
            0 => 
            array (
              'simpleResponse' => 
              array (
                'textToSpeech' => 'Okay sure',
                'displayText' => 'Okay, Sure!',
              ),
            ),
          ),
          'suggestions' => 
          array (
          ),
        ),
      ),
      'possibleIntents' => 
      array (
        0 => 
        array (
          'intent' => 'actions.intent.TEXT',
        ),
      ),
    ),
  ),
);
echo json_encode($a);

PS: There aren't any PHP errors either. The page runs without any errors when visiting the URL.
I also tested it with OAuth PLAYGROUND and the returned result was this

OAUTH PLAYGROUND RESULT

 {
  "finalResponse": {
    "richResponse": {
      "items": [
        {
          "simpleResponse": {
            "displayText": "Sure, thing!", 
            "textToSpeech": "Sure thing"
          }
        }
      ]
    }
  }, 
  "expectUserResponse": 0, 
  "isInSandbox": 1
}
Elo97234c
  • 163
  • 1
  • 4
  • 15
  • Anybody? Help :( – Elo97234c Jul 24 '17 at 13:23
  • Double check your fulfillment URL is correct. You should check your web logs to confirm any incoming requests from the assistant. – Leon Nicholls Jul 24 '17 at 15:52
  • I did, my URL is correct. I log everything that happens in my php file, and i successfully receive all the data (User spoken Text, user_id) but the only issue is that the assistant wont respond to my commands. It says APP NAME isnt responding.... – Elo97234c Jul 24 '17 at 16:37

2 Answers2

2

You have two issues in your original post (which you updated to reflect these two issues):

Issue 1 - Invalid JSON response.

The value for "expectUserResponse" should be a boolean, not a number. This is significant in JSON. So it should be

"expectUserResponse": true

(The same is true of the value for "isInSandbox")

Issue 2 - Version mismatch

The response you're sending appears to match version 2 of the specification, but your action.json doesn't specify a version, so it defaults to version 1. To specify version 2, your action.json file "conversations" section should look like:

 "conversations": {
    "PASS TEXT": {
        "name": "PASS TEXT",
        "url": "https://whatever.example.com/endpoint",
        "fulfillmentApiVersion": 2
    }
 }

Other things to look at

  • Trying to do auth up front introduces complications. A good first thing to try would be to remove the auth requirement and make sure your endpoint is returning a valid response. Once you have that working, add the auth back in.

  • Sandbox mode is associated with transactions. Unless you're doing transactions, you can try dropping this parameter.

  • Make sure your webhook is an HTTPS endpoint with a valid (not-self-signed) certificate. If you need to create a tunnel for testing, consider ngrok

  • Make sure you have re-uploaded the action.json file when you change it, and that you restart the Simulator when you have done so.

My test files

I have this minimally working with the following files:

action.json


{
    "actions": [
      {
        "description": "Default Welcome Intent",
        "name": "MAIN",
        "fulfillment": {
          "conversationName": "playground"
        },
        "intent": {
          "name": "actions.intent.MAIN",
          "trigger": {
            "queryPatterns": [
              "talk to playground"
            ]
          }
        }
      }
    ],
    "conversations": {
      "playground": {
        "name": "playground",
        "url": "https://example.ngrok.io/assistant/webhookEnd.php",
        "fulfillmentApiVersion": 2
      }
    }

}

The webhookEnd.php file:

<?php
header('Content-Type: application/json');
$a = [
  "expectUserResponse" => false,
  "finalResponse" => [
    "richResponse" => [
      "items" => [
        [
          "simpleResponse" => [
            "textToSpeech" => "Sure thing!",
            "displayText" => "Sure, thing?"
          ]
        ]
      ]
    ]
  ]
];
echo json_encode($a);
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • I just did both those things, still no luck :( – Elo97234c Jul 24 '17 at 18:42
  • In Oauth Playground i can see my response! But on the simulator`{ "response": "APP NAME isn’t responding right now. Try again soon.\n", "conversationToken": "GhBzaW11bGF0b3JfZGV2aWNl", "audioResponse": "//NExAASA...", "debugInfo": {} }` – Elo97234c Jul 24 '17 at 18:45
  • Please Help! I've been stuck in this for 4 days now – Elo97234c Jul 24 '17 at 18:52
  • I've updated with other suggestions. The biggest is to demonstrate and explain the minimal problem. See if this works without auth. If it does - your problem is with auth and you should take steps to debug along those lines and, if necessary, post a new question focusing on the auth issue. – Prisoner Jul 24 '17 at 19:05
  • I dropped the Auth part, and removed sandbox. Still the same results :/ – Elo97234c Jul 24 '17 at 19:27
  • I'm not sure what you're doing, then. I've provided some additional suggestions, along with my test files that work. – Prisoner Jul 24 '17 at 19:39
  • Maybe somthing is wrong with my SSL becouse i got it for free (3 month trial). I'll give ngrok a shot and ill let you know how it goes! – Elo97234c Jul 24 '17 at 19:50
  • I tried it with HEROKU and it simply just doesnt work. Same Results. Im getting no where with this. – Elo97234c Jul 24 '17 at 20:29
  • If you were using my code, I found a typo in my code that could have caused an error. If you were not using my code - try my code. I have no further idea what it could be since it is working for me, as coded, with ngrok. – Prisoner Jul 24 '17 at 20:42
  • I tried it again, with your code completely still nothing :(. Is there anyone i might be able to talk to(Google Developer)? and check whats causing the error ? – Elo97234c Jul 25 '17 at 06:07
  • I GOT IT TO WORK! CHECK THE UPDATED END POINT PHP FILE – Elo97234c Jul 25 '17 at 07:08
  • What did you change besides moving from expecting a response to not? Please document your solution in another answer to help others. – Prisoner Jul 25 '17 at 10:20
0

I realized that in my google oauth playground, it had an Internal Server Error

HTTP/1.1 200 Internal Server Error
Content-length: 293
X-powered-by: ASP.NET
Server: Microsoft-IIS/8.5
Date: Tue, 25 Jul 2017 08:10:11 GMT
Content-type: application/json
X-powered-by-plesk: PleskWin

Then i Googled this error, and i saw posts which said that the response formate of the json was incorrect. So I went to the fulfilment documents and took a sample of the response json, converted it into a array and VOILA, internal server error gone

HTTP/1.1 200 OK
Content-length: 293
X-powered-by: ASP.NET
Server: Microsoft-IIS/8.5
Date: Tue, 25 Jul 2017 08:10:11 GMT
Content-type: application/json
X-powered-by-plesk: PleskWin 

I wish the simulator could have shown more details about the error without just prompting "APP NAME isnt responding"
Good Luck Guys!

Elo97234c
  • 163
  • 1
  • 4
  • 15