acceptable-kangaroo-64719
07/14/2023, 12:39 PMin-0
and out-0
. If you change these names, remember what you changed them to, we'll need them later.
5. Click on "Deploy"
https://cdn.discordapp.com/attachments/1129391709973913750/1129391710137483374/image.png▾
https://cdn.discordapp.com/attachments/1129391709973913750/1129391710657585223/image.png▾
acceptable-kangaroo-64719
07/14/2023, 12:43 PMcall_stack_ai
. Add a "Raw Input" capture card with the question, "What would you like a haiku about?"
3. Add an execute code card after the capture card. Copy and paste the below code into your Execute code card:
js
// 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=64b12e0b300d2b8f5f828099&org=8dc59f7b-40a4-41c4-ad11-d5e0f4691e27'
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}`)
}
4. Change the following things in the code:
- URL: Change this to your Stack-AI URL. You can get this by going to "Deployments" from your project dashboard.
- inNode / outNode: If you changed the names of your input and output nodes, update them here. Otherwise, leave them as the default values
5. Finally, you'll need to add your Stack-AI API key as an environmental variable. To do this:
- Go to "Chatbot Settings" and click on the "variables" tab
- Scroll down to 'Configuration Variables' and click on the '+'sign
- In the left box write apiKey
. In the right box, paste your API key. You can get this by clicking on "Show Token" in the Stack AI deployment page.
https://cdn.discordapp.com/attachments/1129391709973913750/1129392821179269180/image.png▾
acceptable-kangaroo-64719
07/14/2023, 12:45 PM@stackAIResponse
. If you see an error or a squiggly red line, you can ignore it for now 😉
Your node in Botpress should look like this:
https://cdn.discordapp.com/attachments/1129391709973913750/1129393183806205972/image.png▾
acceptable-kangaroo-64719
07/14/2023, 12:51 PMhttps://cdn.discordapp.com/attachments/1129391709973913750/1129394682238095370/image.png▾
acceptable-kangaroo-64719
07/14/2023, 12:52 PMacceptable-kangaroo-64719
07/14/2023, 12:55 PMhttps://www.stack-inference.com/run_deployed_flow?flow_id=12345678
To get your API key, click the "Show token" button. The API key will appear in the code after the word Bearer
and looks like abcd12-efg1-hi3jk-lmnop1
https://cdn.discordapp.com/attachments/1129391709973913750/1129395772220248104/image.png▾
acceptable-kangaroo-64719
07/14/2023, 12:58 PMin-0
and out-0
. If they are not, update the code.
4. Verify that your Stack-AI bot has been deployed by clicking the blue "Deploy" button in the top right
5. Verify that your Stack-AI bot actually works as expected
6. Look in the logs in the Botpress bottom panel and see what the error is and read its description. You can search this Discord channel (and Google) for this error and see how other people have solved it.acceptable-kangaroo-64719
07/14/2023, 1:02 PMjs
{ [inNode]: `${workflow.userName} ${event.preview}` },
Here are some common things you might want to add:
* event.preview
is the thing the user said, exactly as they said it (without any spellcheck or other processing)
* event.tags
has information from WhatApp or other channels (if your Botpress bot is deployed to them) like phone number or user ID.
* turn.KnowledgeAgent.answer
has the Botpress knowledge agent's answer (if it is enabled).
* If you've made any workflow variables, workflow.variableName
can add them.acceptable-kangaroo-64719
07/14/2023, 1:13 PMhttps://cdn.discordapp.com/attachments/1129391709973913750/1129400376395825244/image.png▾
wide-pharmacist-63065
07/20/2023, 5:13 PMrich-battery-69172
07/20/2023, 10:02 PMawait
statements everywherelittle-doctor-93292
07/21/2023, 10:30 AMfreezing-carpenter-9818
07/21/2023, 10:48 AMacceptable-kangaroo-64719
07/21/2023, 11:05 AMhttps://cdn.discordapp.com/attachments/1129391709973913750/1131904708659925043/image.png▾
wide-pharmacist-63065
07/21/2023, 4:59 PMblue-pilot-76879
07/23/2023, 8:31 AMlittle-doctor-93292
07/23/2023, 5:27 PMblue-pilot-76879
07/23/2023, 6:19 PMboundless-pencil-51555
07/23/2023, 8:53 PMblue-pilot-76879
07/24/2023, 6:28 AMhttps://cdn.discordapp.com/attachments/1129391709973913750/1132922308680495104/image.png▾
blue-pilot-76879
07/24/2023, 6:29 AM${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}
)
}
"
I have also tried @boundless-pencil-51555 code from his dope template.little-doctor-93292
07/24/2023, 6:32 AMblue-pilot-76879
07/24/2023, 6:33 AMboundless-pencil-51555
07/24/2023, 8:12 AMlittle-doctor-93292
07/24/2023, 8:17 AMblue-pilot-76879
07/24/2023, 8:19 AMblue-pilot-76879
07/24/2023, 8:19 AMlittle-doctor-93292
07/24/2023, 8:20 AM