Receive the number of entities entered by the user in DIalogFlow - dialogflow-es

I'm trying to get the number of entities entered by the user of a specific entity in DialogFlow, but I did not find any API in the DialogFlow documents that could return that value (an example of what I want: in the fruit entity, if the user types maces, orange, the result returned would be 2).
const [Tamanho,Sabores,Rua,Num,NumPizza] = [agent.parameters.Tamanhos, agent.parameters.Sabores, agent.parameters.location, agent.parameters.numberinteger, agent.parameters.numbers];
const Sabtes = agent.parameters.Sabores.value; //It was just a test
if(Sabores.items.length>4)
agent.add("Você fez mais pedidos de sabores do que o permitido");
if(Sabtes>2)
agent.add("Você fez mais pedidos do que o permitido");

Related

How do I insert a specific key: value of Json into a postgres table using Node.js

I got a json variable in which i got all my data. I'd like to take a specific key and its value to insert it in a specific column of my table.
Here is an example:
{
'Code bati': 'Pas',
Etage: '0',
Zone: 'FST',
'Pièce': '000',
'Priorité': 5,
'Désignation': 'Salle de cours',
'Type d’installation': '',
'Date de mise en service': '',
"Date d'installation": '',
Maintenance: '',
'Entreprise ayant le contrat de maintenan': '',
'Date de visite': 44525,
Marque: 'Epson',
'Modèle': 'EB-1980WU',
'N° série': 'V5YF630231L',
'Heure Lampe': 1796,
Position: 'centré',
HDMI: 'oui',
VGA: 'oui',
Video: 'non',
Automate: 'MLC ???',
Liaison: 'RS232',
'Type écran': 'manuel',
'Cage sécurité': 'oui',
'Statut HDMI': 'à tester',
'Statut VGA': 'à tester'
},
Here is my array, i'd like to take for example the key 'Zone' and its attribute 'FST' to insert them in a specific table of my postgres database.
Do you have a solution for me ?
It is a bit unclear to me if you have already installed PG lib for node. I have used this one in the past (when I needed something simple and fast):
https://www.npmjs.com/package/pg.
Anyways, let's say you have this JSON in a variable, then you would like to parse that into an object, and then you can pick and choose whatever you want, and insert into the db.
Btw, your JSON is not formatted correctly, it is already formatted as an object... in the yourJSON var below I have formatted it correctly for you (by taking what you had, and wrapping it with JSON.stringify(whatYouHad))
const yourJSON = '{"Code bati":"Pas","Etage":"0","Zone":"FST","Pièce":"000","Priorité":5,"Désignation":"Salle de cours","Type d’installation":"","Date de mise en service":"","Date d'installation":"","Maintenance":"","Entreprise ayant le contrat de maintenan":"","Date de visite":44525,"Marque":"Epson","Modèle":"EB-1980WU","N° série":"V5YF630231L","Heure Lampe":1796,"Position":"centré","HDMI":"oui","VGA":"oui","Video":"non","Automate":"MLC ???","Liaison":"RS232","Type écran":"manuel","Cage sécurité":"oui","Statut HDMI":"à tester","Statut VGA":"à tester"}';
const parsedJSON = JSON.parse(yourJSON);
const query = 'INSERT INTO your_table (zone) VALUES ($1);
const bindings = [parsedJSON.Zone];
const insertResult = await dbClient.query(query, bindings);
console.log(insertResult);
You would need to clarify some more otherwise...

Get IdentifyRef fileds data from TFS workitem

I have a code that gets a WI Type [Code Review Response]. When trying to get the Created By field of the WI
field = {[System.CreatedBy, Microsoft.VisualStudio.Services.WebApi.IdentityRef]}
or Reviewed By, or Closed By field of the WI, I am getting the string Microsoft.VisualStudio.Services.WebApi.IdentityRef and not the user name.
It seems there is another, lower level object in it that holds the user data...
How can i get into the user name and details?
For example, when I trying the following code:
WorkItem linked_WI = witClient.GetWorkItemAsync(linked_WI_ID).Result;
//set WI object to the linked WI
string linked_WI_Type = linked_WI.Fields["System.WorkItemType"].ToString();
if (linked_WI_Type == "Code Review Response")
{
string codereview_closed_status = linked_WI.Fields["Microsoft.VSTS.CodeReview.ClosedStatus"].ToString();
string codereview_reviewer = linked_WI.Fields["Microsoft.VSTS.Common.ReviewedBy"].ToString();
}
I am not getting the reviewer name but again the identity reference (Microsoft.VisualStudio.Services.WebApi.IdentityRef) as string.
How can I loop into the Idefntify Ref object and get the user name?
Try DisplayName property of IdentityRef object:
var person = (IdentityRef)linked_WI.Fields["Microsoft.VSTS.Common.ReviewedBy"];
string codereview_reviewer = person.DisplayName;

Access and update the relationship field of a resource

I am grabbing the resource of particular asset from registry by something like this:-
var flight = factory.newResource(Namespace,'Aircraft',flightId);
To this resource, i am assigning a relationship by :-
flight.aircraft = factory.newRelationship('org.acme.airline.aircraft','Aircraft',aircraftId);
flight.aircraft.firstClassSeats = 10;
flight.aircraft.secondClassSeats = 10;
This relationship contains the following properties as defined in model file :
asset Aircraft identified by aircraftId {
o String aircraftId
// Number of seats per class
o Integer firstClassSeats default = 0
o Integer businessClassSeats default = 0
o Integer economyClassSeats default = 0
}
Flight Data :
asset Flight identified by flightId {
o String flightId regex=/[A-Z][A-Z][0-9][0-9][0-9]-[0-9][0-9]-[0-3][0-9]-[0-9][0-9]/
o String flightNumber
o Route route
o String[] aliasFlightNumber optional
--> Aircraft aircraft optional
}
Now, how to update these relationship values (for example firstClassSeats) of a particular flight resource and update it to the corresponding registry.

Required Field Validator for Model (.cto file) in Hyperledger Composer

I am developing a blockchain application using Hyperledger Composer.
This is a part of my model i.e. .cto file:
concept Address{
o String addressId
o String PersonInChargeFullName
o String title
o String address1
o String address2 optional
o String city
o String country
o String zipcode regex=/^\d{5}$/
o String phone regex=/^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/
o String email regex=/^([a-zA-Z0-9_\-\.]+)#([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
o Boolean isActive default=true
}
abstract participant Company identified by companyId{
o String companyId
o String companyName
o Address defaultAddress
}
participant OEM extends Company {
o Address[] plants
}
From this page, I understand that if we use optional as a field validator, which means that that field is optional, and others are not. Am I right?
Although, I have not made PersonInChargeFullName as optional, when I submit the data (for eg: "PersonInChargeFullName": "",) from composer-rest-server API, the transaction gets processed, without any error.
Please advise.
Here option is little bit of different concept try running your code without PersonInChargeFullName field not as PersonInChargeFullName = "" but don't include it in json input i am pretty sure you will get error.

Genexus: Error CS0234 calling External Object with stored procedure in Gx Ev 3 U5

I'm trying to execute a stored procedure in Genexus X Evolution 3 Upgrade 5 and it doesn't generate the C# External Object code, so it gives me an error:
error CS0234: El tipo o el nombre del espacio de nombres 'SdtdynQuery' no existe en el espacio de nombres 'GeneXus.Programs' (¨falta una referencia de ensamblado?)
How can I solve this?
Ariel,
You could wrap the External Object Code inside a Procedure and use it that way from Transaction Rules.

Resources