twilio-node icon indicating copy to clipboard operation
twilio-node copied to clipboard

Supplying Items to a list template does not work (validation errors)

Open rozzrr opened this issue 11 months ago • 2 comments

Issue Summary

using the nodejs library i expect that when i do the following :

const list_picker : TwilioListPicker = { body: "bodyText", button: "buttonText", items: [{ id : "1", item : "item_name", description : "item_descr" }] }

        await client.messages.create({
            contentSid : message.templateId,
            from : message.from,
            to : message.to,
            contentVariables : JSON.stringify(list_picker),
        });

this will provide a series of options to the whatsapp user, however this does not an we are met with validation errors

what does work is this:

const list_picker : TwilioListPicker = { body: "bodyText", button: "buttonText", id : "1", item : "item_name", description : "item_descr" }

        await client.messages.create({
            contentSid : message.templateId,
            from : message.from,
            to : message.to,
            contentVariables : JSON.stringify(list_picker),
        });

which then is valid...

so this means we cannot send an array of items, but only a single one.

Steps to Reproduce

  1. Set up a list item picker template
  2. send a message providing a list of items to pick from in 'items' array
  3. notice the errors from the sdk when this happens (even though all params match up to the varibles in the template)

Code Snippet

 //works
 const list_picker : TwilioListPicker = {
                body: "bodyText",
                button: "buttonText",
                id : "1",
                item : "item_name",
                description : "item_descr"
            }

            await client.messages.create({
                contentSid : message.templateId,
                from : message.from,
                to : message.to,
                contentVariables : JSON.stringify(list_picker),
            });



//doesnt work

 const list_picker : TwilioListPicker = {
                body: "bodyText",
                button: "buttonText",
                items: [{
                    id : "1",
                    item : "item_name",
                    description : "item_descr"
                }]
            }

            await client.messages.create({
                contentSid : message.templateId,
                from : message.from,
                to : message.to,
                contentVariables : JSON.stringify(list_picker),
            });

Exception/Log

(https://www.twilio.com/docs/api/errors/20422)

Technical details:

  • twilio-node version:
  • node version:

rozzrr avatar Jan 15 '25 20:01 rozzrr

Any help .... ?

rozzrr avatar Feb 17 '25 21:02 rozzrr

Hello! You are confusing TwilioListPicker which should be used with https://content.twilio.com APIs, the API you are using https://github.com/twilio/twilio-oai/blob/245ab7ce2f87a07433c743197e0330f181289064/spec/json/twilio_api_v2010.json#L27070 doesn't support these objects. Please check https://www.twilio.com/docs/content/using-variables-with-content-api for more info on how to use this API

manisha1997 avatar May 05 '25 16:05 manisha1997

Closing this issue due to no response in last 30 days. Thanks!

tiwarishubham635 avatar Jun 23 '25 06:06 tiwarishubham635