2017-02-12 46 views
0

我所試圖做的事:Alexa的意圖發送兩個請求,失敗

我有一個非常簡單的Alexa的技能來監聽命令字:

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

自定義插槽類型爲:

AFFILIATE_ACTIONS commissions | earnings | sales | summary 

我的樣品話語是:

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

這與我的PHP服務器進行通信,我在那裏偵聽請求類型。

問題是什麼?

當我調用命令字,沒有任何意圖,它使一個「LaunchRequest」到我的服務器,並正確地返回cardoutputSpeech

如果我問的意圖,它使一個IntentRequest到我的服務器,但然後還發送SessionEndedRequest

我處理IntentRequest並把它的線沿線的一個JSON編碼的響應:

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

我的亞馬遜回聲從來沒有講Some simple response而是給了我There was a problem communicating with the requested skill

我有一個非常類似的技術工作在此之前,但看不到我做錯了什麼。

我都試過了。

我使用PHP寫的每個原始請求的日誌文件,json_decoded要求我送回亞馬遜的響應。我也在使用測試工具,但是這給了我The remote endpoint could not be called, or the response it returned was invalid.。我知道它可以調用我的端點,因爲我看到每次寫入的日誌文件。

爲什麼叫我的意圖,但然後結束會話造成的錯誤?

回答

0

嘗試SSML應對alexa的要求, 例如:

{ 
"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>" 
    } 
    } 
} 
0

你得到的錯誤... endpoint could not be called, or the response it returned was invalid建議你發送回Alexa的服務JSON格式不正確。您正在接收請求,這是如何記錄的。現在,您只需排查您發回的回覆。這可能是一些小事。以下是json響應格式的文檔:https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html。如果您可以從PHP代碼中共享json輸出,那麼幫助解決問題會更容易。

而且,我相信你需要更改爲'shouldEndSession' => false

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