简体   繁体   中英

Watson Conversation condition for checking if system entity @sys-date is today/yesterday

I'm trying to create a dialog with different response/action depending on a @sys-date system entity provided by the user. I know I can add conditions such as @sys-date.before('2018-01-24') where the compared value is fixed, but I have not been able to create a conditions that would check if the provided system entity is during today or during yesterday. Best I've tried is @sys-date.before(now().reformatDateTime('dd-MM-yyyy')) but even that does not seem to work like expected.

You can find out date for today and yesterday as follows:

{ "context": { "date_today": "<? new Date().format('yyyy-MM-dd') ?>", "date_yesterday": "<? new Date((new Date().getTime()) - (24*60*60*1000L)).format('yyyy-MM-dd') ?>" }

These variables can be used then to compare the date in the system entity. Eg

@sys-date.before($date_yesterday)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM