Hi, I am calling a service, which returns an array. This array contains questions which have to be answered by the applicant and the answers have to be saved by the bot. Is there any way to loop the array items, so that the bot asks each question and saves each response?
Afterwards, the bot will use all the responses to call another service
Create an if condition in the bot action’s connectors: If context.areAnyQuestionsLeft equals true, go to the Answer entity node. Otherwise, go to the UploadAnswers bot action.
Answer: This is an entity node that accepts any string.
Type: String
User prompt: {{context.myService.response.body[context.currentQuestion]}}
This assumes the questions from your service are an array of strings. If they’re an array of objects instead, include the property that contains the question text: e.g., {{context.myService.response.body[context.currentQuestion].questionText}}.
StoreAnswer: This runs after end of each question in your loop. It stores the answers in a temporary context variable. You could upload the answer to a web service at this point instead, depending on whether you need atomicity (i.e., only upload answers if user answers all questions).