3

I'm creating a Fiddler extension that is simplifying my interaction with Twilio during development. I'm about to release it to the wild, but I would like one more feature before I do so.

I'm able to return the various phone numbers on my Twilio Account, and list them with the various URLS that are required.

I would like to select on of the numbers, and "Click-To-Test" whick will dial the selected phone number. I would then like to interact with my Twilio service via my computer rather than picking up a phone.. I should be able listen to the voice prompts, and interact by dialing 1, 2, 3 etc. when prompted.

Twilio offers this JavaScript library here (Twilio in the Browser), and give an example here via Azure (Twilio in Javascript Application), or here via MVC (Hello Monkey Client)

All of which leverage a Javascript library which creates a Twilio Device on the client side. I'm NOT a Javascript guy (yet, but it looks like that's next on my every growing learn-this-technology list), but I have to think that the same functionality could be implmented in C#.

I've attempted to host the device in a browser control, but I'm not getting to far with it, and the integration still remains on how to pass a select item in C# to a executing Java Script library running in a browser.

I've also looked into IronJS run the JavaScript via the Dynamic Run Time, but I'm not sure if that will work in the end. The Twilio Library looks for a script tag in the web page, and hooks up several event handlers. Running the library in IronJS, causes it to fail as there is no web page, and my Java chops are not up to hacking this piece out.

My question is: Can't this Javascript Library be ported to C#, and create a full client that Twilio sees like the Javascript soft phone? I would think this would not only be helpful for me, but also for Win 8 dev, and Windows Phone 8 Dev as well.

codeputer
  • 1,987
  • 3
  • 19
  • 45
  • I am having a hard time understanding your integration requirements. C# is not a client-side programming language that you can run in browser, yet you want to run this in the browser and use C#. Did I not understand correctly? You mention passing something from C# to JavaScript. This is very doable using ASP.NET MVC. Explain more about the architecture of your existing application that this needs to integrate with. Is it ASP.NET? Is it Web Forms or MVC? Why do you feel that the JavaScript libraries need to be ported to C#? Are you trying to run this server side or client? Considered NodeJs? – Kevin Junghans Jan 25 '13 at 14:32
  • Hi Kevin, This is such a mix of technologies, I'm not sure I got it right! :S 1) I do NOT want to run in browser, I want to connect to Twilio using a full fat client written in C#. 2) IronJS allows you to execute JavaScript WITHIN a C# program. Leveraging IronJS, I wouldn't have to port the JavaScript to C# but simply use as is. HOWEVER, the Twilio script refers/searches the Browsers DOM which is NOT available in IronJS - soooo either we find a way to remove this dependency, or this alternative is a no go. – codeputer Jan 25 '13 at 20:36
  • I am currently using ASP.NET WEBAPI with Twilio, but this is for a soft phone which would mimick a connection with Twilio in exactly the same manner if I would dial a Twilio number via my mobile phone. – codeputer Jan 25 '13 at 20:43

3 Answers3

0

I'm not a C# developer, I believe hosting the JS library in a WebBrowser control seems the way to go (at least much easier than porting the library to C#).

According to MSDN, you can use the Document property to call JS code from your application. For example, if you had this defined in your web page:

function test(message) { 
    alert(message); 
}

You can call it from your application:

webBrowser1.Document.InvokeScript("test",
    new String[] { "called from client code" });
Jeffery To
  • 11,836
  • 1
  • 27
  • 42
  • I can try to be more specific to your situation if you post more details on the integration you're trying to accomplish. – Jeffery To Jan 30 '13 at 04:08
0

Unfortunately, there's not a straightforward path to using Twilio Client in Windows 8 or other Windows desktop apps. I will pass along this feedback that it would be great to have VoIP functionality through Twilio for Windows 8 apps.

Kevin Whinnery
  • 1,209
  • 10
  • 11
-1

The Twilio C# helper library should help with this.

https://github.com/twilio/twilio-csharp

See the blog post below for an example application:

http://www.twilio.com/blog/2012/02/twilio-for-net-developers-part-5-twilio-client-mvc-and-webmatrix-helper-libraries.html

You also linked earlier to a Twilio Client C# code example:

http://www.twilio.com/docs/quickstart/csharp/client/hello-monkey

All of the Twilio Quickstarts can be viewed in C# using the language drop down in the upper right.

beanserver
  • 652
  • 3
  • 6
  • One of your links I put in my question. I realize the Twilio client should help me, but I don't think you took the time to read the question. I would like to run the Twilio script in IronJS, or have it ported to C#. – codeputer Jan 24 '13 at 18:32