🕵️ SicherheitslückenWhat continuous operational resilience looks like under DORA(09.09.2026 um 17:53 Uhr)
🔧 AI Nachrichten OpenAI seeks tougher AI rules. CIOs may feel the ripple effects(10.09.2026 um 12:11 Uhr)
🔧 AI Nachrichten Mistral valued at €21bn after €3bn Series D funding round(08.09.2026 um 10:19 Uhr)
🪟 Windows TippsWindows XP's Cursor Indicator Is Getting a Windows 11 Refresh(25.08.2026 um 13:00 Uhr)
🕵️ SicherheitslückenWhat continuous operational resilience looks like under DORA(09.09.2026 um 17:53 Uhr)
🔧 AI Nachrichten OpenAI seeks tougher AI rules. CIOs may feel the ripple effects(10.09.2026 um 12:11 Uhr)
🔧 AI Nachrichten Mistral valued at €21bn after €3bn Series D funding round(08.09.2026 um 10:19 Uhr)
🪟 Windows TippsWindows XP's Cursor Indicator Is Getting a Windows 11 Refresh(25.08.2026 um 13:00 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 4 Min Lesezeit
0

Gathering Keypad Input in Voice Calls with Twilio and .NET

↗ Quelle (dev.to)
🗣️ Stimme:

Twilio, a cloud communications platform, enables developers to integrate communication features such as SMS, voice, video, and email into applications effortlessly. Among its many capabilities is the ability to gather user keypad input (DTMF tones) during a voice call. This guide walks you through the process of implementing a feature that collects keypad input and responds dynamically in a .NET application.



Overview of Twilio’s Gather Verb

The Gather verb in TwiML (Twilio Markup Language) is used to capture user input during a call. By using the Gather verb, you can prompt users to press keys on their phone’s keypad and respond based on their input.



Step 1: Set Up an Endpoint for Keypad Input

To begin, create an endpoint using ASP.NET Core to serve TwiML that includes the Gather verb. This endpoint provides instructions to the caller and waits for a single digit of input.



Example Implementation




CODE
using Microsoft.AspNetCore.Mvc;
using Twilio.TwiML;
using Twilio.TwiML.Voice;

[Route("api/[controller]")]
[ApiController]
public class VoiceController : ControllerBase
{
[HttpGet("gather")]
public IActionResult Gather()
{
var response = new VoiceResponse();

// create a Gather verb to listen for keypad input
var gather = new Gather(
input: new List<Gather.InputEnum> { Gather.InputEnum.Dtmf }, // listen for keypad input
numDigits: 1, // gather 1 digit
action: new Uri("https://yourapp.com/api/voice/handle-key") // redirect to handle-key endpoint after gathering input
);

gather.Say("Press 1 for sales, 2 for support, or 3 for billing."); // add instructions to the Gather verb
response.Append(gather); // add the Gather verb to the response
response.Say("We didn’t receive any input. Please try again."); // provide a fallback if no input is gathered

return Content(response.ToString(), "application/xml");
}
}







Step 2: Handle Keypad Input

Create another endpoint to handle the user’s input and respond based on the keypad digit they entered. Once the user provides input, this endpoint processes the received digit and returns an appropriate response based on their selection.



Example Implementation




CODE
[HttpPost("handle-key")]
public IActionResult HandleKey([FromForm] string Digits)
{
var response = new VoiceResponse();

// check the gathered digit and respond accordingly
switch (Digits)
{
case "1":
response.Say("You pressed 1. Connecting you to sales.");
// Here you could redirect to another call or add more actions
break;
case "2":
response.Say("You pressed 2. Connecting you to support.");
// Redirect to support, etc.
break;
case "3":
response.Say("You pressed 3. Connecting you to billing.");
// Redirect to billing, etc.
break;
default:
response.Say("Invalid option. Please try again.");
response.Redirect(new Uri("https://yourapp.com/api/voice/gather")); // Redirect back to gather if invalid input
break;
}

return Content(response.ToString(), "application/xml");
}







Step 3: Initiate the Call

Trigger the voice call and direct it to the endpoint created for gathering input (/api/voice/gather).



Example Implementation




CODE
var call = CallResource.Create(
to: new PhoneNumber("+1234567890"), // recipient's phone number
from: new PhoneNumber("+0987654321"), // your Twilio phone number
url: new Uri("https://yourapp.com/api/voice/gather")
);

Console.WriteLine($"Voice call initiated with SID: {call.Sid}");






Complete Flow Overview

Call Initiation: A voice call is initiated, and the user is directed to the /api/voice/gather endpoint.



Gather Input: The user hears a message and provides input by pressing a key on their phone.



Input Handling: The digit entered is sent to the /api/voice/handle-key endpoint, which responds based on the user’s choice.



Redirection: If the input is invalid, the user is redirected back to the gather step for another attempt.



Conclusion

Using Twilio’s Gather verb in combination with .NET provides a powerful way to collect user input during calls and handle it dynamically. This approach is ideal for creating interactive voice response (IVR) systems, ensuring a seamless user experience for callers. By implementing TwiML endpoints, you can prompt users, process their input, and respond with tailored actions, all while leveraging Twilio’s scalable communications platform.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Sam Altman calls GPT-6 Astra rollout ‘messy’ as enterprise users wait for access
1 Quelle
Swiss government explores replacing Microsoft 365 with open-source software
1 Quelle
What continuous operational resilience looks like under DORA
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Gathering Keypad Input in Voice Calls with Twilio and .NET

Thematisch verwandte Begriffe: Gathering, Keypad, Input, Voice · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...