UPDATE: with this project, I won a place in the 4th generation of startups of Wayra Mexico. More updates to come in the future posts :).

NGS, or Next Generation Support, is a project that I created to participate in the TADHack event. It is about improving the user experience we have when we call to customer support, and it takes advantage of the new telco technologies we have today, to create a product that tries to fix a rather common issue which is the bad quality in customer support systems.

What NGS has to offer?

  1. Everyone has a smartphone, and there’s an app for everything, why not for a specialized customer support?
  2. It’s really annoying to navigate through the IVR menus. It’s easier to directly go to the option you want, with a click.
  3. It can be completely free, the only thing you need is an Internet connection.
  4. The customer would be able to call from literally anywhere in the world, using Internet, no toll-free numbers at all.
  5. Call center agents can know exactly who’s calling, where is he located, and what does he want, and with this info a better customer experience can be offered.
  6. The customer can take advantage of the current technology, with HD voice quality, chatting, video calling, screen sharing, etc.
  7. The customer can know exactly who is behind the phone, with a picture, an email, a full name, and he can rate the experience he had with the agent.
  8. In summary, improved customer experience from every angle you can think of.

Opensource communication technologies I used

  1. Kamailio
  2. rptengine: this one belongs to the Kamailio project but deserves special mention because it powers the media relaying. Extremely important
  3. SIPjs
  4. Freeswitch
  5. CSipSimple: compiled in library mode, it allowed me to use PJLIB to create SIP apps for Android.

I posted below, a few screenshots of the software, and I’m planning to add more and release the code during this month.

This is a work in progress. The project has only 3 weeks of being alive, at the time this post was written.

Screenshot_2014-06-05-20-33-52 Screenshot_2014-06-05-20-34-00 Screenshot_2014-06-05-20-34-17 Screenshot_2014-06-05-20-34-21 Screenshot_2014-06-05-20-34-32 Screenshot_2014-06-05-20-34-39 Screenshot_2014-06-05-20-35-59 Screenshot_2014-06-05-20-36-15 Screenshot Screenshot-1



Cnxcc prepaid module: workshop on Kamailio World

This is a short tutorial on how to test the cnxcc module with live traffic and from any softphone. These are the things that you need:

Register from any softphone:
* server:
* username: anything between 5000-9999. Actually anything will work, but I’d rather use those numbering ranges
* password: anything. It is not required
* credit: you will get 1$ credit every time you register. If you place a call and run out of credit, just register again and you will get +1$ on your account.

Place a call: you can actually call to any number with the following pattern: “^09\d{8}$”. This basically means that you can call to a number starting with “09”, that has 8 digits afterwards. Example: 0981223344

You will run out of credit: after a little more than 10 seconds, you will run out of credit and your call will be terminated. Don’t worry, you will receive a SIP MESSAGE on you UA, if it supports it, telling you what just happened.

Recharge your line: if you want more credit, just re-REGISTER from your UA

Check you credit: by texting “credit” to destination “service“, from your UA that supports SIP MESSAGE.

Check the web: you can actually hang up somebody else’s call, or your call, from the web interface. It looks nice and you can log in using “guest” as username and “123456” password.

Call each other: you have the option to call other registered users, but for this, you have to know the number of the other person, or guess it randomly 😉

Duplicated username: you may have chosen the same username that someone else did. If that’s the case, your call will last less than 10 seconds if you call simultaneously, or not even start if someone already exhausted the credit. In the latter case, you will receive a SIP MESSAGE telling you that you have no credit left ;).

These are the files involved in this project. I hope you find them useful.

The demo has no media relay configured, so, you won’t have audio unless you are calling each other on the same network.



Asterisk as a transcoder for Kamailio

Using Asterisk as a SBC or transcoder may not be the right choice, especially if you follow the saying “use the right tool for the job”, and Asterisk is not precisely the right tool on these cases.

