Cloudflare 504 Error
# support
y
I'm receiving consistent 504 Errors when creating outbound calling campaigns where the number of contacts is large. It's no problem when creating test campaigns with 1-2 recipients but as soon as the list of recipients grow to 50+ I receive this error. Two campaigns that I know were affected by this: e70122ea-fc8b-4357-beae-6a59a4fc6311 99331f3f-2c87-4012-b140-e04687c5b300 This caused the Node Vapi SDK to waste lots of my credits and irritated customers because of it's builtin retry function where it created duplicate campaigns due to this 504 error. (I've now set maxRetries to 0 because of this). Here are some campaigns that I had duplication issues with. Campaign 1: 2c0d5168-aa86-4dd4-9e59-dad001fe2cd7 82a43e29-927f-4c01-afb7-6ca0940c645b 33dc1865-027d-4594-a2a3-e9ef15a08a32 Campaign 2: 5b7cff34-fc64-4534-b6fd-0e1c64b51be7 73b0e4e4-6eb5-4d16-b2f0-257b416b3e56 c6cc4602-ccf4-4c0f-a6c0-062e5cc09950 Campaign 3: c29ff415-801d-4f2c-bc30-5130b9782be7 4f3fe393-7154-41d3-8382-e90637247ee7 114e7ae1-da17-49d6-ae80-e440b4a29fd4 Looking forward to see if you can identify what's gone wrong here. Hopefully we can resolve it together 🤞
v
To avoid Cloudflare 504 errors when creating large outbound campaigns, batch your recipient list into smaller chunks (e.g., 50 contacts per batch) and launch each batch sequentially. This approach helps you stay within concurrency and processing limits, reducing the risk of timeouts and duplicate campaigns. Example pseudocode:
Copy code
js
const batches = chunkArray(recipients, 50);
for (const batch of batches) {
  await createCampaign(batch); // Launch each batch one at a time
}
This should help you process all contacts efficiently without triggering server errors. For more details, see the [Outbound Campaigns Overview](https://docs.vapi.ai/outbound-campaigns/overview). Source: - [Outbound campaigns overview](https://docs.vapi.ai/outbound-campaigns/overview)
c
Hi, I am sorry for the delayed response. I reviewed the campaign and saw that many calls are being scheduled. Due to how our system is designed, many calls are held in the queue for processing once the concurrency limit has been reached, and during certain hours it is noticeably slow. Until we optimize our system from our end. I would highly recommend to use the API directly for bulk callings. You can see more information about how to achieve it from here: (

â–¾

)
y
Thanks for the response! I'm a bit puzzled about however. We are using the API to create Outbound Calling Campaigns at the moment. The issue is when the request to create campaign times out, we don't receive any identifier to be able to retrieve data about it from the API later on. Our current workaround is to detect whenever it times out, then fetch recent calling campaigns and find the one with matching name and then retrieve the ID from there, but this is not really optimal for our use case.
c
Hi, As mentioned in my previous reply, there is an architectural problem related to campaigns which we are yet to solve, regardless of whether the campaign is created from dashboard or via
POST /campaign
. So the recommended approach to create bulk calling is by looping through all phone numbers and using the
POST /call
endpoint on each iteration.
y
Okay thanks for clarifying! Do you have any ETA of when this issue could be resolved? This approach would result in quite a large change of my infrastructure. I will start looking into making the appropriate changes necessary until then.
c
The optimization of campaigns has not been come to priority, Therefore there is no timeline set for it yet. Because of this reason, I won't be able to provide any ETA on this. We apologize for any inconveniences this might have caused you.
y
I understand. Thank you for your transparancy about these issues, I hope that you resolve this sometime in the near future.