Architect Expression - Variable Scope Issue

Okay, so this feels…familiar. Three coffees in. Been here before, honestly. We’re migrating a Twilio Gather to Architect, and I’m battling scope issues with variables in a Data Action.

The flow’s grabbing digits from a speech node, storing them in a variable called v_digits. Simple enough. Then, a Data Action attempts to pass v_digits to /api/v2/conversations/{conversationId}/messages, hoping to use it in a webhook payload. The thing is, the webhook’s recieveing an empty string for v_digits.

I’ve checked the expression syntax - it looks correct. I’ve also confirmed the speech node is populating v_digits correctly using a display node right before the Data Action. Feels like Architect isn’t passing the variable scope through the Data Action properly. I tried {{v_digits.value}} and {{v_digits}} - no dice. I remember fighting something similar in '21 with a different BPO, and it involved manually setting the context…ugh. Anyone else hit this?

fun one today. spent half the morning tracing this exact issue - variable scope in architect is…fragile, to put it mildly.

the data action is the bottleneck. architect’s variable passing isn’t direct - it serializes everything into a JSON payload, then deserializes it on the webhook side. that adds overhead. a LOT of overhead, especially if you’re hitting the messaging endpoint repeatedly.

try this - instead of directly passing v_digits, build the entire payload inside the architect flow using a Set Variable action. concatenate the digit string into a JSON object. it’s clunky, yeah, but avoids the scope issue and cuts down on the serialization/deserialization round trip.

{
 "type": "text",
 "text": "You entered: ${v_digits}"
}

then pass that whole JSON string to your webhook. the payload becomes a single variable. it’s still JSON, so you’re still parsing it, but you’ve eliminated an extra layer of conversion.

also - and this is CRITICAL - make sure your webhook isn’t doing any unnecessary processing. every microsecond counts. poorly written webhooks can KILL performance. we’ve seen jobs stall out when webhooks take longer than three seconds. test with simple payloads first.

1 Like