When you have options like FreeSwitch and SEMS, Asterisk seems to be disproportional and awkward to use, but it is so widely known that sacrificing flexibility to avoid investing time in learning a new technology (in case you don’t know FS or SEMS already) seems like a good alternative.

Having said that, let’s assume the following rules for our setup:

  • Our local network only accepts G722 codec between users, because, we enforce HD quality calls and we have lots of bandwidth at our disposal.
  •  We offer a local numbering plan and we can call between users of the network.
  • We also offer external calls to PSTN. For this purpose, we have a gateway that supports only PCMA/PCMU and G729. We don’t have the licence to do G729 in all of our softphones reason why we use PCM to reach our gateway from the softphones.
  • Asterisk will act as a transcoder, translating from G722 to PCMA/PCMU and backwards.
  • Asterisk will only take part of the SIP conversation when Kamailio detects that we are dialing to a number that does not belong to our internal numbering plan.

And from the SIP perspective

  • Kamailio is listening on port 5075 and serving on the net, using the IP
  • Asterisk is listening on port 5080.
  • The PSTN gateway is located at
  • Kamailio is accepting every registration request without any kind of authentication.
  • Username format is not being enforced, so I would recommend that you use something similar to 1000, 1100, etc.
  • I’m from Paraguay, and locally we dial “+5959” to access the mobile network. Change this pattern to your dialing prefix so that it makes sense to your gateway.

Basically, the magic on the Kamailio side happens approximately here:


