NGS

NGS

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: cnxcc.caruizdiaz.com:5070
* 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.

linphone-cnxcccnxcc-csipsimple

 

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 192.168.2.0/24, using the IP 192.168.2.97.
  • Asterisk is listening on port 5080.
  • The PSTN gateway is located at 192.168.2.20.
  • 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:

kamailio.cfg

	
request_route {
# per request initial checks
	route(REQINIT);

	# NAT detection
	route(NATDETECT);

	# CANCEL processing
	if (is_method("CANCEL")) {
		if (t_check_trans()) {
			route(RELAY);
		}
		exit;
	}

	# handle requests within SIP dialogs
	route(WITHINDLG);

	### only initial requests (no To tag)

	t_check_trans();

	if (!is_method("REGISTER|INVITE|ACK|BYE|CANCEL|PRACK")) {
		sl_send_reply("405", "Method not allowed");
                exit;
	}

	# authentication
	route(AUTH);

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

	# handle registrations
	route(REGISTRAR);

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

	if (!is_method("INVITE")) {
		route(RELAY);
		exit;
	}

	if ($rU =~ "^5959") {
		if (route(IS_FROM_SBC))
			route(FROM_SBC);
		else
			route(TO_SBC);

		exit;
	}

	route(ENFORCE_CODEC_POLICY);
	route(LOCATION);
}

route[ENFORCE_CODEC_POLICY] {
	# enforce g722 codec in all calls
	if (!sdp_with_codecs_by_name("G722")) {
		sl_send_reply("488", "Use G722!");
		exit;
	}

	# make sure g722 is the only code offered
	sdp_keep_codecs_by_name("G722");
}

route[IS_FROM_SBC] {
	if ($si =~ SBC_IP && $sp == SBC_PORT) 
		return 1;
	else
		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(RELAY);
}

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");
	}

	rewritehost(PSTN_GW_IP);
	rewriteport(PSTN_GW_PORT);

	route(RELAY);
}

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.

sip.conf

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

bindaddr=0.0.0.0
bindport=5080

[kam_transcoder]
type=friend
host=192.168.2.97
port=5075
disallow=all
allow=g722
allow=ulaw
allow=alaw
context=transcoder
canreinvite=no
insecure=invite

extensions.ael

context transcoder {

        _.      => {

                Set(SIP_CODEC=alaw);
                Set(RURI=${SIP_HEADER(X-RURI)});

                NoOp(${RURI});
                if ("${EXTEN}" != "h") {
                        SipAddHeader(X-RURI: ${RURI});
                        Dial(SIP/${EXTEN}@192.168.2.97:5075,40,rt);
                }
        }
}

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