简体   繁体   English

如何在Dialogflow API V2中处理多个代理?

[英]How to handle multiple agents in Dialogflow API V2?

I am using NodeJS SDK for accessing Dialogflow(V2) agent.I have multiple agents for multiple categories of business, one agent for one business. 我正在使用NodeJS SDK来访问Dialogflow(V2) 代理 。我有多个代理用于多个类别的业务,一个代理用于一个业务。

Currently I am using single aget for my Nodejs application and I am using the nodeje SDK of V2 which requires to set an environment variable of the GOOGLE_APPLICATION_CREDENTIALS (I mentioned private key json file path) for Authentication. 当前,我正在为Nodejs应用程序使用单个aget,并且正在使用V2的nodeje SDK,该SDK需要设置GOOGLE_APPLICATION_CREDENTIALS的环境变量(我提到了私钥json文件路径)以进行身份​​验证。

How can I implement the above functionality for multiple agents in my Nodejs application. 如何在Nodejs应用程序中为多个代理实现以上功能。 can you please help me how to resolve this issue? 您能帮我解决这个问题吗?

How to access listIntents method for multiple agents? 如何访问多个代理的listIntents方法?

Thanks. 谢谢。

If you want to use multiple agents, instead of using environment variables, the best alternative is to use keyFileName property when creating the client. 如果要使用多个代理,而不是使用环境变量,最好的替代方法是在创建客户端时使用keyFileName属性。

const sessionClient = new dialogflow.SessionsClient({
    keyFilename: '/path/to/google.json'
});
const sessionPath = sessionClient.sessionPath(projectId, sessionId);

Dialogflow easy way for authorization Dialogflow授权的简便方法

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

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