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;