disable past date in virtual agent chat bot

mehak1890
Tera Expert

Hello Dear All - Does anyone give advice or directions on how to write "disable past date" in script section in virtual agent chat bot? Has anyone used date validations scenrios in chat bot? I'm working on catalog item as we cant use UI Policy or catalog client script in virtual agent so is it possbile if we can customized or how to write scripting for disable past date in virtual agent chat bot?

 

Pls guide/ help me.

 

Thanks,
Mehak

2 REPLIES 2

Shaqeel
Mega Sage

Hi @mehak1890 

 

Follow these steps:

 

1.CREATE A VA TOPIC.

 

2.ADD DATE PICKER TO TOPIC.

Add a Node: Click on the + button to the conversation flow.
Select: Ask a Question from the node options.
Question Type: Select Date as the question type.
Question Text: Provide the text, for example, "Please select a date".

 

3.SCRIPT. (to disable past dates)

in "Ask a question" node config, click add script.

(function() {
    var today = new Date();
    today.setHours(0, 0, 0, 0); // Reset time part to 00:00:00 to ensure only the date part is considered

    // Set the minimum date in ISO format (YYYY-MM-DD)
    var minDate = today.toISOString().split('T')[0];

    // Return the date restrictions
    return {
        minDate: minDate
    };
})();

 

4.INTEGRATE SCRIPT WITH DATE PICKER.

After integration script into 'Ask a Question' node where the date picker is defined.
Ensure the script returns the minDate property that Virtual Agent will use to restrict past dates.

 

DONE.

Do the testing and kindly let us know the result.

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Shaqeel

****************************************************************************************************************

 

 

 


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

mehak1890
Tera Expert

Hi Shaqeel,

 

Here we have used the Topic Block activity to call the existing catalog item and that catalog item has a date field. There we need to disable the past date. Basically this is a catalog item field which we are using for the date input in VA. 

 

Can we somehow disable past date for such a catalog item based variable?

 

Thanks,

Mehak