[英]How do you create an intent in C# using Dialogflow API?
https://cloud.google.com/dialogflow/docs/reference/rest/v2/projects.agent.intents/create我是 chatbot 的新手,我在 dialogflow 中创建了一个代理,我想在 c# 和然后在该代理中使用它,但我被卡住了,因为没有任何关于如何使用 C# 的 Dialogflow 库在 C# 代码中创建意图和实体的参考
You are probably looking for this documentation .您可能正在寻找此文档。
First, you need to create an authorized client.首先,您需要创建一个授权客户端。 For that, valid API credentials are required, see here for more information.
为此,需要有效的 API 凭据, 请参阅此处了解更多信息。 With that JSON file (as embedded resource in this case, but of course it is possible to load it differently), the code looks like this:
使用该 JSON 文件(在这种情况下作为嵌入式资源,但当然可以以不同方式加载它),代码如下所示:
// Create authorized client
var credentials = GoogleCredential.FromStream(
Assembly.GetExecutingAssembly().GetManifestResourceStream("Namespace.Of.GoogleApiCredentials.json"))
.CreateScoped(IntentsClient.DefaultScopes);
var client = new IntentsClientBuilder
{
TokenAccessMethod = credentials.GetAccessTokenForRequestAsync
}.Build();
This client can now be used to create and modify intents .该客户端现在可用于创建和修改意图。 The same process is used to modify entities (with the only difference that you need to create an
EntityTypesClient
instead of an IntentsClient
).相同的过程用于修改实体(唯一的区别是您需要创建
EntityTypesClient
而不是IntentsClient
)。 Remember to also extend the credentials' scope to include the entity client's default scopes.请记住还要扩展凭证的范围以包括实体客户端的默认范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.