KaleksyK

Using API step's data in function step

Hi all!

I'm currently building a workflow where I get data using API step. I pass the data in to Function step and then I would like to handle data there. The end goal would be filter data by using user input and show the result in chat.

Example:
Bot: Which city you live in?
User: Stockholm
Bot: Here are the recycling points in Stockholm: adress 1, address 2 and address 3.

I currently manage to fetch data with API step and I can pass it in function step. But then the problems starts.

Is it possible to access apiData in function step and filter it? It's hard to degub this because I haven't found console in Voiceflow and some error are hard to catch.

apiData and recyclingPoints are predefined in API step.

// This gets full JSON
const apiData = args.inputVars.apiData;

//This gets first recycle point's street name
const streetName = args.inputVars.recyclePointStreet;

// User's input for question "Your city?"
const userCity = args.inputVars.userCity;

// Here I send data in to chat as a test
payload: {
message: You said: "${userCity}" and "${streetName}",
},
Was this page helpful?