简体   繁体   English

Google Dialogflow 没有利用我的更改

[英]Google Dialogflow doesn't utilize my changes

I'm trying to create a simple AI chatbot command for my discord bot and it's working out, however, my Dialogflow doesn't seem to utilize any changes that I made like new intents or different responses.我正在尝试为我的 discord 机器人创建一个简单的 AI 聊天机器人命令,并且它正在运行,但是,我的 Dialogflow 似乎没有利用我所做的任何更改,比如新意图或不同的响应。 it always just returns the text from before the changes or just doesn't return anything at all.它总是只返回更改之前的文本,或者根本不返回任何内容。

I might be really stupid.我可能真的很傻。

This is my code:这是我的代码:

const Discord = require("discord.js")
const axios = require('axios');
const uuid = require('uuid');
const dialogflow = require('@google-cloud/dialogflow');

require("dotenv").config();
const projectId = "mydialogprojectid";

console.log(process.env.GOOGLE_APPLICATION_CREDENTIALS)

const config = require(`../config.json`)

exports.run = async(client, message, args) => {
    message.channel.startTyping();

    // A unique identifier for the given session
    const sessionId = uuid.v4();
    console.log(sessionId)

    // Create a new session
    const sessionClient = new dialogflow.SessionsClient();
    const sessionPath = sessionClient.projectAgentSessionPath(projectId, sessionId);

    // The text query request.
    const request = {
      session: sessionPath,
      queryInput: {
        text: {
          // The query to send to the dialogflow agent
          text: args.join(' '),
          // The language used by the client (en-US)
          languageCode: 'en-US',
        },
      },
    };

    // Send request and log result
    const responses = await sessionClient.detectIntent(request);

    const result = responses[0].queryResult;

    if (result.intent) {
      console.log(`  Intent: ${result.intent.displayName}`);
    } else {
      console.log(`  No intent matched.`);
    }
    console.log(result)
    message.channel.stopTyping();
    return message.channel.send(result.fulfillmentText ? result.fulfillmentText : "Something went wrong, forgive me please! I'm still in beta.")
}

I have the same issue it works on the Dialogflow console etc but when using it in discord it wouldnt find the intent etc like you described.我有同样的问题,它适用于 Dialogflow 控制台等,但是在 discord 中使用它时,它不会像你描述的那样找到意图等。

At first i thought this was just some cache issue.起初我认为这只是一些缓存问题。 I will update this if i find a solution.如果我找到解决方案,我会更新这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM