https://discord.gg/botpress logo
http request - autonomous node
# šŸ¤help
b
Hi everyone, I could use some help with Botpress. I’m trying to run an HTTP request from inside an Autonomous Node using two dynamic variables: user.Whatsapp and workflow.orderId. Here’s the issue: The bot is not managing to set the value into workflow.orderId dynamically before reaching the HTTP request. So, the request fails with a TypeError saying it can’t read undefined. However — if I manually predefine a value in that variable (for example by hardcoding it in the variable editor), the HTTP request works fine. So it seems like the HTTP Request block can access the variable only if it’s already defined before the node runs. In my workflow: • 1st node - I’m using AI Task to extract the value and save it to workflow.orderId. • 2nd node - Autonomous Node, which contains an HTTP Request card that uses the variable in the URL like this: https://api.example.com/status?phone={{user.Whatsapp}}&order_id={{workflow.orderId}} The bot just can’t make the request unless the variable was already set before the Autonomous Node runs. Any ideas on how to ensure the Autonomous Node waits for or pulls the most up-to-date values? Thanks so much in advance!
l
did you make the variables writable? +rw
b
yes, now the problem is if the user first message is for example "hi" and not the orderID the workflow proceeds to the next node (autonomous node) without the order ID and cant do the http request. If the user answer is a message like "Hi 12345" the AI task extracts the order ID and does the http request. I need to find a way or how to create an action on the autonomous node that write the value on the variable, since the autonomous node by it self cannot write in variables.
l
Improve your prompt or put a validation before the workflow transitions to the AN node that order id is present, else ask the user to enter the order id. You could also ask your AN node to ask the user to enter the order id
b
Is it possible just using the autonomous node with the card "simple http request" without the AI task node? Because the problem is either save the answer on the variable with the Ai task node (if the first message does not cointain the order ID) before the autonomous node or to show the results if im only using the autonomous node with a card with simple http request . Also this workflow will run with a trigger from n8n with twilio integration.
So far, I’ve tested two approaches: 1. Using an AI Task node to extract and store the Order ID, followed by an Autonomous Node with an HTTP Request card; ( this only works if the first message from the user is the OrderID) 2. Using only the Autonomous Node with the HTTP Request card, and including clear instructions about calling the API and presenting the result. This option doesnt always write on the variable, and if it writes, it doesnt always show the get results.
p
I suggest placing your existant workflow in a subworkflow to an autonomous node and having the orderId ans an input variable to that workflow. This way the autonomous node whose role is greeting the user and routing will have to pass the order Id in order to transition to the http request workflow. Hope this helps!
b
thanks
p
No problem :))
n
@bland-butcher-39173 if you still need help feel free to DM me I'm intrigued by your issue as I had a similar one for the last week and just gutted it out with the Botpress team šŸ™‚
b
Thanks I fixed it with 3 autonomous , 2 to save the variables with a transition and the last one with all the knowledge .
2 Views