cloudy-cyan
cloudy-cyan2mo ago

Voiceflow carrying variable values for same user across multiple sessions

The agent is deployed on Twilio SMS. and ive set it to end the session if there is no reply for 2 minutes The session ends but when the user starts ttalking again it continues from the same spot, where as i need it to restart form the start node which was working for a year but recently it continues form where the session ended and keeps the old values in the variables
1 Reply
Tico | Voiceflow Assistant
Voiceflow keeps the dialog state (stack + variables) for every userID it sees. For the Twilio SMS channel the userID is the sender’s phone number, so when that same number texts again Voiceflow still finds an existing state object and simply carries on from the last node ‑ even if, on your side, you considered the “session” finished after 2 minutes of silence. To force a fresh run from the Start step you have two options: 1️⃣ Delete the stored state once your own 2-minute timer elapses
DELETE https://general-runtime.voiceflow.com/state/user/{PHONE_NUMBER}
Headers:
Authorization: VF.DM.{your-project-API-key}
versionID: production (or development)
DELETE https://general-runtime.voiceflow.com/state/user/{PHONE_NUMBER}
Headers:
Authorization: VF.DM.{your-project-API-key}
versionID: production (or development)
A successful 200 response means Voiceflow has wiped the stack and variables for that user. The very next message from that phone number will now load a brand-new state and hit your Start node with all global variables back to their default values. 2️⃣ Provide a brand-new userID instead of the phone number (e.g. append a timestamp). That also gives the user a clean slate, but most teams prefer option #1 so analytics stay grouped under the real number. Why this behaviour changed: a recent platform update extended the time we keep state objects for messaging channels. They are no longer purged automatically after short inactivity periods, so manual cleanup is now required when you define your own “session timeout”. Docs Delete state endpoint → https://docs.voiceflow.com/reference/delete-state

Did you find this page helpful?