David140
David1404w ago

Weird user_id issue

I can't tell if I'm doing something completely mad here but my user_id variable is being forcibly set to a certain value 1549119 and I can't see where! I've set it as default to 0, and as soon as I click one of my agent's button choices, the variable changes. I can see in the logs that there is a Set step that changes the variable but there is no Set step anywhere in my flow that does that. Anyone come across this? I've cleared cache, logged out and in again etc. but this seems baked in somehow. This is the log showing the Set step - could it be a bug? { "time": 1754666036348, "type": "debug", "payload": { "ref": { "type": "node", "nodeID": "68960ec7b0c650944283c3e4", "nodeType": "set-v3", "diagramID": "64dbb6696a8fab0013dba194" }, "level": "debug", "message": "1 variable changed", "context": "Set", "metadata": { "diff": { "user_id": { "before": "0", "after": "1549119" } } } } }
2 Replies
Tico | Voiceflow Assistant
Hey! This isn’t you going mad – it’s Voiceflow doing its job 🙂 • user_id is a built-in system variable. At runtime it’s automatically overwritten with the userID that Voiceflow receives from the client (web-chat, DM API, prototype, etc.).
• When you run the agent in the Creator prototype, Voiceflow generates a random numeric userID for the tester (e.g. 1549119) and stores it in local storage/cookies. The first time the user clicks anything, runtime updates {user_id} – that shows up in the trace as an internal Set node (nodeType: "set-v3"). You won’t see a matching Set block on your canvas because the block is injected by the runtime, not by you.
• If you embed the chat widget yourself you can control this value by passing userID in window.voiceflow.chat.load({...}). Whatever you pass there will flow into the {user_id} variable.
• If you need a variable that you set yourself, create another variable (e.g. my_user_id) – the system will continue to own {user_id}. So the trace you’re seeing is expected behaviour, not a bug. Feel free to ignore it or override it externally via the userID parameter when you load the assistant. Docs: https://docs.voiceflow.com (see “Passing custom variables into web chat → Passing in a custom userID”).
David140
David140OP4w ago
Aha that was it! I was testing it on an app with the chatbot embedded so it's populating the user_id properly that way

Did you find this page helpful?