Either #sys.date-period or #sys.date - dialogflow-es

I want to be able to handle an intent where the user provides either a date period or a date in their phrase.
E.g., "What's my scheduled today" or "What's my schedule this week".
Using #sys.date-period serves an empty parameter to my webhook when "today" is used, and using #sys.date serves an empty parameter when "this week" is used.
Is there a way to accomplish this other than using #sys.any and deciphering the type of parameter myself in my fulfillment?

Use #sys.date-time entity to get the date, I'm using it in my bot and it's working fine with any of the cases that you've mentioned.
It easily identifies today, tomorrow or general date format (i.e. 21st Jan).
For more information see this documentation

Related

How to provide dynamic answer for the selected entity as parameter in dialogflow fulfillment

I have an entity (items) and its values are ('name', 'colour', 'awards')
I have three intents
Intent1 = Welcome Intent (user will get the options in the form of chips)
Intent2 = Select Option (bot will ask question to enter detail for selected option)
Intent3 = Update Option (bot will save the record and ask next option to update.)
Example -
bot: welcome! what you want to update? name, colour, awards.
user: name
bot: Enter your name.
user: John
bot: record updated, what to update next? name, colour, awards.
now the issue is awards have multiple fields to update, to update awards a user has to provide three things (award name, award date, award description)
What I want is when a user selects awards options from the chips then it should be taken to new intent where I will get all the data through slot filling.
The first thing to remember is that an Intent represents what the user has said and not what you are doing with what they have said. So it doesn't make sense to say that you are "going to an Intent".
Second, while slot filling seems like a good idea, it usually leads to further problems, since it doesn't handle conditional information well, or handle users if they skip around in what they want to update.
All of these are better solved by setting up a state machine where they are in the conversation, what information you need, and what they have provided so far. Based on these settings, you can prompt them yourself for what you expect next. (You may also find using one or several Dialogflow contexts useful for shaping how to accept results as well.)
So, for example, when the user has indicated they are updating the awards, it might work like this:
User: Awards
[Your fulfillment sets the 'awards' context with a parameter that we are prompting for the name.]
Bot: Ok, I'm going to need the award name, description, and when it was awarded. What is the name?
User: Merit
[This matches the Fallback Intent with an Input Context for 'awards', since it is free-form input. Your fulfillment stores this and sets the 'awards' context with a parameter that we are now prompting for the date.]
Bot: Got it, the award is named Merit. When was it awarded?
User: Today
[This matches an Intent with a training phrase of "<#sys.date>" and the Input Context of 'awards'. There are also training phrases for things like "It was awarded <#sys.date>" and so forth. Your fulfillment sets the date and sets the 'awards' context with a parameter that we're now prompting for description.]
Bot: Got it. Awarded on March 1st. What is the description?
User: They were awesome.
[This matches the Fallback Intent with the Input Context of 'awards' again, because it is still free-form input. Our fulfillment, however, knows that this is about the description this time, so it stores it and removes the 'awards' context since we've captured everything.]
Bot: I've recorded that as a description of "they were awesome" - sure thing. That was everything we needed for now. Do you want to update the name, colour, or awards next?
That all seems pretty straightforward. But consider if the conversation had gone this way:
User: Awards
[Your fulfillment sets the 'awards' context with a parameter that we are prompting for the name.]
Bot: Ok, I'm going to need the award name, description, and when it was awarded. What is the name?
User: [Having done this many times] They were given the award for Honor yesterday
[This might match an Intent with an Input Context of 'awards' and the training phrase of "Given the award for <#sys.any> <#sys.date>" and possibly "<#sys.date> they got an award for <#sys.any>". Your fulfillment sets the name and date from this, sees what information it still needs, and prompts with...]
Bot: Got it. Award named Honor. Awarded March 1. What is the description?
User: Actually, it is named Honorable Service
[This matches an Intent with a training phrase of "named <#sys.any>" and an Input Context for 'awards'. Your fulfillment changes the name stored, checks what we still need, and again prompts...]
Bot: Ok, I've changed the award name to Honorable Service. What is the description?
The first scenario could be handled by slot filling and simple prompting, but the second can't. Being able to handle more natural responses from people and more flexible prompting will be better for your users.

DialogFlow Fulfilment - How to get both original and default value for a parameter

I am trying to get a time value from an intent as both $time and $time.original. I need the $time value to do some processing on it and I need the $time.original to show the output back to user.
For example, if user says, 'are you open tomorrow?', I want to respond 'Yes, we are open tomorrow?' but on the back end, I need the value of date 'tomorrow' to do the processing.
Any help would be appreciated.
First, you would need #sys.date entity if you want to catch value of entities like tomorrow instead of #sys.time
Now coming to the question, directly extracting the parameter value will only give us parsed date value, not the original value.
But if we set an output context, then from that context we can extract both parsed value and the original value as intended.
Here is a request that we get on webhook we can get date and date.original by parsing the output-context that we set in the intent:
{"responseId":"###","queryResult":{"queryText":"are you open
tomorrow","parameters":{"date":"2018-12-28T12:00:00+05:30"},"allRequiredParamsPresent":true,"fulfillmentText":"","fulfillmentMessages":[{"text":{"text":[""]}}],"outputContexts":[{"name":"projects/###/agent/sessions/###/contexts/time","lifespanCount":5,"parameters":{"date":"2018-12-28T12:00:00+05:30","date.original":"tomorrow"}}],"intent":{"name":"projects/###/agent/intents/###","displayName":"time-intent"},"intentDetectionConfidence":1,"languageCode":"en"}}
I have not also tried with it yet but I Guess you would be able to parse it with it system entity Dialogflow system Entities
as they're shown #sys.date and example matches with what you need. I guess it will be processing it into date

Can you force Dialogflow to extract the date-time entity instead of separate date and time entities?

I'm building a Google Home skill using Dialogflow. I want the user to be able to say a date time such as "today at 3pm", "Wednesday at 11am", or "August 10 at 5pm."
Dialogflow has several prebuilt entities including: date, time, and date-time. For some reason the system seems to always parse date and time separately instead of just as date-time. I've tried putting in several examples and manually setting the entity type to date-time but whenever I add another one it always parses them separately.
Any ideas how I could force it to extract date-time as one entity?
You can use #sys.date-time or can have a composite custom entity and use it for the intents. There could be any combination of the entity that you can put there. Once you extract it, you can use regex to extract date and time in your webhook.
Entity
Intent

New to DialogFlow, proper values won't appear when referencing them

I'm working my way through the tutorial and I am pretty sure I'm following it closely but it doesn't seem to be working.
I think I've successfully connected the value with the entity, then referenced said value in the response. But it seems like the entity is not responding.
You don't show the text response, but it seems unlikely this will do what you think it does.
As you've written it, the Intent will match if a user says something like "What is the February 10th"? Which doesn't make much sense.
Specifying a parameter against the sample phrase means that you expect the user to say something that matches that parameter in that place. In this case, you're saying the parameter is of type #sys.date, so you're expecting them to say a date of some sort (there are a variety of possible things that will match).
If you want the user to say "What is the date?" as a phrase, then the "date" part shouldn't be associated with a parameter. You'll then need to fill in some value for the reply - likely through a webhook.

Constructing Date-Periods Using "Since" in Api.ai

I am building a google-assistant application with api.ai that delivers data that has been aggregated over a date-period via a webhook.
It is common for people to ask for date periods using the word "since", for instance:
"What is the data since last monday" (tuesday - now)
or the even trickier:
"What is the data since last year". (ambiguous reference to date-period)
Can api.ai parse these date-periods, or is it necessary to identify if the intent request is of a special "relative" type and then construct the date-period manually?
You will probably want to use something like the #sys.date-period pre-defined entity.
For example, if you create an Intent with a "User says" with parameters such as:
and a response:
and then enter in some queries like:
These might not be exactly what you need, so you may need to craft more of you own. If so, check out the #sys.date pre-defined entity, which may do some of the work for you, and the complete list at https://docs.api.ai/docs/concept-entities#section-date-and-time

Resources