How to generate Whatsapp List dynamically

I am building a flow in which I want to populate the WhatsApp list dynamically using API response. I went through the documentation and found a sample schema for quick replies but not for the Whatsapp List. So, How to achieve this?

1 Like

Hey @DarshanPatel11,

We launched this feature last week only! You can use the following code snippet to dynamically populate WhatsApp List:


{
       title: 'Please select your preferred slot for Appointment',
       optionText: 'Appointment Slots',
       options: [
           {
               section: 'June 5, 2021',
               options: [
                   { title: '9am-11am', text: '5.9-5', description: 'General Medicine' },
                   { title: '12pm-2pm', text: '5.12-2', description: 'Orthopedic' },
                   { title: '2pm-4pm', text: '5.2-4', description: 'Physiotherapy' },
               ]
           },
           {
               section: 'June 6, 2021',
               options: [
                   { title: '9am-11am', text: '6.9-5', description: 'General Medicine' },
                   { title: '12pm-2pm', text: '6.12-2', description: 'Orthopedic' },
                   { title: '2pm-4pm', text: '6.2-4', description: 'Physiotherapy' },
               ]
           }, {
               section: 'June 7, 2021',
               options: [
                   { title: '9am-11am', text: '7.9-5', description: 'General Medicine' },
                   { title: '12pm-2pm', text: '7.12-2', description: 'Orthopedic' },
                   { title: '2pm-4pm', text: '7.2-4', description: 'Physiotherapy' },
               ]
           }
       ],
       footer: 'Please follow Covid Guideline while consulting.'
   }

I tried the code snippet you gave, I am not getting any error in the logs, but Whatsapp List is not being sent to User via bot.

{“level”:“debug”,“log”:{“data”:“Executing Message Type [waList]”,“sender”:“918488862479”,“source”:“whatsapp”,“tag”:"",“traceId”:“918488862479_undefined”},“botId”:“x1632306469977”}

{“level”:“info”,“log”:{“data”:“Finished Executution for Async sources”,“sender”:“918488862479”,“source”:“whatsapp”,“tag”:"",“traceId”:“918488862479_undefined”},“botId”:“x1632306469977”}

1 Like

No problem @DarshanPatel11 ! Can you please share your bot access with admin preveilage with me at pratik@yellow.ai?

@Pratik from { title: '9am-11am', text: '5.9-5', description: 'General Medicine' }

When user select the item from the list text is the value to be stored in the variable right?

But that is not working, text is not accessible.

I am having the same issue. Sir, if you have got the solution. Can you please share?

@Pratik Hey Pratik, the issue at hand is to convert an api response containing date and time slots using a js function to fit into the format that will be supported by WA list node. if this code exists already in your repository, please share that across. TIA :slight_smile:

Hey @DarshanPatel11 if your API response is coming in object then you have to convert that object into array and then you can pass that in a WA list. Because WA list take Array data.

@Jayesh_Rana hey I’m stuck with building the array data in the format similar to the sample data that the node accepts. Is there any predefined js code available for the same ? Please share across. TIA.

Hello, @Prathap_P_S The datatype for passing WhatsApp list details is an object.
You can find more information in the document below.

Pass the object variable through fetch from and get the WhatsApp list response in Store response in, which should be a string. The text value will be returned in that response.

Note: The WhatsApp list feature will not accept duplicate text values.