0

What I am trying to do:

I have a very simple Alexa Skill which listens for a command word:

{
    "intents": [{
       "intent": "AffiliateEmpire",
       "slots": [
       {
          "name": "affiliate_action",
          "type": "AFFILIATE_ACTIONS"
       },
       {
          "name": "date",
          "type": AMAZON.DATE
       }
   }]
}

The custom slot type is:

AFFILIATE_ACTIONS   commissions | earnings | sales | summary

My sample utterances are:

AffiliateEmpire for affiliate {affiliate_action}
AffiliateEmpire get {affiliate_action} for {date}

This communicates with my PHP server where I listen for the request type.

What is the problem?

When I invoke the command word without any intent, it makes a "LaunchRequest" to my server and correctly returns a card and outputSpeech

If I ask for an intent, it makes an IntentRequest to my server but then also sends a SessionEndedRequest.

I handle the IntentRequest and send it a json encoded response along the lines of:

array(
   'version'           => '1.0',
   'response'          => array(
      'outputSpeech' => array(
      'type' => 'PlainText',
         'text' => 'Some simple response'
      )),
   'shouldEndSession'  => true,
   'sessionAttributes' => array()
));

My Amazon Echo never speaks the Some simple response but instead gives me There was a problem communicating with the requested skill

I had a very similar skill working before this, but cannot see what I am doing wrong.

What I have tried.

I am using php to write a log file for each raw request, json_decoded request and the response I sent back to Amazon. I am also using the testing tool, however this gives me The remote endpoint could not be called, or the response it returned was invalid.. I know it can call my endpoint as I see the log file written to each time.

Why is it calling my intent but then causing an error by ending the session?

Alexander Holsgrove
  • 1,795
  • 3
  • 25
  • 54

2 Answers2

0

Try the SSML for responding the alexa request, Ex:

{
"version": "1.0",
"response": {
    "directives": [],
    "shouldEndSession": false,
    "outputSpeech": {
        "type": "SSML",
        "ssml": "<speak>I am going to book a cab for you @ your provided time.</speak>"
    }
  }
}
Shivam Gupta
  • 149
  • 5
0

The error you're getting... endpoint could not be called, or the response it returned was invalid suggests that the json you're sending back to the Alexa service is not formatted correctly. You're receiving the request, which is how it's getting logged. Now, you just need to troubleshoot the response your sending back. It's likely something minor. Here are the docs for the json response format: https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html. If you can share the json output from the php code it would be easier to help troubleshoot.

Also, I believe you need to change to 'shouldEndSession' => false

array(
   'version'           => '1.0',
   'response'          => array(
      'outputSpeech' => array(
      'type' => 'PlainText',
         'text' => 'Some simple response'
      )),
   'shouldEndSession'  => false,
   'sessionAttributes' => array()
));
Steve Tingiris
  • 331
  • 1
  • 5