简体   繁体   English

如何使用 Dialogflow API 在 C# 中创建意图?

[英]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.

相关问题 如何使用C#.Net为POST请求和响应创建Webhook dialogflow API - How to create webhook dialogflow API for POST request and response using C# .Net 如何在 wehhook c# 中使用 dialogflow 中的权限助手意图 - how to use the Permission helper intent from dialogflow in wehhook c# Dialogflow - 检测意图冻结 - C# - Dialogflow - Detect Intent freezes - C# 你如何在C#中创建扩展? - How do you create an extension in C#? 使用C#在Dialogflow API V2中进行身份验证 - Authentication in Dialogflow API V2 using C# 您可以使用C#中的Revit API创建主题演讲吗 - Can you Create a Keynote using the Revit API in C# 如何使用c#凭据管理器API在1个用户名下存储多个凭据? - How do you store multiple credentials under 1 username using the c# credential manager API? TFS API:如何使用 C# 从服务器路径获取本地映射路径? - TFS API: How do you get a local mapped path from a server path by using C#? 如何使用带有C#的Google表格API将CSV文件上传到Google表格? - How do you upload a csv file to google sheets using the google sheets api with c#? 如何使用 iText7 从 C# 中的 MemoryStream 创建 Image 对象? - How do you create an Image object from a MemoryStream in C# using iText7?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM