Trying to automate outbound calls from using the REST Proxy. The flow is supposed to grab the next lead and kick off a call on behalf of the current agent.
I’m using GetRESTProxy to hit POST /api/v2/conversations/calls. The JSON payload looks like this:
{
"to": [{"phoneNumber": "{lead.phone}"}],
"from": {"phoneNumber": "{agent.phone}"},
"type": "outbound",
"providerId": "{provider.id}"
}
The call works fine if the agent has been idle for a while. The problem happens when the agent just hung up. If I trigger the within 2-3 seconds of the previous call ending, I get a 409 Conflict. The error message says User is already in a conversation.
I’ve checked the agent state in the UI. It clearly shows Available. The previous call object shows state: terminated. I even added a WAIT for 5 seconds in the script, but the 409 still hits.
Is there a delay in the platform clearing the conversation lock? Or am I missing a step to explicitly release the agent before initiating the new call? Here is the block I’m using:
Set RESTProxy to GetRESTProxy(
method: POST,
path: /api/v2/conversations/calls,
body: {
"to": [{"phoneNumber": "{lead.phone}"}],
"from": {"phoneNumber": "{agent.phone}"},
"type": "outbound",
"providerId": "{provider.id}"
}
)
The response status code is 409. Body contains "message": "User is already in a conversation".
Not sure if I need to query the conversations API first to confirm the previous one is truly gone. Or if there’s a specific header I should be sending. Tried adding If-None-Match: * but that didn’t change anything.
Any ideas on how to handle this race condition?