How to use Dialogflow queries with special characters like '#'? - dialogflow-es

if I use a query string like:
Does John know to code in C#?
Dialogflow cannot match the C# as an entity parameter. But if I ask like:
Does John know to code in C#
Without any following characters, Dialogflow can match C# as entity parameter. What can be the reason for this? I have tried template and also example queries for training the intent but the result is the same for both.

Related

Dialogflow regex entity similar to #sys.any

I have many intents that extract a parameter that could be almost anything. An example would be a company name. Lots of variation there: "VWR", "1-800-Flowers", "#1 Mufflers". This list can include names in many languages.
I'm using the #sys.any entity now but it doesn't work well if the text includes numbers or punctuation. I get this for the parameter for example: "1 - 800 - Flowers". There are spaces around the numbers and punctuation.
I was expecting the Regex entity to solve my problem but on save it throws and error saying its too broad. \S+[\s\S]*\S+ will catch anything in any language. Here's the error: "com.google.apps.framework.request.BadRequestException: Validate entity with entityName 'RegexAny' and entityId '149486a3-7a49-4171-b23c-860f7d47b713' failed because of the following reasons: Regular expression match is too broad: \S+[\s\S]*\S+."
How can I get around this unhelpful restriction and capture the user's input just as they typed id?
I've had this problem happen to me as well. What I do is use the #sys.any parameter and do the regex check in my fulfillment code. Here you can remove any punctuations and spaces. If you decide to do it this way I'd recommend removing any output contexts and setting them programmatically if you find a match with that regex. If there's no match I will set the same context as the input contexts for that intent.
This works wonderfully.

Dialogflow Agent regex entities definition

I have created an agent in dialogflow, for which I want to define an entity based on regex values, I know we have regex capability in defining the entities, but I don't know how to use it or how to define regex while defining the entity. There are no examples or blogs available to help me with this. I want to see an example or syntax of how to define regex entities so that I can replicate the same for my case. Any help will be highly appreciated.
Try this. Go to the Entity page. Create a new Entity an call it whatever you want. In the entity screen select regex and enter this value [A-Za-z]{3}[0-9]{7,10}$. Save the Entity. This regex will validate any value that begins with three letters and 7 to 10 character. Example PAP1234567 or DWL123456789.
Now go to an, intent or create one, and on the training phrases add one that says:
My number is PAP12345678. Select the PAP12345678 to highlighted and the entities menu will appeared. Select the new regex entity and save.
Test the intent on DialogFlow. Hope this help.

How to use variable from dialogflow in activechat? Payload?

I am currently trying to use NLP (Dialogflow) to resolve all inputs into a number value. I would then like to use that number value as a variable in activechat, a visual chatbot builder. How can I do that?
EDIT: Is it done by using a payload?
When you are using direct Dialogflow integration all entity values are accessible in Activechat as $_nlp_entity_[entity_name] variables. So, if you have #city entity in Dialogflow, when any intent with that entity triggers an event in Activechat, $_nlp_entity_city will be populated with the value for that entity.
Hope that helps.

dialogflow ambiguity with same synonyms for different entity values

I have an issue developing an agent with dialogflow (api.ai). I am using a lot of entity values which are all different from one another. however there are similar synonyms for some entity values but the agent is returning only one value.
How can i get all the possible matches or ask question to resolve the ambiguity
for example i have an intent like: tell me the location of ABC express train
if my entity values are :
entity synonym
15127 ABC express
12345 ABC express
I want it to return two values or ask question to resolve such ambiguity
how can i work this out
Thanks in advance
If you enable fulfillment for this intent, you can take a look at the value the user said and ask a further question if you need to disambiguate between entities.
Let's imagine you are extracting an entity called "trains". The parameters table in your intent might look like this:
By default, if the user says ABC express, the fulfillment webhook will be called with the following parameter hash:
"parameters": {
"trains": "15127"
}
This isn't enough information to decide if the request was ambiguous, since train 15127 might also have non-ambiguous synonyms.
You can configure Dialogflow to send the original text of the entity, alongside the resolved value. This means you will receive the following information to your webhook:
"parameters": {
"trains": "15127",
"original": "ABC express"
}
You can then use some simple logic to ask a further question if the value of original appears in a list of known ambiguous synonyms.
To have Dialogflow send this data, modify your parameters table so it looks like the following:
This will cause the original synonym to be sent to Dialogflow alongside the resolved value.

How can I define a complex entity in API.AI like service request number

I need to make an entity service order but the format should be date-XXXXXX i.e. 170717-000001.
Date in simple format followed by hyphen and then a six digit number. Ho can I create a complex entity like this.
At the moment, API.AI does not support regex but you can use #sys.any to catch strings and validate them at your backend.

Resources