Add contents of turn.KnowledgeAgent.answer to a va...
# 🤝help
a
Struggling to do this seems it cant read KnowledgeAgent.answer. after querying KB it returns a list like this via a text card with {{turn.KnowledgeAgent.answer}} - Cairns Shield St: 88 Shields Street - Cairns Mulgrave Rd: 207 Mulgrave Road - Cairns Central Lake St: 77 Lake Street I'm trying to make this a choice in the next step but im having trouble just reading turn.KnowledgeAgent in any execute code card or process the text further Error is 16:23:09errorError executing action "inline-ins-f5d843dceb.js" in flow:Main:node:get_store [TypeError, Cannot read properties of undefined (reading 'KnowledgeAgent')] Full log below Any ideas Thanks https://cdn.discordapp.com/attachments/1135463208170307604/1135463208371621948/message.txt
a
Hey @alert-apartment-89957 what si the code that you're trying to run? Could you share it?
a
Hi @acceptable-kangaroo-64719 i have tried lots but this is what currently trying const bulletpoints = workflow.turn.KnowledgeAgent.answer;
i have got a fixed code version working taking the string and separating it into choices but still cant seem to pass turn.KnowledgeAgent.answer into execute node // Assuming you have the following code to set the contents of {{turn.KnowledgeAgent.answer}} const turnKnowledgeAnswer = "- Cairns Shield St: 88 Shields Street\n- Cairns Mulgrave Rd: 207 Mulgrave Road\n- Cairns Central Lake St: 77 Lake Street\n- North Rockhampton: Shop 22 Northside Plaza, 222 Musgrave Street"; // Split the answer by '\n' to get individual choices const choicesArray = turnKnowledgeAnswer.split('\n'); // Initialize an empty array to store the final choices const choices = []; // Loop through each choice in the choicesArray and extract the label and value choicesArray.forEach((choiceText) => { const regex = /- (.?): (.)/; // Regular expression to extract label and value from the choice text const match = choiceText.match(regex); if (match) { const label = match[1].trim(); // Extract the label from the regex match const value = match[2].trim(); // Extract the value from the regex match choices.push({ label, value }); } }); // Set the workflow.choices to the formatted choices array workflow.choices = choices;
i think i solved it with AI card and telling it to assign to variable
a
you don't need the
workflow
, it's just
turn.KnowledgeAgent.answer