Dialog Engine Bot and Date Formatting

Hello,

We have a date/time field passed from the front end website with the following format: 2021-01-30T14:22:00.000Z

Would that be possible with the dialog engine bot to configure it in a way that would be like:
IF Date/Time > 3 days out ----> configure the bot to send an automatic response.

Hello,

Is this date something you collect while the customer is exchanging with the bot? Or something that the front-end sends as part of the create chat request (chat attributes/parameters)?

Regards,

Hi Jerome,
The date is an attribute passed from the front end website.

Hello,

I haven't practiced Dialog Engine much. But I don't think you can do this directly in the Dialog Engine bot itself.

I think it should be possible to achieve this with the new Architect Dialog Engine Bot flows.
As you can leverage "Update Data" action, "Decision/Logical" action and some Architect built-in functions (to manipulate Date/Time).

Having said that, if you are using the "regular" Dialog Engine bots (the one prior to the introduction of the Architect Dialog Engine Bot flows), you could possibly implement the logic upfront, in your Architect Chat flow.
I mean before invoking the Dialog Engine bot.

See below for a description of the functions you could use to compare the date/time.
As a note, you can leverage the same approach and functions if you are using an Architect Dialog Engine Bot flow.

First, you will need to convert the date/time you receive from your front-end into a DateTime variable (as what you receive from the front-end is a string).
You can leverage the ToDateTime function (in an Architect expression).
Ex:
I extract the date/time (string from the front-end) from the conversation context (let's say I save it in State.MyFrontEndDateTime).
I convert it to a date/time variable and save it in State.MyConvertedFrontEndDateTime using ToDateTime(State.MyFrontEndDateTime)

Then, you need the current date/time (used for the comparison) - you can get it with an Architect function -> GetCurrentDateTimeUtc()

You can now make the comparison between the 2 dates.
I have used an Architect function to substract the 2 dates: DateTimeDiff(GetCurrentDateTimeUtc(), State.MyConvertedFrontEndDateTime)
The result of this is a Duration (type of variable).
If you want to check if the difference is more than 3 days, you can do something like this in a "Decision" action:
DateTimeDiff(GetCurrentDateTimeUtc(), State.MyConvertedFrontEndDateTime) > MakeDuration(3,0,0,0)

And you can leverage the "Send Response" action to send an automatic response.

As I said above, if you are using an Architect Dialog Engine Bot flow, and if you want to have this verification inside the bot itself, you should be able to implement a similar logic as the Architect Dialog Engine Bot flow has access to the necessary blocks (Update Data, Decision) and Architect functions (ToDateTime, GetCurrentDateTimeUtc, ...).

Hope this helps.

Regards,

Thank you for this Jerome.
That's very helpful. In the architect flow would work for our purposes.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.