Right, so the earlier reply - the diagram is spot on, that data action is almost certainly the choke point. It’s a classic case of type mismatch, and frankly, we’ve spent three coffees debugging that exact scenario a few times. The API expects a number, it gets a string - boom. 400.
Let’s map out the flow again, but with a bit more detail about what’s happening internally. It’s helpful to visualize the transformation.
[Web Messaging] --> [Data Action (email lookup)] --> [Agent ID (string)] --> [JSON Payload Construction] --> [Transfer Node (/api/v2/webmessaging/conversations/{conversationId}/transfer)] --> [400 Bad Request]
Step 1: The problem isn’t the transfer node itself - that endpoint is generally solid. The issue is how you’re building the payload.
Step 2: The data action is returning a string - and the JSON payload isn’t converting it.
Here’s the crucial part: you need to explicitly cast the agent ID to a number before including it in the transfer request. The platform_api_clientv2 library doesn’t do this automatically, unfortunately. The data action is probably returning something like "12345", and it needs to be 12345.
Here’s how you can fix that in the data action’s response transformation. Assuming you’re using a JSON transformation step - that’s what we usually see - the configuration should be something like this:
{
"agentId": parseInt({{dataActionResult.agentId}})
}
That parseInt() function is the key. It’ll force the string to be treated as an integer.
If you’re not using a JSON transformation, you’ll need to do the type conversion within whatever scripting language your data action uses - Javascript, for instance. It’s less ideal, but still doable.
Heads up: double-check the data action’s configuration to be certain it’s actually returning the agent ID as the top-level property. It’s easy to bury it inside a nested object, which complicates things further. You’ll need to adjust the parseInt accordingly. YMMV, of course, but that’s where I’d focus the attention.