2017-04-05 114 views
1

我正在尝试在移动应用程序中创建一个卡,该应用程序连接到亚马逊账户和当前技能。亚马逊Alexa技能 - 创建移动应用程序卡

只要用'tellWithCard'调用EMIT函数就够了吗?就像例如:

that.emit(':tellWithCard', "Thank you for your visit", "Store Name", "Some description") 

我想这一切功能分开,但对我不起作用:

that.emit(':tellWithCard', message, "Store Name", description) 
that.emit(':tellWithLinkAccountCard', message, "Store Name", description) 

that.emit(':askWithCard', message, "Store Name", description) 
that.emit(':askWithLinkAccountCard', message, "Store Name", description) 

是否有任何额外的功能应该是什么?

回答

1

是的,这就是你所需要的。

下面是一个例子: (从原来的回购的README两者)​​

var cardTitle = 'Hello World Card'; 
var cardContent = 'This text will be displayed in the companion app card.'; 

var imageObj = { 
    smallImageUrl: 'https://imgs.xkcd.com/comics/standards.png', 
    largeImageUrl: 'https://imgs.xkcd.com/comics/standards.png' 
}; 

this.emit(':tellWithCard', 'lalalala', cardTitle, cardContent, imageObj); 

做验证来自服务模拟器你应该得到这样的回应:

{ 
    "version": "1.0", 
    "response": { 
    "outputSpeech": { 
    "type": "SSML", 
    "ssml": "<speak> lalalala </speak>" 
    }, 
    "card": { 
    "text": "This text will be displayed in the companion app card.", 
    "title": "Hello World Card", 
    "image": { 
     "smallImageUrl": "https://imgs.xkcd.com/comics/standards.png", 
     "largeImageUrl": "https://imgs.xkcd.com/comics/standards.png" 
    }, 
    "type": "Standard" 
    }, 
    "shouldEndSession": true 
    }, 
    "sessionAttributes": {} 
} 

但请记住,服务模拟器的测试不会在Alexa应用程序中创建实际的卡。为此,您需要使用设备。

+0

感谢您的回答。是的,我也以这种方式在设备上尝试过。设备连接到同一个帐户...但可能我做错了什么,而不是这部分的实施。你有什么其他的想法会影响卡片发送吗? –

+0

你在服务模拟器中得到这样的答案吗? – imTachu

+0

是的。我在“text”模拟器中,在https://echosim.io/ simulator中,在“测试”执行中,在真实设备上作为语音信息接收答案,甚至通过HTTP POST将记录接收到外部系统(用于测试,称为之前发出) 晚上在亚马逊帐户有一些特殊的配置? –