我有多个设备将音频流式传输到我的服务器。
我的服务器正在将音频发送到我的自定义技能
如何将关于设备所在房间的额外状态传递给适配器,例如“房间名称”?
我的多部分请求包括:
{
'context': [
{
'header': {
'namespace': 'AudioPlayer',
'name': 'PlaybackState'
},
'payload': {
'token': '',
'offsetInMilliseconds': 0,
'playerActivity': 'IDLE'
}
},
{
'header': {
'namespace': 'Speaker',
'name': 'VolumeState'
},
'payload': {
'volume': 100,
'muted': False,
}
},
{
'header': {
'namespace': 'SpeechSynthesizer',
'name': 'SpeechState'
},
'payload': {
'token': '',
'offsetInMilliseconds': 0,
'playerActivity': 'FINISHED'
}
}
],
'event': {
'header': {
'namespace': 'SpeechRecognizer',
'name': 'Recognize',
'messageId': 'my-messageId',
'dialogRequestId': 'my-dialogRequestId',
},
'payload': {
'profile': 'CLOSE_TALK',
'format': 'AUDIO_L16_RATE_16000_CHANNELS_1'
}
}
}
我尝试在上下文中传递任意额外的标题,例如,
[
'header': {
'namespace': 'MyCustomSkill',
'name': 'RoomState'
},
'payload': {
'name': 'kitchen',
'temperature': '40'
}
]
但适配器无法访问这些额外的标头。请求如下所示:
{
"request": {
"locale": "en-GB",
"type": "IntentRequest",
"timestamp": "2017-10-05T22:33:35Z",
"requestId": "amzn1.echo-api.request.a415ac1b-7b42-4520-830d-a48912956a45",
"intent": {
"slots": {
"ROOM": {
"value": "kitchen",
"resolutions": {
"resolutionsPerAuthority": [
{
"authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.c9fd57b8-b243-42ed-a6a9-5745fccb6746.ROOM",
"values": [
{
"value": {
"id": "09228dac155633b13780552bc01dc2e0",
"name": "kitchen"
}
}
],
"status": {
"code": "ER_SUCCESS_MATCH"
}
}
]
},
"name": "ROOM",
"confirmationStatus": "NONE"
}
},
"name": "ChatIntent",
"confirmationStatus": "NONE"
}
},
"context": {
"AudioPlayer": {
"playerActivity": "IDLE"
},
"System": {
"user": {
"userId": "my-user-id"
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"device": {
"deviceId": "my-device-id",
"supportedInterfaces": {
"AudioPlayer": {}
}
},
"application": {
"applicationId": "my-application-id"
}
}
},
"version": "1.0",
"session": {
"user": {
"userId": "my-user-id"
},
"sessionId": "amzn1.echo-api.session.8c3e0d80-69e3-49ad-a981-d1073e0100b2",
"new": true,
"application": {
"applicationId": my-application-id"
}
}
}
这可以用上下文来实现吗?
答案 0 :(得分:0)
如果您希望有上下文,可以创建状态处理程序
或者你可以简单地使用
this.attributes存储您所需的信息。