How to Troll Telemarketers with Lenny

Telemarketers are the worst. They have no souls. They feed off of the misery of others. No one likes them. Luckily, a nice British gentleman by the name of Lenny has come to save the day.

I first heard about Lenny from an youtube video on how someone was trolling spam callers. Lenny simply consists of a few lines of code in Asterisk and a handful of voice recordings, but he has the power to thwart the evil telemarketers of the world by sending them into an endlessly frustrating loop of inane conversation.

Setting up Lenny in FreePBX is a pretty simple task, and is also a really nice primer into Asterisk custom contexts, and the power of scripting.

 

Step 1 — Install the sound files

Lenny uses a series of sound files that contains the speech, background noise, etc.

You can download these and then extract the archive to /var/lib/asterisk/sounds/Lenny. Make sure permissions on the directory and the actual sound files grant your Asterisk server read permission.

Personally I used PSCP from Putty, but I know others use WinSCP, and even FileZilla.

Also note that FreePBX13+ you’ll need to extract to /var/lib/asterisk/sounds/en/Lenny

Step 2 — Setup the extension context

As I’m using FreePBX, I added the following code to /etc/asterisk/extensions_custom.conf:

[Lenny]
exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

Step 3 — Setup the custom destination

I use the Custom Destinations Module for FreePBX as it allows me to add code (such as the Lenny code above) in my extensions file and send calls directly to the context as part of my call flows, eg:

Custom Destination

If you have used the context suggested in the code snippet above “Lenny” then your custom destination should go to Lenny,talk,1.

Step 4 — Setup the extension

This step is optional but it will allow you to create an internal extension that you can dial internally or even transfer calls to.

First you need to create a new extension using “Other (virtual exten)” as the device type:

Add Extension

Don’t enable any extra services like User Manager or Voicemail as you don’t need them.

Once done you then configure the destinations to route to your custom destination:

Configure Extension

Step 5 — Setup the inbound call route

To route calls to Lenny you will need to setup an incoming call route. Your extension should be the extension you have just created:

Inbound Call Route

Step 6 — Recording the calls

If you want to record the calls, you can do it two ways:

  1. By setting your inbound call route to record calls. This has an added benefit as call recordings may be viewed from within your CDR reports,eg:
    Call Recording
  2. By adding a record function to the Lenny context, eg:
     [Lenny]
     exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
     same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
     same => n,Playback(Lenny/Lenny${i})
     same => n,BackgroundDetect(Lenny/backgroundnoise,1500)
    

Legislation regarding recording calls differs between countries. Make sure you are compliant before doing this.

Step 7 — You’re done

Apply your configuration and try calling Lenny.