I'm trying to create entites in Dialogflow using node.js. The entity values will come from a JSON file. I'm currently testing it using postman. However, the entity values are not being separated and being combined in only one line. How do I fix this? Thank you
This is my sample JSON file that is being sent.
{
"Entity_Values": [
{
"Value": "One",
"Synonym":["Solo","1"]},
{
"Value": "Two",
"Synonym":["Double","2"]}
],
"Entity_Name": "Sample"}
This is what I have so far:
function createEntity (inputEntityobj, EntityName) {
const promises = [];
let entity_values = {value:[], synonyms:[]};
let inputEntity_values = [inputEntityobj];
for (i = 0; i < inputEntityobj.length; ++i) {
let inputEntity_values = [inputEntityobj[i].Value];
let inputEntity_synonym = [inputEntityobj[i].Synonym];
entity_values.value.push(inputEntity_values);
entity_values.synonyms.push(inputEntity_synonym);
}
const sizeRequest = {
parent: agentPath,
entityType: {
displayName: (EntityName),
kind: 'KIND_MAP',
autoExpansionMode: 'AUTO_EXPANSION_MODE_UNSPECIFIED',
enableFuzzyExtraction: true,
entities: [entity_values],
},
};
This code outputs
value: [ [ 'One' ], [ 'Two' ] ], synonyms: [ [ [Array] ], [ [Array] ] ]
And in Dialogflow, these are all in one entity entry instead of being in two separate entries.