代码之家  ›  专栏  ›  技术社区  ›  pavithra rox

谷歌对话流小对话问题

  •  0
  • pavithra rox  · 技术社区  · 8 年前

    我正在用谷歌对话流开发聊天机器人应用程序。我正在使用node js client https://github.com/dialogflow/dialogflow-nodejs-client-v2 访问我的聊天机器人的数据。我已经从对话流控制台启用了小对话,当我从对话流Web演示或自己的控制台使用它时,它可以正常工作。

    var请求={ 查询输入:{ 会话客户端 const result=responses[0].查询结果; console.log(`response:$result.fullmenttext `); 如果(结果、意图){ res.json(“文本”:result.fullmenttext); }其他{ res.json(“fullmenttext”:“没有匹配的意图”); console.log(`no intent matched.`); } }) .catch(错误=>){ console.error('错误:',err); })(二)
    
    

    在那里我得不到我想要的结果。相反,它有不同的意图

    我在这里做得不对……访问聊天机器人的数据。我已经从对话流控制台启用了小对话,当我从对话流Web演示或自己的控制台使用它时,它可以正常工作。

    enter image description here

    对于同一个聊天应用程序,我使用DialogFlowNodeJS客户机实现了一个API。

     if (req.body.text) {
            query = req.body.text;
        }
        // Get the city and date from the request
        var request = {
            session: sessionPath,
            queryInput: {
                text: {
                    text: query,
                    languageCode: languageCode,
                },
            },
        };
        // Send request and log result
        sessionClient
            .detectIntent(request)
            .then(responses => {
                console.log('Detected intent');
                const result = responses[0].queryResult;
                console.log(`  Query: ${result.queryText}`);
                console.log(`  Response: ${result.fulfillmentText}`);
                if (result.intent) {
                    res.json({ "text": result.fulfillmentText });
                } else {
                    res.json({ 'fulfillmentText': "No intent matched" });
                    console.log(`  No intent matched.`);
                }
            })
            .catch(err => {
                console.error('ERROR:', err);
            }); 
    

    在那里我得不到我想要的结果。相反,它有不同的意图

    enter image description here

    我在这里做得不对……

    1 回复  |  直到 8 年前
        1
  •  1
  •   Aza T    8 年前

    推荐文章