Execute Code Node
# 🤝help
t
I have a workflow.variable that returns with the following value from an API call: "\"Sure! Here are two that you might find helpful:\\n\\n1. Product: Microdose Capsules\\n - Price: $30\\n - Description: These capsules contain a precise dose of psilocybin, making it easy to microdose. Each capsule contains 100mg of psilocybin.\\n - Benefits: Microdosing with these capsules can help improve mood, increase creativity, and enhance focus and productivity.\\n - Image: Microdose Capsules\\n\\n2. Product: Liquid Microdose Tincture\\n - Price: $40\\n - Description: This tincture is made from high-quality psilocybin mushrooms and is designed for easy and accurate microdosing. Each dropper contains 1ml of liquid, which is equivalent to 10mg of psilocybin.\\n - Benefits: Microdosing with this tincture can provide mental clarity, reduce anxiety and depression, and promote overall well-being.\\n - Image: Liquid Microdose Tincture\\n\\n"" My question is How to extract every string value for Product, Price, Description, Benefits, Image and store them in separate user variables with the same names? I tried prompting code executer but none worked, I also tried Zapier to format the incoming data, but zap can save one variable at a time, which is not scalable. I appreciate your advice
e
Are you noticing a delay in the code execution?
t
You mean for the response from the API ?
e
yes
r
Usually API are returning JSON or in some cases XML so it's easy to parse using code. Are you sure you cannot add a parameter to your endpoint so it can return an object instead of plain text. This will make it so you will be able to reference the data. Without this it will be super hard.
t
honestly, I'm not sure if that's possible or not, I am returning data from FlowiseAi, Are you familiar with it?
yes, it returns with 4-5 sec delay
r
Sorry I'm not but if you have a link to their API documentation I would be cutious to have a look
t
That's alright, unfortunately there's no public API documentation for Flowise. They have a general documentation which does not cover this specific topic. This is the link, in case you'd like to check it out: https://docs.flowiseai.com/ Thanks again
sorry bugging you, I've been strugeling with this for the past 6 hours! I appreciate if you can assist me, No one in the physical world around me, does not have a blue clue what I'm talking about. Here is my only hope to get help. This is the API call that I am getting the txt response initially, with respect to what I need to achieve, can it be modified in that way? I hope this makes sense. This is the code: const url = "https://amirflowise.onrender.com/api/v1/prediction/6fe3ac08-8ba4-487b-a894-fc12ccbe9b25"; const headers = { "Content-Type": "application/json" }; const data = { "question": workflow.userQ } const response = await axios.post(url, data,{ headers }) if (response.status === 200) { workflow.aiResponse = _.get(response, "data") }
r
I will get back to you later this afternoon I have a few meeting to get to
s
what i do, but with only 3 vars, is feed that into an AI task and then in the AI task system box (the big top box) I put a very decript account of the goal, what the inputs will look like and what variables the ai is to designate. works pretty well actually. just make sure that it doesnt apply some bs value if it cant parse correctly
oh yea, and put the vars you want to find values for in that variables box under the input (i think its the 3rd one)
r
Looks like flowise don't have an official API we can connect to
This will make it very difficult for you to get info from flowise in Botpress.
t
do you know any workaround to get faster response from the API? mine are super slow
e
I notice it could be the code too if you are make heavy code that could