0

我一直无法让 node.js 的 google-actions sdk 传递参数。我安装了https://github.com/actions-on-google/actionssdk-eliza-nodejs示例项目,发现参数也不适用于该项目。有什么见解吗?

在网络模拟器中,我输入了“我感到难过”

这是我得到的请求

{
"query": "i am feeling sad",
"accessToken": "**masked**",
"expectUserResponse": true,
"conversationToken": "CiZDIzU4O..."content_copy,
"debugInfo": {
    "assistantToAgentDebug": {
        "assistantToAgentJson": {
            "user": {
                "user_id": "**masked**"
            },
            "conversation": {
                "conversation_id": "1484523995718",
                "type": 2,
                "conversation_token": "{\"elizaInstance\":{\"noRandom\":false,\"capitalizeFirstLetter\":true,\"debug\":false,\"memSize\":20,\"version\":\"1.1 (original)\",\"quit\":false,\"mem\":[],\"lastchoice\":[[-1],[-1],[-1],[-1],[-1,-1,-1],[-1,-1],[-1],[-1],[-1],[-1,-1,-1],[-1,-1,-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1,0,-1],[-1,-1,-1],[-1],[-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1],[-1],[-1,-1],[-1,-1],[-1],[-1],[-1],[-1],[-1],[-1],[-1,-1,-1],[-1]],\"sentence\":\"i am feeling sad\"}}"
            },
            "inputs": [
                {
                    "intent": "assistant.intent.action.TEXT",
                    "raw_inputs": [
                        {
                            "input_type": 2,
                            "query": "i am feeling sad"
                        }
                    ],
                    "arguments": [
                        {
                            "name": "text",
                            "raw_text": "i am feeling sad",
                            "text_value": "i am feeling sad"
                        }
                    ]
                }
            ]
        }
    }
}
}

text_value should = "sad",而不是基于 eliza.json 的 "我感到难过",它有:

{
"versionLabel": "Eliza v1",
"agentInfo": {
  "languageCode": "en-US",
  "projectId": "**masked**",
  "invocationNames": [
    "eliza"
  ],
  "voiceName": "female_1"
},
"actions": [
  {
    "description": "Start an Eliza consultation",
    "initialTrigger": {
      "intent": "assistant.intent.action.MAIN"
    },
    "httpExecution": {
      "url": "https://**masked**"
    }
  },
  {
    "description": "Deep link to Eliza consultation",
    "initialTrigger": {
      "intent": "raw.input",
      "queryPatterns": [
        {
          "queryPattern": "my emotional state is $SchemaOrg_Text:text"
        },
        {
          "queryPattern": "I am concerned about $SchemaOrg_Text:text"
        },
        {
          "queryPattern": "I am feeling $SchemaOrg_Text:text"
        },
        {
          "queryPattern": "I need to talk about my feelings"
        }
      ]
    },
    "httpExecution": {
      "url": "**masked**"
    }
  }
],
"deploymentStatus": {
  "state": "NEW"
},
 "versionId": "1"
}
4

2 回答 2

1

Google Actions SDK 将解析模式并为激活您的操作的意图正确绑定参数。例如,如果你说

在我的行动中,我感到难过

您将收到如下所示的参数

"arguments": [
    {
        "name": "text",
        "raw_text": "sad",
        "text_value": "sad"
    },
    {
        "name": "trigger_query",
        "raw_text": "i am feeling sad",
        "text_value": "i am feeling sad"
    }
]

但是,如果您通过将 expect_user_response 设置为 true 来请求操作的输入,则始终使用意图“assistant.intent.action.TEXT”以原始形式返回参数。由您来解析这些原始参数,如该问题的其他答案中所示。

另请注意,据我所知,未根据文档返回 Schema_Org 类型。更多信息在这里

于 2017-01-26T16:38:43.333 回答
0

如果您使用的是 Actions SDK,那么您必须使用自己的 NLP 来理解原始用户查询和提取参数。如果您没有自己的 NLP,那么我们建议您使用 API.AI。

于 2017-01-18T16:38:11.943 回答