Axios Timeout
# 🤝help
a
I have an "Execute code" card with the following contents:
Copy code
const url = 'https://some.url/function'
const data = {
  input: workflow.input
}
workflow.isWaitingForReply = true
let response = await axios.post(url, data, { timeout: 1000 * 60 * 15 })
response = response.data.res
workflow.response = response
workflow.isWaitingForReply = false
The function takes around 5 minutes to return a response. The error that I get is:
Copy code
Error executing action "inline-ins-xxx.js" in flow:Main:node:Standard5 [AxiosError, Network Error]
I'm sure that the function doesn't timeout itself. If I use
curl
to test the HTTP call, I do get a reply after 5 minutes. I tried setting the timeout for axios, but it didn't help. Is there any other way? Thank you
a
@colossal-egg-20510 do you know if there's a timeout on the BP server side for axios requests?
a
@acceptable-kangaroo-64719 or better, Suppose I invoke my function, but don't wait for the HTTP call to finish. Instead, I push the response from within the function by using the SDK. Is there a way I can send the conversationId to my HTTP function, so that I reply back to it?
c
We have lower timeouts on our apis. A bot will typically timeout after 1 minute.
a
@colossal-egg-20510 / @acceptable-kangaroo-64719 Is there a way i can send a message from my serverless function to a conversationId, instead of my bot waiting for axios to finish? In other words, forget about the timeout and let the function continue the conversation after it's done processing
a
Async nodes/transitions are coming, but they're not in the product yet, and they might help. Could you tell me a bit more about your use case?
a
@acceptable-kangaroo-64719 I have an external serverless function which takes an input and returns a response, that can take up to 15 minutes to process. Obviously awaiting axios for 15 minutes is not ideal. Instead, how can I push the response from within my external function to a botpress conversation? Flow: Step 1: Use axios inside a code block to call my function which enqueues my job Step 2: job finishes, then using the SDK / API push the message back to the user's conversation. For step 2 I could solve the issue in 2 ways: - using the SDK, but that means having an actual backend service which listens for events (not applicable to me, because I'm using a serverless function) - using the API,
PUT /v1/chat/conversations/{id}
, but how do I get the conversationId in the first place in the code block of step 1?
a
Are you a part of the Triggers beta? https://discord.com/channels/1108396290624213082/1121833577659768893 This seems like a good use case for a custom trigger.
2 Views