Dynamic Single Option Issue
# 🤝help
b
hello everybody! I've been breaking my head on a single choice capture with an array variable instead of static choices for days now and I can't seem to get it work.... Let me explain: I have the necessity to show dynamic choices so I created an array like this: ['label':title,'value':id] and placed it as a choice (deselecting the static option by clicking X) On the emulator it works fine On the web page once I click the choice nothing happens. So I can see the choices but it seems like they do not get captured So I've even created the array in the workflow itself, now in the webpage once I select a choice it asked me again to select it... sometimes it asks me to select it without shwing the choices (second time) Any hints here? Is there a way to debug it? Why it's not working on the web page but it works on the emulator?
This is my payload: workflow.allAvailableRooms { label: 'MATRIMONIALE', value: 'rec04HiSUQFDVivUM' }, { label: 'LETTI SEPARATI', value: 'rec1cF9HpKMBLK50n' }, { label: 'QUADRUPLA', value: 'recDez2XjBK1WQnHs' }, { label: 'LETTI SEPARATI TRIPLA', value: 'recas5Ctxy13Oxyl9' }, { label: 'TRIPLA', value: 'reccrOKhZ8khK7Kqo' }, { label: 'SINGOLA', value: 'recesVr1rucW6TMbV' }
and in the logs in web chat I found this error: error in handler yt [Error]: Quota exceeded for state_item_payload_bytes, attempted to use 179901 but maximum is 131072 (Error ID: err_1692872392659xDBEED5A4) at Mr (/var/task/customer_code.js:8:27984) at Ot (/var/task/customer_code.js:8:27764) at w (/var/task/customer_code.js:8:67151) at /var/task/customer_code.js:8:63390 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 7) at async saveAllStates (/var/task/customer_code.js:292:4499) at async saveState (/var/task/customer_code.js:292:7022) at async Object.onEvent (/var/task/customer_code.js:315:8312) at async Object.onMessage (/var/task/customer_code.js:315:7767) { isApiError: true, code: 400, description: 'The request payload is invalid.', type: 'InvalidPayload', error: undefined }
a
Hey @busy-evening-56847, are those
{label: 'xyz', value:'123'}
objects in an array?
b
yes
indeed I can see the options and in the emulator everything works fine, but in the web chat logs I see an error with the payload state...
a
okay. I have it working in my emulator copy/pasted from your post. Let me try in webchat....
yeah, tried it in webchat with no issue. I used this code to define the buttons:
Copy code
js
workflow.buttons = [
  { label: 'MATRIMONIALE', value: 'rec04HiSUQFDVivUM' },
  { label: 'LETTI SEPARATI', value: 'rec1cF9HpKMBLK50n' },
  { label: 'QUADRUPLA', value: 'recDez2XjBK1WQnHs' },
  { label: 'LETTI SEPARATI TRIPLA', value: 'recas5Ctxy13Oxyl9' },
  { label: 'TRIPLA', value: 'reccrOKhZ8khK7Kqo' },
  { label: 'SINGOLA', value: 'recesVr1rucW6TMbV' }
]
then used the var in a single choice card like

https://cdn.discordapp.com/attachments/1144215154695880795/1144220059108130866/image.png

https://cdn.discordapp.com/attachments/1144215154695880795/1144220087914598400/image.png

no errors in the logs
b
why you are not storing anything in the variable?
I am storing the result into a string variable
a
because I'm lazy 😛 I'll save it and see if that makes an error
b
haha look I am doing the exact same thing as you. the difference is that I have created the workflow variable form the UI as well and I am building the variable dynamically fetching the results from an API. Let me show you the code: workflow.allAvailableRooms = [] for (let i = 0; i < workflow.availableRooms.length; i++) { let roomObj = workflow.availableRooms[i] let room_found = false for (let j = 0; j < workflow.allAvailableRooms.length; j++) { if (workflow.allAvailableRooms[j].label == roomObj['Name (from Category)'][0]) { room_found = true break } } if (!room_found) { workflow.allAvailableRooms.push({ label: roomObj['Name (from Category)'][0], value: roomObj['ID'] }) } }
and for some reason now that I've tried hardcoding the array like you did, I get the same error. Maybe my bot is too complex?
a
I'm not getting any errors when I save the result to a string var. Are you doing anything funky after the choice card?
b
alright man, I am sorry I disturbed. I found the issue and it was indeed related to the state payload size. Before this I was calling 3 separated cards for code executing to keep things cleaner. But I had to store my variables into temp workflows. Apparently this exceeded the quota and it was causing this issue on the web chat. On the emulator this wasn't visibale though. I had to go check the logs in the web chat directly. To fix it i merged the 3 cards into 1 so I could use local variables instead of temp workflows. Now it works 🙂 Thanks for your assistance Gordy!
3 Views