How integrate with Stack AI
# 🤝help
b
I have use that in my execute code: "// 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 = 'https://www.stack-inference.com/run_deployed_flow?flow_id=64d70c373d99b7722a662257&org=4f3bea72-86a8-449b-b4b9-e0de71a2b769' 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}) }" apprently the content of event.preview was capture. So the problem come of the transmisson of the variable inNode to the Stack Ai project but I have do all the prompts in the realm help>how_to_integrate_with_stack_ai. please help me. Image Image

https://cdn.discordapp.com/attachments/1142518248760426507/1142518249511194698/image1.png

https://cdn.discordapp.com/attachments/1142518248760426507/1142518250270376057/image.png

b
I've done this by doing:
Copy code
const endpoint = "YOUR_STACK_AI_ENDPOINT_URL"

const headers = {
  Authorization: `Bearer ${stackAiapiKey}`
}

//save the user's question or send event.preview
const data = {
  "in-0": workflow.question,
}

  try {
    const response = await axios.post(endpoint, data, { headers })
    workflow.apiResponse = response.data["out-0"]
  } catch (error) {
    throw new Error(`stack-error: ${error}`)
  }
b
Thank! I have test your code that not works but i have modifie that line : Authorization:
Bearer ${stackAiapiKey}
to: Authorization:
Bearer ${stackAiapiKey}
, 'Content-Type': 'application/json' and that works! else I have test once again my code and it finally work modifing that line: { [inNode]: ${event.preview} }, by that line: { "int-0": ${event.preview} },
28 Views