2017-09-05 7 views
1

エコーショーのスキルを開発中です。しかし、私はすべての表示テンプレートとpythonラムダスキルからものを表示することができません。私はアレクサのスキルを完璧に行い、うまく動作するイメージURLを追加することができます。しかし、表示テンプレートを追加すると、無効な応答が表示されています。エコー表示pythonスキルが表示テンプレートを生成しない

私はこのチュートリアル https://medium.freecodecamp.org/how-to-design-and-code-alexa-skills-for-amazons-echo-show-c5716da8fee5

を踏襲しており、これはJSONレスポンスに追加する追加のパラメータでした。

directives: [ 
    { 
    type: “Display.RenderTemplate”, 
    template: { 
     type: “BodyTemplate1”, 
     token: “T123”, 
     backButton: “HIDDEN”, 
     backgroundImage: { 
      contentDescription: “StormPhoto”, 
      sources: [ 
       { 
        url: “https://s3.amazonaws.com/hurricane-data/hurricaneBackground.png” 
       } 
      ] 
     }, 
     title: “Hurricane Center”, 
     textContent: { 
      primaryText: { 
       text: output, 
       type: “PlainText” 
      } 
     } 
    } 
}], 

これは私の修正されたレンダリングテンプレートメソッドの外観です。 デフbuild_speechlet_response(タイトル、出力、reprompt_text、should_end_session): imgurl = "https://thesweetsetup.com/wp-content/uploads/2014/10/scanbot_ico_1024.png"

return { 
    'outputSpeech': { 
     'type': 'PlainText', 
     'text': output 
    }, 
    'card': { 
     'type': 'Standard', 
     'title': title, 
     'text': output, 
     "image": { 
      "smallImageUrl": imgurl, 
      "largeImageUrl": imgurl 
     } 
    }, 
    'reprompt': { 
     'outputSpeech': { 
      'type': 'PlainText', 
      'text': reprompt_text 
     } 
    }, 
directives: [ 
    { 
    type: “Display.RenderTemplate”, 
    template: { 
     type: “BodyTemplate1”, 
     token: “T123”, 
     backButton: “HIDDEN”, 
     backgroundImage: { 
      contentDescription: “StormPhoto”, 
      sources: [ 
       { 
        url: “https://s3.amazonaws.com/hurricane-data/hurricaneBackground.png” 
       } 
      ] 
     }, 
     title: “Hurricane Center”, 
     textContent: { 
      primaryText: { 
       text: output, 
       type: “PlainText” 
      } 
     } 
    } 
}], 

    'shouldEndSession': should_end_session 
} 

しかし、これは私を与えます無効な応答形式としてのエラー。私はここで間違っています。

答えて

0

これは私のためにPythonで動作しました。しかし、リストテンプレートをレンダリングすることはできません。

def build_response(session_attributes, speechlet_response,text_response,speech_response,secondary_text,teritary_text,should_end_session): 
session=should_end_session 
return { 
    'version': '1.0', 
    'sessionAttributes': session_attributes, 
    'response': { 
      "directives": [ 
      { 
    "type": "Display.RenderTemplate", 
    "template": { 
"type": "BodyTemplate2", 
"token": "A2079", 
"backButton": "VISIBLE", 
"backgroundImage": { 
    "contentDescription": "Textured grey background", 
    "sources": [ 
    { 
     "url": "https://i.pinimg.com/originals/8b/e4/cc/8be4ccbbc43b1131c59b09b6c27f2e58.jpg" 
    } 
    ] 
    }, 
    "title": "Document Scanner", 
    "image": { 
    "contentDescription": "testing car", 
    "sources": [ 
     { 
     "url": "https://thesweetsetup.com/wp-content/uploads/2014/10/scanbot_ico_1024.png" 
     } 
    ] 
    }, 
    "textContent": { 
    "primaryText": { 
     "text": '''<font size='6'>'''+text_response+'''</font>''', 
     "type": "RichText" 
    }, 
    "secondaryText": { 
     "text": secondary_text, 
     "type": "PlainText" 
    }, 
    "tertiaryText": { 
     "text": teritary_text, 
     "type": "PlainText" 
    } 
    } 
} 
} 
      ], 
      "outputSpeech": { 
      "type": "SSML", 
      "ssml": '''<speak>'''+speech_response+''' </speak>''' 
      }, 
      "reprompt": { 
      "outputSpeech": { 
       "type": "SSML", 
       "ssml": "<speak>how can i help you ?</speak>" 
      } 
      }, 
      "shouldEndSession": session, 
      "card": { 
      "type": "Standard", 
      "title": "content.simpleCardTitle", 
      "content": "content.simpleCardContent" 
      } 
     } 
} 

text_response、speech_response、secondary_text、teritary_textはすべて追加された文字列パラメータです。

関連する問題