GREG
GREG3mo ago

DTMF Struggles!

I'm sure this should be a simple basic process, but I just can't get it to work and need help. Been trying to work with Tico but either I'm not following directions or he just doesn't get me! LOL I have tried just having a choice block but it’s not detecting the DTMF keys. I have set DTMF: 1 and DTMF: “1” just “1” in the intention but that does not work either. I believe it should just be a choice block with the proper DTMF reference but I’m just not getting it. When I test via phone, nothing seems to work for DTMF key press. This is where I'm at now, but I've tried many different scenarios and just can't make it work. If someone can help me I would be most grateful.
No description
1 Reply
GREG
GREGOP3mo ago
Happy to report I finally found a working solution! Flow: Message Block → Custom Action (DTMF) → JavaScript Block → Condition Block * The DTMF block passes a variable containing either the last key pressed or, if no DTMF route matches, the user’s spoken utterance. * The JS block parses this and sets a variable that the Condition block uses to route to the proper agent. I struggled for a long time because docs and advice had me referencing the wrong variable names. Key lesson: in Voiceflow JS you don’t use variables.varName — just varName directly. Working JavaScript:
// Handle both speech and DTMF in a DTMF Custom Action
if (last_event.type === "intent" && last_event.payload && last_event.payload.query) {
const spokenText = String(last_event.payload.query).toLowerCase();

if (spokenText.includes("one") || spokenText.includes("1")) {
selectedOption = "1";
} else if (spokenText.includes("two") || spokenText.includes("2")) {
selectedOption = "2";
} else if (spokenText.includes("english")) {
selectedOption = "1";
} else if (spokenText.includes("french") || spokenText.includes("français") || spokenText.includes("francais")) {
selectedOption = "2";
}

} else if (last_event.data) {
selectedOption = last_event.data;
}
// Handle both speech and DTMF in a DTMF Custom Action
if (last_event.type === "intent" && last_event.payload && last_event.payload.query) {
const spokenText = String(last_event.payload.query).toLowerCase();

if (spokenText.includes("one") || spokenText.includes("1")) {
selectedOption = "1";
} else if (spokenText.includes("two") || spokenText.includes("2")) {
selectedOption = "2";
} else if (spokenText.includes("english")) {
selectedOption = "1";
} else if (spokenText.includes("french") || spokenText.includes("français") || spokenText.includes("francais")) {
selectedOption = "2";
}

} else if (last_event.data) {
selectedOption = last_event.data;
}
Hope this saves someone else the same headache!
No description

Did you find this page helpful?