3

나는 예를 구축 봤는데을 사용하여 표준 카드에 이미지를 추가 할 수 있지만 응답 카드에 이미지를 추가 그들이 어디에 어떤이없는 방법. 알렉사 기술 키트 : <a href="https://github.com/amzn/alexa-skills-kit-js/tree/master/samples" rel="nofollow">alexa-skills-kit-js/samples/</a></p> <p>에 JS

response.askWithCard(speechOutput, repromptOutput, cardTitle, cardContent);

어디 이미지가 가는가? cardContent는 일반적으로 문자열입니다. 나는 그것을 이미지가 들어있는 물체로 만들뿐 ...?

답변

0

'Simple'은 하드 코드 된 것처럼 보이고 작고 큰 이미지 URL에는 'Standard'카드가 필요합니다. 여기에 당신은 기능을 추가 할 AlexaSkill.js의 로컬 복사본을 수정해야

https://github.com/amzn/alexa-skills-kit-js/blob/master/samples/historyBuff/src/AlexaSkill.js#L142

if (options.cardTitle && options.cardContent) { 
     alexaResponse.card = { 
      type: "Simple", 
      title: options.cardTitle, 
      content: options.cardContent 
     }; 
    } 

의 코드입니다. 여기

는의 API 사용이다 플라스크 - 질문 카드의 작동 방식을 보여주는 라이브러리 (광산) :

https://johnwheeler.org/flask-ask/responses.html#displaying-cards-in-the-alexa-smartphone-tablet-app

2

내가 마크 스트링거에서 아마존 개발자 지원 포럼에 비슷한 질문에 reply를 따라 :

나는 이것으로 몸부림 쳤고 지금은 효과가있다. Amazon이 제공하는 샘플 AlexaSkill.js 모듈을 사용하는 경우 을 입력하면 그림 카드를 다루는 데 몇 개의 섹션을 추가해야합니다. 지금

askWithPictureCard: function(speechOutput, repromptSpeech, cardTitle, cardContent, smallImageURL, largeImageURL) { 
     this._context.succeed(buildSpeechletResponse({ 
      session: this._session, 
      output: speechOutput, 
      reprompt: repromptSpeech, 
      cardTitle: cardTitle, 
      cardContent: cardContent, 
      cardSmallImageURL: smallImageURL, 
      cardLargeImageURL: largeImageURL, 
      shouldEndSession: false 
     })); 

당신이 그것을 호출 할 수 있습니다

if (options.cardSmallImageURL && options.cardLargeImageURL) { 
     alexaResponse.card = { 
      type: "Standard", 
      title: options.cardTitle, 
      text: options.cardContent, 
      image: { 
       smallImageUrl: options.cardSmallImageURL, 
       largeImageUrl: options.cardLargeImageURL 
      } 
     }; 
    } 

는 그 다음 askWithCard 정의 더 아래 후이를 추가하십시오 buildSpeechletResponse 섹션에서

은 유사한 유형 후 "단순"섹션이 추가 아마 상수보다 변수를 사용합니다. 이 (가) 사용하여 테스트되었습니다.

response.askWithPictureCard ('이 음성 출력', '이 카드의 제목입니다' '이것은 다시 메시지입니다' '이 카드 텍스트가의 필드가 텍스트 cardContent하지라고주의' 'https://s3.amazonaws.com/thisisthesmallpictureurl-small.jpg', 'https://s3.amazonaws.com/thisisthebigpictureurl-big.jpg');

그런 다음 유사한 프로세스에 따라 tellWithPictureCard 함수를 추가하십시오.

그는 내가 위 내 붙여 넣기 수정 카드을 의미 할 때 스트링거가 CRD를 넣어이 코드에서 하나의 작은 오타가있다. 그 외에도이 접근법이 저에게 효과적이었습니다.