我目前正在使用 jovo 框架并使用 nodeJs 编写我的代码。我的项目是这样的:
你好!你叫什么名字?
萨尔玛
你好萨尔玛,很高兴认识你!你要我为你做什么?
播放更好的收音机
你想让我播放名为 A Better Radio 的收音机吗?
收音机的名称“更好的收音机”在意图的 json 文件中,所以在那里一切正常。但是,例如,如果我说“打赌”,则 radio.value 的值将变为未定义。我想检索用户“play a bet ray”所说的数据,以便我可以分析它。
那么如何从意图中检索用户所说的数据呢?
json看起来像这样:
{
"responseId": "552fd979-bf0f-4f6c-9ddd-39180824c26d",
"queryResult": {
"queryText": "GOOGLE_ASSISTANT_WELCOME",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/trythis-807dd/agent/sessions/1530712293227/contexts/google_assistant_welcome"
},
{
"name": "projects/trythis-807dd/agent/sessions/1530712293227/contexts/actions_capability_screen_output"
},
{
"name": "projects/trythis-807dd/agent/sessions/1530712293227/contexts/actions_capability_audio_output"
},
{
"name": "projects/trythis-807dd/agent/sessions/1530712293227/contexts/google_assistant_input_type_keyboard"
},
{
{
"fulfillmentText": "<speak>Hello! What's your name?</speak>",
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"ssml": "<speak>Hello! What's your name?</speak>"
}
}
]
},
"noInputPrompts": [
{
"ssml": "<speak>Please tell me your name.</speak>"
}
]
}
},
{
"responseId": "8d031a0f-9692-4e8d-a172-d7dad9c7511b",
"queryResult": {
"queryText": "my name is salma",
"parameters": {
"name": "Salma"
},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/trythis-807dd/agent/sessions/1530712293227/contexts/actions_capability_screen_output",
"parameters": {
"name.original": "salma",
"name": "Salma"
}
},
{
"fulfillmentText": "<speak>Hello Salma, nice to meet you! what do you want me to do for you?</speak>",
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"ssml": "<speak>Hello Salma, nice to meet you! what do you want me to do for you?</speak>"
}
}
]
},
"noInputPrompts": [
{
"ssml": "<speak>Hey , Salma, What can i do ?</speak>"
}
]
}
},
{
"fulfillmentText": "<speak>Hello Salma, nice to meet you! what do you want me to do for you?</speak>",
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"ssml": "<speak>Hello Salma, nice to meet you! what do you want me to do for you?</speak>"
}
}
]
},
"noInputPrompts": [
{
"ssml": "<speak>Hey , Salma, What can i do ?</speak>"
}
]
}
},
"fulfillmentText": "<speak>Do you want me to play the radio called A Better Radio ?</speak>",
我努力了 :
let inputs = this.getInputs();
let inputs = this.user().getPrevSpeech(0);
let inputs =this.getSpeechText();