Supplying Items to a list template does not work (validation errors)
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
- Set up a list item picker template
- send a message providing a list of items to pick from in 'items' array
- 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:
Any help .... ?
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
Closing this issue due to no response in last 30 days. Thanks!