Ah, this is a good challenge to dig into with a couple of surprisingly simple solutions. We've had a couple of customers ask this question, so I think it's something that's worth blogging about.
The type of interactive phone services I'm referring to are the DTMF tone-driven services that so many of us love. The basic premise is that you are prompted to provide feedback to the service via your numeric keypad on the phone. Some examples of these services include conference call gateways, interactive phone menus, ticket hotlines, etc.
I'm a bit of a fan of agile development practices so let's go ahead and use a simplified agile methodology to create a usuable bit of code. First, we need to create a user story. A user story is a way the capturing requirements for the project. We will only have one requirement for our project, so let's go ahead and write a few short sentences to describe it.
The user should be able to enter a phone number for the conference call gateway and a pass code for the meeting. The user should only need to press one button to both dial the gateway phone number and communicate the pass code to the conference call gateway. The user should have the option of sending an additional character (#, a pound sign) to mark the end of the pass code, should the conference call gateway support this.
Now that we have the user story, we can go ahead and start to implement it. The first step I'm going to take is to layout the UI for the application much of the user story is about the way the user interacts with the application. I'm going to need a couple of text boxes for the conference call phone number and the pass code, and I'll need to checkbox to determine whether the optional pound sign should be entered.

Fig 1. The user interface for the conference call dialler
Great! Now we need to start thinking about how we are going to call the conference call number and then enter the pass code. With a little bit of research, we find that most conference call systems will initially play back a recorded message prompting the caller for the pass code, so we need a way of dialling the number, pausing for the prompt and then entering the pass code.
Luckily, the telecommunications industry provide a standard way of controlling the dial sequence through a series of tokens. These tokens are defined in a RFC3601. The token we are interested in is 'p'. This will initiate a brief pause before continuing with the rest of the dial sequence. For example, if the conference call number is 1-800-123-4567 and the pass code is 8899, you can enter the following sequence to call that number and enter the pass code:
18001234567p8899
But how do you enter 'p'? on a phone? Isn't 'p' the 7 key on the keypad? Well, it is, but you enter the 'p' by pressing and holding the asterisk key (*). If the conference call service requires the terminating pound sign, you can enter this:
18001234567p8899#
You can have as many pauses as you like in a dial sequence. This is useful for navigating your way through interactive services that present a deep heirarchy of menu options. For example:
18001234567p1p1p2p1p3
This would dial 1-800-123-4567, then select option 1, select option 1, select option 2, and then select option 3. Hopefully, by this point you'll be connected to the service you require!
How does this relate back to our user story? Well, we can simply take the conference call number, the pass code and the pound sign and concatenate them to form the dial sequence we need for the call service. Then using the Microsoft.WindowsMobile.Telephony.Phone class, we can dial the sequence and wait to be connected. The code for doing this is shown below:
string phoneNumber = string.Format("{0}p{1}{2}", ConferenceNumber.Text,
PassCode.Text, (PoundSign.Checked ? "#" : string.Empty));
Microsoft.WindowsMobile.Telephony.Phone p = new Microsoft.WindowsMobile.Telephony.Phone();
p.Talk(phoneNumber, false);
The second parameter passed to the Talk method sets a flag to suppress a dialog asking the user to confirm that they wish to dial the number. Plug this code into the Dial button's Click event handler and the application is complete with just 3 lines of code. Amazing!
The customer is happy -- we've implemented everything in the user story and it works great! However, I did say that there is more than one way to do this and to demonstrate this clearly, I'm going to modify the original user story a little. I'll mark the changes to the user story in bold.
The user should be able to enter a phone number for the conference call gateway and a pass code for the meeting. The user should press one button to dial the call service and then, when prompted, press another button to enter the pass code. The user should have the option of sending an additional character (#, a pound sign) to mark the end of the pass code, should the conference call gateway support this.
In order to accomodate this changes to the user story, we will need to modify the user interface slightly. We will need to remove the Done button and move the Dial button into its place. Where the Dial button was, we will add a new button to enter the pass code.

Fig 2. The modified user interface for the
conference call dialler
The code behind the Dial button will also need to be changed. To meet the requirements set out in the user story, we will simplify the code so that it just calls the conference call number:
Microsoft.WindowsMobile.Telephony.Phone p = new Microsoft.WindowsMobile.Telephony.Phone();
p.Talk(ConferenceNumber.Text, false);
Now we just need to handle the Pass Code button Click event and enter the pass code through the connected call. This is easier than it sounds because Windows Mobile comes to our rescue.
The Windows Mobile platform supports a feature called asynchronous pluggable protocols. In essence, this is a way of registering a custom URL protocol scheme and an associated URL protocol handler with the operating system so that when the URL is called, the URL protocol handler will be invoked. An example of a URL protocol scheme is http and its URL protocol handler under Windows Mobile is piexplore.exe, Pocket Internet Explorer.
A simple way to demonstrate how URL protocol schemes work is to create a new process and pass a URL as the command parameter. The following code will launch Pocket Internet Explorer and navigate to the OpenNETCF web site:
System.Diagnostics.Process.Start("http://www.opennetcf.com/", string.Empty);
There are number of URL protocol schemes registered with the operating system by default. If you want to check out the protocols schemes, these can be found in the registry under the following key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shell\URLProtocols]
There are number of interesting URL protocols schemes registered under this key, including callto, sms, mms, tel, and res, but the one of interest to use is dtmf. Using this protocol scheme, you can simulate the pressing of touch-tone keys during a call. This is how we will enter the pass code when the user clicks the Pass Code button when prompted for pass code by the call service. In the Pass Code click handler, we will need to add the following code:
Process.Start(string.Format("dtmf:{0}{1}", PassCode.Text, (PoundSign.Checked ? "#" : string.Empty)), string.Empty);
Now that we had add this code, the user story has been implemented and all that is left to do is compile the application and try it out. Once again, all we wrote was 3 lines of code!
I've created a Visual Studio 2005 containing both projects that implemented in this article. You can download the sample solution from here.