request_route {
# per request initial checks

	# NAT detection

	# CANCEL processing
	if (is_method("CANCEL")) {
		if (t_check_trans()) {

	# handle requests within SIP dialogs

	### only initial requests (no To tag)


		sl_send_reply("405", "Method not allowed");

	# authentication

	# record routing for dialog forming requests (in case they are routed)
	# - remove preloaded route headers
	if (is_method("INVITE|SUBSCRIBE"))

	# handle registrations

	if ($rU==$null) {
		# request with no Username in RURI
		sl_send_reply("484","Address Incomplete");

	if (!is_method("INVITE")) {

	if ($rU =~ "^5959") {
		if (route(IS_FROM_SBC))



	# enforce g722 codec in all calls
	if (!sdp_with_codecs_by_name("G722")) {
		sl_send_reply("488", "Use G722!");

	# make sure g722 is the only code offered

route[IS_FROM_SBC] {
	if ($si =~ SBC_IP && $sp == SBC_PORT) 
		return 1;
		return 0;

route[TO_SBC] {

	xlog("L_INFO", "Going to SBC");

	# set the destination URI to our SBC
	$du = "sip:" + SBC_IP + ":" + SBC_PORT; 

	# We store the original request URI.
	append_hf("X-RURI: $ru\r\n");


route[FROM_SBC] {

	# At this point, the SDP offer should be fixed with the right codec information
	xlog("L_INFO", "Coming from SBC");

	if (is_present_hf("X-RURI")) {
		$ru = $hdr(X-RURI);
		xlog("L_INFO", "New URI is [$ru]");
	else {
		xlog("Weird, I couldn't find X-RURI hdr");



And, on the Asterisk side we have got two things to modify:

  1. sip.conf: we have to add our Kamailio instance as a trusted peer, with no authentication and with the right codec definition
  2. extensions.ael: yes, I use AEL instead of the common extensions.conf, mostly because I hate extensions.conf syntax. If you chose to use .conf, no problem. It should work using whatever you choose.


context=public                  ; Default context for incoming calls. Defaults to 'default'




context transcoder {

        _.      => {


                if ("${EXTEN}" != "h") {
                        SipAddHeader(X-RURI: ${RURI});

The full list of files are available on my github, here.

Csipsimple: a custom version


Ever heard of it? It’s an Android SIP client, the best to my opinion, that ports the PJSIP stack to Android devices and adds to it a really good-looking user interface.

Four months ago, I started studying Android programming and the love for it didn’t take long to come. Learning it was relatively easy because of my background on Java, but it is a complicated platform with so much diversity that it will take long before I could say that I fully understand everything.

Creating a custom version of Csipsimple has been in my TO-DO list since more than a year. I first tried to rebrand it but I had no idea how to do it and I even downloaded the code and took a look on it. It was Chinese to my eyes.

Finally, I decided to study Android and the result of it is a work in progress which is looking quite good and promising to be a great product for ng-voice, the company I work for.

Below are a few screenshots of the product, and with this link you can get to the github project with a full list of features and things that makes the softphone different than the original csipsimple.

Login Screen
Login Screen
Customer information screen
Customer information screen


DWG2000 API Windows demo

Finally a full-featured and executable demo is available for downloading and testing.

It runs on any Windows box with dotNet framework 2.0 installed on it. Personally, I tested the app on Windows XP and Windows 7.

To try it, decompress the zip file and paste the only two DLL files into %windir%System32 folder. Then, run the executable file.

This is a very early demo application and it may contain bugs. In case of that, please report it to my personal email so I can fix it.


Kamailio: modifying “expires” attribute

Have you ever needed to change the expires attribute of the Contact header in a REGISTER message because you don’t use usrloc or registrar modules? Well, if that is your case, this code snippet may be helpful for you:

But why so complicated? Two things.

– We use a custom module for registration. It’s written in C and the expires attr is generated by the Authorization authority.
– Save(“location”) of usrloc module automatically sends the 200 OK with the correct headers. We do not have this in hand for usage.

This might not be the easiest way of doing it, but it works, serves the purpose and could be used as an alternative 🙂

C# bindings for DWG2000 SMS API

Yes, it’s done and as I promised in my previous post, I am releasing it to the public.

This project started when a local company hired me to make the API support for Linux. It was a success and the sms-client started to work right away. It was not until 2 or 3 months after finishing the project that the idea of making the source code public came to my mind and despite this project may not be a great contribution to the community, it is the first of (hopefully) many.

This particular branch of the project might be specially useful for writing quick VAS software on top of the gateway. It is much easier to write business logic algorithms in C# than in C and in my case, that’s exactly what happened.

Get a copy from my github account

Dinstar SMS API update

I’ve been working very hard in the past few months that updating my blog was relegated to the least of my priorities. It’s a pity, but I had no choice :(.

Back on the track, I came here to present an update of the Dinstar’s SMS API implementation which I started writing some time ago. I paused the project several times mostly because I had no economic reason to support my time on it , but luckily, the situation changed and today the great majority of the API is implemented and working.

I don’t maintain a changelog other than the one on github commit list, but basically, this is what changed:

– Support for API 1.4 and 2.0
– Support for authentication mechanism. (This is partial, check source code)
– Support for RSSI packages
– Support for Unicode strings
– The project is no longer a standalone application, now is a shared library.
– Several bug fixes

The C# bindings are also ready. I will publish the code probably next week.

Check the repo on github

Opensourcing my Clasipar bot

I’m opensourcing, after two years of continued use (:D), a bot for refreshing ads that were published in a specialized classified ads webpage called Clasipar, which is the most popular webpage for this kind of services here in Paraguay.

When you publish an advert on Clasipar, your announcement has a living period of 24 hours. After that, it gets lost among the thousands of other ads in the category it was published in. If you don’t periodically refresh your ad, in a daily basis for example, it will probably disappear completely unnoticed and whatever business you wanted to do, will never be concreted.

This is where this bot comes in. Once your announcement is online, the bot refreshes it daily so you don’t have to worry about this task anymore. You can even publish 3 copies of the same announcement and configure the bot to automatically refresh them at 9am, 1pm and 5pm, for example. This method allows you to get your ad always in the front page of its category.

On September 21 of 2010, I wrote a post about this piece of software and here’s the entry.

Check out the code at For usage, take a look to the README file.