https://discord.gg/botpress logo
#🤝help
connecting to NLP Cloud api
# 🤝help
h

happy-army-4408

07/15/2023, 7:53 AM
I am trying to connect Botpress to NLP Cloud API and I can't get past this error... Error executing action "inline-ins-1d934a3788.js" in flow:Main:node:call-nlp-api [ReferenceError, process is not defined] In case it helps, here is the code generated from a prompt... const url = "https://api.nlpcloud.io/v1/gpu/chatdolphin/gs-correction" const params = { authorization: process.env.NlpCloudKey, text: workflow.baseQuery } const response = await axios.get(url, { params }) if (response.status === 200) { workflow.grammarInfo = response.data.results } It's not that I have zero coding experience, but my skills are not at all fresh. Has anyone had success with this API or perhaps overcome this error?
I believe I'm making progress, but now I'm getting 401 errors from NLP Cloud. I've tested the key on their playground so I'm sure it's correct, but I'm not 100% sure I'm feeding them the right syntax. I've reached out to their support too, but really hoping someone has an idea what's going on... const url = "https://api.nlpcloud.io/v1/gpu/chatdolphin/gs-correction" const params = { authorization: env.nlpCloudKey, text: workflow.baseQuery } const response = await axios.get(url, { params }) if (response.status === 200) { workflow.grammarInfo = response.data.results }
I'm an idiot! 😫 Not because I couldn't figure out how to do this... but because it took me so long to quit trying and just let Chat GPT fix it... which, of course, it did. At first I was following the Spoonacular example in the tutorial too literally and attempting to use GET when the API requires POST blah, blah, blah... the main take away is to just quit trying to hard and let GPT do it. 😋 Working Code: const url = "https://api.nlpcloud.io/v1/gpu/chatdolphin/gs-correction"; const data = { text: workflow.baseQuery }; const headers = { Authorization:
Bearer ${env.nlpCloudKey}
, "Content-Type": "application/json" }; try { const response = await axios.post(url, data, { headers }); if (response.status === 200) { workflow.grammarCorrected = response.data.correction; } else { console.log(response); } } catch (error) { console.log(error); }