无法使用 Actions SDK 读取意图

Unable to read intents using Actions SDK

我的 action.json 文件中有以下操作,

{
    "description": "Recommend movies",
    "initialTrigger": {
        "intent": "GIVE_RECOMMENDATION",
        "queryPatterns": [
            {"queryPattern": "What should I watch?"},
            {"queryPattern": "Give me a recommendation"},
            {"queryPattern": "Tell me a good ($String:genre)? movie"}
        ]
    },
    "httpExecution": {
        "url":"my webhook URL here"
    }
}

在我的 API 上,我有:

app.post('/', function(req, res){
    let assistant = new ActionsSdkAssistant({request: req, response: res});
    console.log('Current intent: ' + assistant.getIntent());
}

当我模拟我的动作并说 "What should I watch?" 时,当前意图总是 'assistant.intent.action.TEXT'。为什么它从来没有像它应该的那样 'GIVE_RECOMMENDATION'?

我假设您正在这样测试自己的技能:

open ACTION NAME

What should I watch?

您可能遇到了与我相同的问题,请参阅已接受的答案和评论

简而言之:触发初始意图后(即打开技能后)Actions SDK仅支持assistant.intent.action.TEXT意图,不再进行任何意图匹配。

意图匹配仅适用于操作的第一次调用:

ask ACTION_NAME What should I watch?

以上应该会给你正确的意图名称。

如果您没有自己的自然语言处理系统并且需要与用户进行基于意图的对话,

Google 建议使用 http://api.ai