STACK AI - UNDEFINED - PROBLEM
# 🤝help
c
Anyone willing to help me? Its been a couple days making research and I still get Undefined response. I get the OUT-1 and IN-0 input and output, but when I start a conversation and set up a question, the bot gets the info done and gives an answer but It does not store in the bot, so the text box gives me "Undefined" answer. I put my code and a screenshot if someone can help me. // Set these to the names of your stack-AI in/out nodes var inNode = 'in-0' var outNode = 'out-0' // Change this to your Stack-AI URL let url = 'X URL" try { const response = await axios.post( url, { inNode:
${event.preview}
}, // Be sure to set your API key as an env variable { headers: { Authorization:
Bearer ${env.apiKey}
, 'Content-Type': 'application/json' } } ) workflow.stackAIResponse = response.data[outNode] } catch (e) { console.error(
There was an error calling Stack-AI: ${e}
) } ty so much in advance https://cdn.discordapp.com/attachments/1235611685457363015/1235611685662888108/737b1855e7d05afbcee0030e35dc989e.png?ex=6635008e&is=6633af0e&hm=bc8377bf31331c8edbbcd2e1576c710bf2a5f35b2bcb719c3f82670e21e80f59&
@bumpy-butcher-41910 could you help me? 🙂
b
what happens if you change "workflow.stackAIResponse = response.data[outNode]" to "workflow.stackAIResponse = outNode" ?
c
it changes from undefined to "out-0" it gives literally that as an answer
@bumpy-butcher-41910 o7
b
hm, I'm not sure I understand where the problem is
where did you get this code?
c
I just tried it
Im trying to figure what happens but no chance
The problem is basically that the bot does not prints the answer itself. It doesnt work
b
it looks here like your workflow has 3 keys saved
can you show them to me?
c
That was this afternoon
I have this now
The error has to be something related with the response basically
Because the out-0 output is the correct information
workflow.stackAIResponse = response.data[outNode] workflow.stackAIResponse = outNode workflow.stackAIResponse = response.data.outNode I've tried a lot of options but still it doesnt work properly
you can see here that a value is being stored in this variable
it's just storing 3 keys
you should access one of them - but I don't know what they are
c
Yeah I dont have that anymore
that was when I tried the code you gave me
b
can you try it again?
c
now there's this error where it ways too many requests (429)
first time in the day happening lol
b
likely a stackAI problem lol
but what I'm saying is - the answer should be saved in one of those keys
c
yeah yeah I know because
b
so workflow.stackAIResponse.keyName should have the value
c
let me see if I can send it to you
there is the 1 key of out-0 being stored
but workflow.stackAIResponse doesnt collect it so it isnt being printed
Says Empty -> Not Set
That is what I dont understand
@bumpy-butcher-41910 I dont mind using Botpress KB, I find it useful but the answers it gives me are so so long, so I need to make that shorter, I wanted to do this, but now It doesn't work. I tried the code for the AI Task but it just prints it and doesnt work. We can let this apart if you can help me making the KB Botpress answers short, because that is what I really need ^^
Because this is just blowing my mind
a
It seems that you are missing a property in the stackAI response. The axios response has an "outputs" property, and INSIDE that property you will get your answer. Try to change this code:
Copy code
workflow.stackAIResponse = response.data[outNode]
To this:
Copy code
workflow.stackAIResponse = response.data.outputs[outNode]
c
Now works perfectyl! Thanks man