I have a very basic example
I want to be able to add multiple types and quantities of things - the user may or may not enter the quantity in which case i want to ask for it.For example
I want to order 1 Margherita pizza Medium pan crust and a deluxe veggie
I have defined the following entities
#Pizzas
#PizzaCrusts
#PizzaSizes`
And a composite entity #PizzaWithCrustAndSizes which is made up of all three of the above.
In my request i have a slotfill parameter 'allPizzas' which is a list of the above composite type.
There is a webhook call which refines the order before confirming it. However when i receive the parameter - i get it as a string rather than an object type.
allPizzas: [ '1 Margherita Pan Medium' ]
How do i make Dialogflow send it as an object, is there any way
Yes you can achieve this
you have 3 entites
#Pizzas
#PizzaCrusts
#PizzaSizes
and a composite entity #PizzaWithCrustAndSizes
so in the entity #PizzaWithCrustAndSizes first uncheck the define synonyms checkbox
then you will get the value field now enter the values as
#Pizzas:Pizzas #PizzaCrusts:PizzaCrusts #PizzaSizes:PizzaSizes
go to intent training phrases
I want to order 1 Margherita pizza Medium pan crust
remove all the individual entities and select "Margherita pizza Medium pan crust" and map it to composite entity "#PizzaWithCrustAndSizes"
it will give you the parameter value as object.
Related
I have an entity called 'Vehicle', inside there are different values like 'Car', 'Motorcycle' or 'Truck'.
I want the intent to trigger only if detects a Entity Vehicle with value 'Truck'.
In this pic I show the configuration of my intent. The problem is that will trigger with any value which is a Vehycle
How can I fix it without using fulfillments?
Don't use entities in this case. The issue is that an entity will match any instance of that entity.
If you only want to match 'Truck', add that in your training phrases and then add a parameter named Vehicle with the value Truck, without using an entity. Like so:
Notice that Truck is not highlighted and the Entity field is empty.
Since #sys.airport only exists for the default English locale, I want to create a custom entity that emulates it for other locales.
From what I've read here, you can put subentity types into the value fields, say, the system entity #sys.geo-city:city and a custom entity #usr.iata-code:iata, and it will match either one or the other.
But I don't understand how you would tell Dialogflow which city and which IATA code go together, so that Dialogflow (ES) would know to send the complete object {"city":"Amsterdam", "iata": "AMS"} to the webhook after matching either "Amsterdam" or "AMS", as it does happen with #sys.airport.
Thanks for any input!
It will be difficult to create a custom entity that works just like #sys.airport. The #sys entities are special and can do somethings custom entities can't, for instance, pairing values together.
As you pointed out, you can put multiple entities together in one single entity by using Composite Entities, but the only thing this does is allow you to recognize two values made up from other #sys or custom entities in a single entity. It doesn't give you the option to create pairs between the values of the entities.
If you would want to create something like this, you would need some code that does a look up in a dictionary or list. So when "AMS" is matched, the code fills in the missing property "Amsterdam" or vice versa.
I want to create an entity that has any value except the values that are defined in another entity.
For example, i have an entity that contains all the possible products categories that i use in the bot, and if the user type a value that is not in that entity i want to react in some way.
It's like a fallback but only triggered when that condition is met.
Any suggestion?
Entity extraction is based on some definite value that can be identified and separated. There should be some basic features defined for the agent to train on. Based on these trained features, the agent will look for an entity and extract it from the user's response.
If you have already defined an entity to look for, it will be extracted by the Dialogflow based on the training data. If there is nothing defined it will not be identified as an entity as the agent will be not sure what to look for.
So, what you can do is,
Make the entity (already defined) as not required. Uncheck the "required" checkbox in the Dialogflow.
Add the "#sys.any" in the Entity you defined and make it a composite Entity with the combination of your Entity and "#sys.any" something in the line of
Train your agent to look for this new Entity with your Basic Entity data and Anything else data.
Collect this in the webhook.
OR
You when you want to collect anything else, you can collect user utterance from the agent object and parse the data using Regex pattern of your choice.
I have a product catalog and a classification catalog. The product catalog contains a product and the classification catalog contains attributes, however when I try to insert the product with the attributes it doesn't show when I click the product and go under attributes tab.
How I enter product with attributes:
$lang=en
$productCatalog=productCatalog
$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
$approved=approvalstatus(code)[default='check']
$baseProduct=baseProduct(code,$catalogVersion)
$clAttrModifiers=system='MySystemClassifications',version='General',translator=de.hybris.platform.catalog.jalo.classification.impex.ClassificationAttributeTranslator,lang=nl
$id=#id[$clAttrModifiers];
INSERT_UPDATE Product;code[unique=true];$id;$catalogVersion
;M300047;200.59;
Is there something I have to do after adding it to link it to the product?
There are a lot of pitfalls when working with the classification system. I cannot see an obvious error in your impex script, so I want to ask for every precondition, that has to be fulfilled.
You need a ClassificationSystem (equivalent for Catalog for categories and product)
You need a ClassificationSystemversion (equivalent for CatalogVersion for category and product)
Your product has to be in a category.
This category needs a super category of type ClassificationClass.
You need a ClassificationAttribute.
You need a ClassAttributeAssignment which assigns your ClassificationAttribute to a ClassificationClass.
(Optional) You can create ClassificationAttributeUnits to define the unit of an attribute.
(Optional) You can create ClassificationAttributeValues to define possible values for a ClassificationAttribute.
When these preconditions are met, you can assign values to a product using your impex script.
Since this structure is a bit tricky, let me clarify it with an example:
Consider the ClassificationClasses "Photocameras" and "Videocameras". There are ClassificationAttributes like "Resolution", who are assigned to both ClassificationClasses using a ClassAttributeAssignment. But there might also be a ClassificationAttribute "Shutter Speed" assigned to only photocameras using a ClassAttributeAssignment. For photocameras shutter speed might be measured in milliseconds. So in the ClassAttributeAssignment for photocameras and shutter speed you assign a ClassificationUnit "milliseconds". Now consider a new ClassificationAttribute "Form Factor". There are only a few available form factors, so for each form factor you create one ClassificationAttributeValue. Using a ClassAttributeAssignment, you can assign an ClassificationAttribute "Form Factor" to your "Photocameras" ClassificationClass with the ClassificationValues "Compact Camera", "SLR" and so on. Once again, there might be different form factor values for video cameras.
In a JSF page I have to display the data from an entity.
This entity has some int fields which cannot be displayed directly but need to be translated into a descriptive string.
Between them some can have a limited number of values, others have lots of possible values (such as a wordlwide Country_ID) and deserve a table on the Db with the association (ID, description).
This latter case can easily be solved navigating via relationship from the original entity to the entity corresponding to the dictionary table (ID, description) but I don't want to introduce new entities just to solve translations form ID to description.
Besides another integer field has special needs: the hundred thousand number should be changed with a letter according to a rule such as 100015 -> A00015, 301023 -> C01023.
Initially I put the translation code inside the entity itself but I know the great limits and drawbacks of this solution.
Then I created a singletone (EntityTranslator) with all the methods to translate the different fields. For cases where the field values are a lot I put them inside a table which is loaded from the singletone and transformed in a TreeMap, otherwise the descriptions are in arrays inside the class.
In the ManagedBean I wrote a getter for EntityTranslator and inside the jsf I use quite long el statements like the following:
#{myManagedBean.entityTranslator.translateCountryID(myManagedBean.selectedEntity.countryID)}
I think the problem is quite general and I'm looking for a standard way to solve it but, as already stated, I don't want to create new 'stupid' entities only to associate an ID to a description, I think it is overkill.
Another possibility is the use of converters Object(Integer) <-> String but I'm more comfortable in having all the translation needs for an Entity inside the same class.
Your question boils down to the following simple line:
How can I display a field different from id of my entity in my view and how can I morph an integer field into something more meaningful.
The answer is that it depends on a situation.
If you solely want to input/output data, you don't need id at all apart from the possible view parameter like ?id=12345. In this case you can input/output anything you want in your view: the id is always there.
If you want to create a new entity most possibly you have a way of generating ids via JPA, or database, or elsehow besides the direct input from the user. In this situation you don't need to mess with ids as well.
If you want to use information on other entities like show user a dropdown box with e.g. a list of countries, you always have the option to separate label (let it be name) and value (let it be id), or even have a unique not null column containing the country name in your database table that will serve as a natural identifier. If you'd like to get data from the user using an input text field you always can create a converter that will do the job of transforming user input strings to actual entity objects.
Regarding the transformation of your integers, you've actually got several choices: the first one is to attach a converter for these fields that will roughly do 301023 -> C01023 and C01023 -> 301023 transformations, the second one is to write a custom EL function and the third one is to prepare the right model beforehand / do the transformations on-the-fly.