Date Widget popping up with caraousel

I am using a date widget after a carousel. Before selecting carousel value , date picker is popping up in my chatbot . I want that after selecting value from carousel , date picker should pop up .

Bot Display

Please change the carousel to prompt instead of message carousel.

How to print date object in yellow.ai . I am storing it but value printing as object object

Please check the code. consultationdate → variable where date is stored in node.
From there you can chek the object to parse and form a date accordingly of what you want to display, while logging the data that comes from the variable.

return new Promise(resolve => {
    /**
     * Format date in DD/MM/YYYY
     */
    console.log(data.variables.consultationdate, 'in consultationDate')

    let consultationDate = data.variables.consultationdate.value.timestamp

    consultationDate = new Date(consultationDate).toISOString().split('T')[0].split('-');
    // let temp = consultationDate[1];
    // consultationDate[1] = consultationDate[2]
    // consultationDate[2] = temp
    consultationDate = consultationDate.reverse().join('/')
    console.log(consultationDate, "consultationDate in consultationDate")
    resolve(consultationDate);
});

@Nistha

Make sure you’re storing the value in an object variable

Here’s the format for a data object (in single date picker)

{
    "value": {
        "timestamp": "2021-09-08T00:00:00.000Z",
        "year": 2021,
        "month": 8,
        "date": 8,
        "day": "Sunday",
        "hour": 0,
        "minute": 0
    },
    "range": {
        "exists": false
    }
}

In the text node, to print the value in (DD/MM/YYYY), you can simply enter the format

{{variables.YourObjectName.value.date}}/{{variables.YourObjectName.value.month}}/{{variables.YourObjectName.value.year}}

Here’s the Reference Doc

2 Likes