Driving people insane with tripledent gum and Freeswitch

If you have seen the Disney Pixar's Inside Out, you already know what triple dent gum is. The song really burns into your brain and sticks around for a while. But why not make friends suffer as well?

Driving people insane with tripledent gum and Freeswitch

If you have no clue what I am talking about ... here you go, you will thank me later.

Ok now, let's share this great song with other people via phone calls :)

What you will need for this:

  • The WAV file of this song
  • Freeswitch
  • LUA

Create a lua file and call it tripledent.lua and place the audio file in /tmp/tripledent.wav or some better place as /tmp/ usually gets cleaned up on reboots.

require "tripledent_config"

api = freeswitch.API();

function start_call()
  first_session = freeswitch.Session("{ignore_early_media=true,sip_h_X-accountcode="..account_code..",sip_h_X-username="..username..",call_direction=outbound,origination_caller_id_number="..caller_id.."}sofia/gateway/"..gateway.."/"..number_to_call);

  if (first_session:ready()) then
    freeswitch.consoleLog("info","TRIPLEDENT: Call was answered");
    first_session:execute("playback", '/tmp/tripledent.wav');
    first_session:hangup();
  end
end

freeswitch.consoleLog("WARNING","TRIPLEDENT: Starting to have fun");
start_call();

It's important to add the ignore_early_media=true otherwise it will start playback before the call was answered and you don't want your friends missing out on this great song.

There isn't really much to say here, it starts a new freeswitch Session with ignore_early_media=true sets some headers needed for the gateway to allow the call to go through, in my case sip_h_X-accountcode and sip_h_X-username.

The required values for the parameters are hidden in tripledent_config.lua let's look at those for a bit.

account_code = "1234";
username     = "1234foobar";
gateway      = "your gateway goes here";

number_to_call = "1800123123";
caller_id = "1800123123";

The account_code, username, and gateway are needed for the outbound call to work since this differs depending on your setup you will have to figure this out on your own.

The number_to_call is obviously the number of your friend you want to call and the caller_id is the caller ID you want to use if you are allowed to send a value here.

Now for the fun part, start up your fs_cli and run this nice new lua script freeswitch> luarun /usr/share/freeswitch/scripts/tripledent.lua of course you could also run it directly from the command line /usr/bin/fs_cli -x 'luarun /usr/share/freeswitch/scripts/tripledent.lua' which also can be added in a cron job, but that would be just mean to automate your pranks.