DTMF to capture a phone number isn't working
I'm trying to create a path for someone to enter their phone number into the voiceflow using dtmf. I'm using the JS below and I've attached a screenshot of the buildout and the results. It isn't ever triggering the complete path when the 10th number is entered. I've tried multiple versions of the JS based on the help webstie that VF provides and they are all doing the same thing. Caputring the numbers but never triggering complete. What am I missing?
/* runs right after the DTMF custom-action step /
if (typeof caller_phone !== 'string') caller_phone = '';
const digitMatch = (last_event?.name ?? '').match(/DTMF\s(\d)/);
if (digitMatch) caller_phone += digitMatch[1];
/ once we have 10 digits break the loop */
if (caller_phone.length === 10) return 'complete';
I got this directly from the VF chatbot. I can't get the (caller_phone.length === 10) to trigger.
caller_phone is my variable.
Any help would be appreciated.


2 Replies
What’s happening
The JavaScript step will only follow a path that exists on that step.
If the path name you
2. In the right-hand panel press “+ Path” and create a new custom path called
3. Drag a connection from that complete port to the block that should run after the full phone number is captured.
4. Keep the Default port wired back to the DTMF Custom-Action block so the loop continues until ten digits are collected. Your JS code is fine ✅ With the complete path added, the flow will break out of the loop immediately after the 10th digit and go down that branch. Reference: “JavaScript step → Custom paths” – https://docs.voiceflow.com/docs/javascript-step
If the path name you
return
in code ( 'complete'
) hasn’t been added in the JS-step settings, the runtime just falls back to the Default port—so it looks as if the “complete” logic never fires even though caller_phone.length === 10
evaluates to true.
How to fix it
1. Open the JavaScript step.2. In the right-hand panel press “+ Path” and create a new custom path called
complete
(exact spelling).3. Drag a connection from that complete port to the block that should run after the full phone number is captured.
4. Keep the Default port wired back to the DTMF Custom-Action block so the loop continues until ten digits are collected. Your JS code is fine ✅ With the complete path added, the flow will break out of the loop immediately after the 10th digit and go down that branch. Reference: “JavaScript step → Custom paths” – https://docs.voiceflow.com/docs/javascript-step
I’ve already added the Java script path “complete” and I’ve confirmed it is spelled with all lower case like in the js code. So that’s not the problem.
Any help here would be greatly appreciated. Thank you.