Answered How to list multiple results from a httprequest node?

I make a http request and store the result of some projects in input.httprequest. I use a Say node to present the first value in the respons by using {{input.httprequest.result.projects[0].name}}
If I would like to present a list with all the project names, how is that done in the best way? Later I would like to drill down and be able to present more info on each project.

Under nodes settings there is a headline Options with Linear and Loop options but I can't find any documentation on those.

BR

Magnus

Didn't find what you were looking for?

New post
Was this post helpful?
0 out of 0 found this helpful

Comments

1 comment

  • Official comment

    Hi Magnus,

    Thank you very much for your request. This sounds like dynamically create text messages to me. In order to do so, you can use the Code Node. Inside this node, you can loop through the results using Cognigy Script and send the output using Channel Output: https://docs.cognigy.com/docs/channel-output#ai.

    Example (Gallery):

    In the Code Node, you could do the following:

    // The path to your API result item list
    const projects = input.httprequst.result.projects;

    let galleryElements = [];

    // Loop through the result list and create gallery items
    for (let project of projects) {
    galleryElements.push({
    title: project.name,
    subtitle: project.subtitle,
    image_url: project.imageUrl,
    buttons: [
    {
    type: 'postback',
    title: 'Select',
    payload: project.name
    }
    ]
    });
    }

    // Use the SAY Node API to output the message
    api.say('', {
    _cognigy: {
    _fallbackText: "This will be displayed on voice apps.",
    _default: {
    message: {
    attachment: {
    type: 'template',
    payload: {
    template_type: 'generic',
    elements: galleryElements
    }
    }
    }
    }
    }
     
     
    Please let me know if this works for you.
     
    Best
    Alex

Please sign in to leave a comment.