Search code examples
watson-conversationwatson-assistant

Detecting "Last Quarter" in Watson Assistant


In Watson Assistant, the @sys-date system entity is able to detect time-related phrases such as "yesterday", "tomorrow", "last month", "next month", "last year", "next year".

I could not get it to recognize "last quarter". For example, if the user asks: what were the sales last quarter?, I'd expect @sys-date to contain 2018-01-01 and 2018-03-31 (equivalent to the Q1 2018 time range).

I recognize quarter boundaries could start at arbitrary months, so perhaps it may need a way to define that.

Is there any way to do that?

Greatly appreciate any pointers!


Solution

  • So the feature is not there yet, but you can easily create this yourself.

    1. Create an entity called "quarter". Give values of "Q1","Q2","Q3","Q4" and related synomyns. Switch on fuzzy matching to handle spelling mistakes.

    Here is an example you can import:

    quarter,Q1,first quarter,quarter 1,quarter one,1st quarter,Q 1,1 quarter
    quarter,Q2,second quarter,quarter 2,quarter two,2nd quarter,Q 2,1 quarter
    quarter,Q3,third quarter,quarter 3,quarter three,3rd quarter,3 quarter,Q 3
    quarter,Q4,last quarter,forth quarter,4th quarter,quarter 4,quarter four,Q 4,4 quarter
    

    2. Create a node to detect @quarter.

    3. In the node click custom and select multi-response.

    4. Fill out each Quarter to capture. Then select the cutomise for each quarter.

    enter image description here

    5. Open the context editor and create a $startDate and $endDate variables. Set as follows (first quarter).

    $startDate = "<? now().reformatDateTime('Y') + '-01-01' ?>"
    $endDate = "<? now().reformatDateTime('Y') + '-03-30' ?>"
    

    Repeat for the other quarters with the correct start/end dates.

    Example

    enter image description here