{"id":297975,"date":"2020-01-30T21:00:10","date_gmt":"2020-01-30T21:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297975"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-01-30T21:00:10","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297975","title":{"rendered":"CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 Entities \u0432 DialogFlow (C#)"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486348\/\">\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043d\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u043b \u0432 \u0441\u0435\u0431\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c (AI) \u043e\u0442 Google \u2014 DialogFlow. \u0421\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0431\u043e\u0442 (Telegram) \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 API \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0430\u0439\u0442\u043e\u0432, \u0430 \u0441\u0430\u043c \u0436\u0435 DialogFlow \u043f\u043e\u043c\u043e\u0433\u0430\u043b \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f. \u041d\u0443\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0438\u043b\u0438 \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442, \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0442\u0435\u0440\u043c\u0438\u043d\u044b: Intent, Context, Action, Event \u043d\u0443 \u0438 \u0442\u043e \u0440\u0430\u0434\u0438 \u0447\u0435\u0433\u043e \u043c\u044b \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u2014 Entities. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 Entities.<\/p>\n<h3>Entities \u0432 DialogFlow<\/h3>\n<p>  \u0412 DialogFlow Entities \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 ReferenceValue \u0438 Synonyms. \u0427\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439, \u0447\u0442\u043e \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e, \u0438 \u0447\u0435\u043c \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u2014 \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u00ab\u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0431\u043e\u0442\u0443 \u0436\u0438\u0437\u043d\u044c\u00bb \u0438 \u0435\u043c\u0443 \u043b\u0435\u0433\u0447\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043e \u043a\u0430\u043a\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0438\u0434\u0435\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0447\u044c, \u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0433\u0430\u043b\u043e\u0447\u043a\u0430 \u043d\u0430 Fuzzy matching \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0431\u043e\u0442\u0443 \u0435\u0449\u0435 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043e \u0447\u0451\u043c \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043e\u0434\u043d\u0443 \u0431\u0443\u043a\u0432\u0443 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<br \/>  \u041c\u043e\u0441\u043a\u0432\u0430 \u2014 \u043c\u043e\u0441\u043a\u0432\u0430, \u041c\u043e\u0441\u043a\u0432\u0430, \u041c\u0441\u043a\u0432\u0430\u2026<br \/>  \u0417\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u044d\u043a\u0441\u043a\u0443\u0440\u0441, \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0441 Entity \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u044f\u043a\u043e\u0439 \u0432\u043e\u0437\u043d\u0438. \u042f \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u043d\u0442\u043e\u0432 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u043d\u043e \u0444\u0430\u043a\u0442 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u043a\u0442\u043e\u043c. <br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>EntityTypes<\/h3>\n<p>  \u0412\u043e\u0442 \u0442\u0443\u0442 \u0438 \u0431\u044b\u043b \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043f\u0435\u0440\u0432\u044b\u0439, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u0430\u043c\u0435\u043d\u044c. \u0412\u0435\u0434\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Entity, \u0430 \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 EntityType \u2014 \u0447\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0447\u0442\u043e?<br \/>  \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u0438 \u0441\u043b\u043e\u0436\u043d\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u0441\u0430\u043c\u043e\u043c DialogFlow \u0432\u043a\u043b\u0430\u0434\u043a\u0430 \u0441 EntityTypes \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Entities:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e8b\/26f\/4c7\/e8b26f4c787260c846fc37850f2ef1ea.png\" alt=\"image\"><br \/>  EntityType:<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8f3\/fc9\/3de\/8f3fc93de9f872ec14fc973b252e09ba.png\" alt=\"image\"> <br \/>  Entitie:<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/fa4\/920\/3be\/fa49203be0d3d4f9c656fb1bcf54f440.png\" alt=\"image\"><br \/>  \u0425\u043e\u0442\u044f \u0432 \u0441\u0430\u043c\u043e\u043c DialogFlow \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u0442\u044c Entity \u0438 \u0432 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c Entries (\u0442.\u0435. \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043d\u0435\u0439).<br \/>  \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<br \/>  \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c EntityType \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0440\u044f\u043c\u043e \u043d\u0430 DialoFlow, \u043d\u043e \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434 (\u0432\u0435\u0434\u044c \u043f\u043e\u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c Entities \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u043c \u0438\u043c\u0435\u043d\u043d\u043e EntityType \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c).<br \/>  \u0421\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c NuGet \u043f\u0430\u043a\u0435\u0442 Google.Cloud.Dialogflow.V2. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438, \u0431\u044b\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044f 1.1.0:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9f4\/484\/2be\/9f44842be3130249cf7edf23bc62b6b4.png\" alt=\"image\"><br \/>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043f\u0435\u0440\u0432\u0430 \u043a\u043b\u0430\u0441 \u0438 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e EntityTypeManagement \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"cs\">using Google.Api.Gax; using Google.Cloud.Dialogflow.V2;  public class EntityTypeManagement     {       \/\/Create - \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e EntityType \u043f\u043e \u0442\u0438\u043f\u0443 Test1 (\u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435)        \/\/projectId - Id \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 \u0441 DialogFlow       \/\/displayName - \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e           public async Task Create(string projectId, string displayName, EntityType.Types.Kind kind =        EntityType.Types.Kind.Map)         {             var client = await EntityTypesClient.CreateAsync();              var entityType = new EntityType();             entityType.DisplayName = displayName;             entityType.Kind = kind;              var createdEntityType = client.CreateEntityType(                 parent: new ProjectAgentName(projectId),                 entityType: entityType             );              Console.WriteLine($&quot;Created EntityType: {createdEntityType.Name}&quot;);         }               \/\/List - \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 EntityTypes \u043e\u0442 \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430       \/\/projectId - Id \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 \u0441 DialogFlow         public async Task&lt;PagedEnumerable&lt;ListEntityTypesResponse,EntityType&gt;&gt; List(string projectId)         {             var client = await EntityTypesClient.CreateAsync();             var response = client.ListEntityTypes(                 parent: new ProjectAgentName(projectId)             );             return response;         }         \/\/GetEntityTypeId - \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 EntityType \u0437\u0430 \u0438\u043c\u0435\u043d\u0435\u043c        \/\/projectId - Id \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430 \u0441 DialogFlow        \/\/targetEventTypeName - \u0438\u043c\u044f EntityType, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b \u0438\u0449\u0438\u0442\u0435          public async Task&lt;string&gt; GetEntityTypeId(string projectId,string targetEventTypeName)         {             var client = await EntityTypesClient.CreateAsync();             var response = client.ListEntityTypes(                 parent: new ProjectAgentName(projectId)             );             string id = response.Where(x =&gt; x.DisplayName == targetEventTypeName).FirstOrDefault().Name;             string returningId = id.Replace($&quot;projects\/{projectId}\/agent\/entityTypes\/&quot;, &quot;&quot;);             return returningId;         }         \/\/Delete \u0438 BatchDelete \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0440\u0430\u0437\u0443 EntityType        \/\/\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e entityTypeId         public async Task Delete(string projectId, string entityTypeId)         {             var client = await EntityTypesClient.CreateAsync();              client.DeleteEntityType(new EntityTypeName(projectId, entityTypeId: entityTypeId));              Console.WriteLine($&quot;Deleted EntityType: {entityTypeId}&quot;);          }                   public async Task BatchDelete(string projectId, IEnumerable&lt;string&gt; entityTypeIds)         {             var client = await EntityTypesClient.CreateAsync();             var entityTypeNames = entityTypeIds.Select(                 id =&gt; new EntityTypeName(projectId, id).ToString());             client.BatchDeleteEntityTypes(new ProjectAgentName(projectId),                 entityTypeNames);         }     }<\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Update \u043d\u0435\u0442 \u043b\u0438\u0448\u044c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e Create \u0443\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0451 \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 EntityTypes \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a Entity \u0438 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441 EntityManagement:<\/p>\n<pre><code class=\"cs\">public class EntityManagement     {        using Google.Cloud.Dialogflow.V2;                 \/\/Create - \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 Entity       \/\/entityTypeId - Id EntityType \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c Entity       \/\/entityValue - ReferenceValue \u0434\u043b\u044f Entity       \/\/ synonyms - \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u0432 \u0434\u043b\u044f Entity         public async Task Create(string projectId,                                  string entityTypeId,                                  string entityValue,                                  string[] synonyms)         {             var client = await EntityTypesClient.CreateAsync();             var entity = new EntityType.Types.Entity() { Value = entityValue};             entity.Synonyms.AddRange(synonyms);                          var operation = await client.BatchCreateEntitiesAsync(                 parent: new EntityTypeName(projectId, entityTypeId),                 entities: new[] { entity }             );              operation.PollUntilCompleted();         }         \/\/CreateMany - \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u0438\u0445 Entities         \/\/entityTypeId - Id EntityType \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c Entity        \/\/entities - \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f Entities \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f         public async Task CreateMany(string projectId,string entityTypeId, IEnumerable&lt;Entity&gt; entities)         {             var client = await EntityTypesClient.CreateAsync();             List&lt;EntityType.Types.Entity&gt; results = new List&lt;EntityType.Types.Entity&gt;();             foreach (var item in entities)             {                 var entity = new EntityType.Types.Entity() { Value = item.value };                 entity.Synonyms.AddRange(item.synonyms);                 results.Add(entity);             }                         var operation = await client.BatchCreateEntitiesAsync(                 parent: new EntityTypeName(projectId, entityTypeId),                 entities: results.ToArray());             operation.PollUntilCompleted();         }        \/\/Delete - \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 Entity, \u043d\u043e \u0435\u0441\u043b\u0438 &quot;string entityValue&quot; \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430       \/\/string[] entityValue \u0438 \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c entityValues: entityValue      \/\/\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0440\u0430\u0437\u0443.         public async Task Delete(string projectId, string entityTypeId, string entityValue)         {             var client = await EntityTypesClient.CreateAsync();              var operation = await client.BatchDeleteEntitiesAsync(                 parent: new EntityTypeName(projectId, entityTypeId),                 entityValues: new[] { entityValue }             );              Console.WriteLine(&quot;Waiting for the entity deletion operation to complete.&quot;);             operation.PollUntilCompleted();              Console.WriteLine($&quot;Deleted Entity: {entityValue}&quot;);          }                \/\/List - \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 Entities \u0441 EntityType       public async Task&lt;List&lt;Entity&gt;&gt; List(string projectId, string entityTypeId)         {             var client = await EntityTypesClient.CreateAsync();             var entityType = await client.GetEntityTypeAsync(new EntityTypeName(                 projectId, entityTypeId             ));             List&lt;Entity&gt; EntitiesList = new List&lt;Entity&gt;();                          foreach (var entity in entityType.Entities)             {                 List&lt;string&gt; Synonyms = new List&lt;string&gt;();                 foreach (var item in entity.Synonyms)                 {                     Synonyms.Add(item);                 }                 EntitiesList.Add(new Entity { value = entity.Value, synonyms = Synonyms.ToArray() });                 Synonyms = null;             }              return EntitiesList;         }     } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c Entity:  <\/p>\n<pre><code class=\"cs\">public class Entity     {         public string value { get; set; }         public string[] synonyms { get; set; }     } <\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e, \u0432\u0441\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 CRUD \u0433\u043e\u0442\u043e\u0432\u044b. \u041e\u043f\u044f\u0442\u044c-\u0442\u0430\u043a\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a Update, \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u043e\u043d\u0430 \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430, \u0442\u0430\u043a \u043a\u0430\u043a Create \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043a\u0430\u043a Update \u0442\u043e\u0436\u0435.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b \u0438, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f, \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0438 \u00ab\u0445\u0430\u0440\u0434\u043a\u043e\u0434\u00bb, \u043d\u043e \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0435\u043c, \u043a\u0442\u043e, \u043a\u0430\u043a \u0438 \u044f, \u043d\u0435 \u043c\u043e\u0433 \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"cs\">static void Main(string[] args)         {       EntityTypesManagement entityTypesManagement = new EntityTypesManagement();       EntityManagement entityManagement = new EntityManagement();        string ProjectId = &quot;Your Project`s id&quot;;        string EntityName = &quot;Your EntityName&quot;;       var entityId = await entityTypesManagement.GetEntityTypeId(ProjectId, EntityName);        Entity entity =  new Entity{value = &quot;1&quot;, synonyms = new[]{&quot;1&quot;,&quot;1&quot;}};       \/*await*\/ entityManagement.Create(ProjectId,entityId,entity);  } <\/code><\/pre>\n<p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/486348\/\"> https:\/\/habr.com\/ru\/post\/486348\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486348\/\">\n<h3>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043d\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u043b \u0432 \u0441\u0435\u0431\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c (AI) \u043e\u0442 Google \u2014 DialogFlow. \u0421\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0431\u043e\u0442 (Telegram) \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 API \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0430\u0439\u0442\u043e\u0432, \u0430 \u0441\u0430\u043c \u0436\u0435 DialogFlow \u043f\u043e\u043c\u043e\u0433\u0430\u043b \u043d\u0430\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f. \u041d\u0443\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0438\u043b\u0438 \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442, \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0442\u0435\u0440\u043c\u0438\u043d\u044b: Intent, Context, Action, Event \u043d\u0443 \u0438 \u0442\u043e \u0440\u0430\u0434\u0438 \u0447\u0435\u0433\u043e \u043c\u044b \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u2014 Entities. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c CRUD \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 Entities.<\/p>\n<h3>Entities \u0432 DialogFlow<\/h3>\n<p>  \u0412 DialogFlow Entities \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 ReferenceValue \u0438 Synonyms. \u0427\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439, \u0447\u0442\u043e \u0441\u0438\u043d\u043e\u043d\u0438\u043c\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e, \u0438 \u0447\u0435\u043c \u0438\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 \u2014 \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u00ab\u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0431\u043e\u0442\u0443 \u0436\u0438\u0437\u043d\u044c\u00bb \u0438 \u0435\u043c\u0443 \u043b\u0435\u0433\u0447\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043e \u043a\u0430\u043a\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0438\u0434\u0435\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0447\u044c, \u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0433\u0430\u043b\u043e\u0447\u043a\u0430 \u043d\u0430 Fuzzy matching \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0431\u043e\u0442\u0443 \u0435\u0449\u0435 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043e \u0447\u0451\u043c \u0438\u0434\u0435\u0442 \u0440\u0435\u0447\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043e\u0434\u043d\u0443 \u0431\u0443\u043a\u0432\u0443 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<br \/>  \u041c\u043e\u0441\u043a\u0432\u0430 \u2014 \u043c\u043e\u0441\u043a\u0432\u0430, \u041c\u043e\u0441\u043a\u0432\u0430, \u041c\u0441\u043a\u0432\u0430\u2026<br \/>  \u0417\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u044d\u043a\u0441\u043a\u0443\u0440\u0441, \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0441 Entity \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u044f\u043a\u043e\u0439 \u0432\u043e\u0437\u043d\u0438. \u042f \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u043d\u0442\u043e\u0432 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435, \u043d\u043e \u0444\u0430\u043a\u0442 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u043a\u0442\u043e\u043c.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-297975","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297975"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297975\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}