简体   繁体   中英

DialogFlow V2 gRPC (c#) (updating entities, etc.)

I have to refactor DialogFlow (previously API.AI) from V1 API to new V2 gRPC. So I prepared everything and started refactoring. But immediately I had some issues. See the example below, when trying to update entities for some entityType.

updateEntity. Synonyms is READ-ONLY property.

W00t ??? Any idea why is that? Or is there another (proper?) way to do this?

var client = DialogFlowHelper.DialogFlowCreateChannelClientEntityTypes();

List<EntityEntry> input = JsonConvert.DeserializeObject<List<EntityEntry>>(jsonData);

List<EntityType.Types.Entity> updateEntities = new List<EntityType.Types.Entity>();

foreach (var e in input)
{
    var updateEntity = new EntityType.Types.Entity();
    updateEntity.Value = e.value;

    // HERE IS THE PROBLEM !!!!
    // HERE IS THE PROBLEM !!!!
    // HERE IS THE PROBLEM !!!!
    //updateEntity.Synonyms = 

    updateEntities.Add(updateEntity);
}

var res = await client.BatchUpdateEntitiesAsync(
    new EntityTypeName("no_problem", "no_problem"),
    updateEntities
    );

Definiton for Synonyms goes like this:

//
// Summary:
//     Required. A collection of synonyms. For `KIND_LIST` entity types this must contain
//     exactly one synonym equal to `value`.
[DebuggerNonUserCode]
public RepeatedField<string> Synonyms { get; }

I have solved the issue.

Synonyms collection (RepeatedField) is ALREADY existing as an empty collection. So you can just add items to it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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