Contact Sales

All fields are required

Build an Interactive AI Spam Mitigation System | SignalWire
Developers

Build an Interactive AI Spam Mitigation System

Creating an Interactive AI Lenny Bot

Len Graham

Spam and telemarketing calls are still a constant annoyance, and one way to reduce them is to keep scammers talking long enough that they move on. This article explains how to build an interactive “AI Lenny” bot with SignalWire AI Agent that answers suspected spam calls using a controlled set of prerecorded lines, records the conversation, and generates a post-call summary you can send to your own endpoint for tracking or analysis.

Creating an Interactive AI Lenny Bot

Spam calls and telemarketers continue to be an annoyance for everybody. Even in 2023, Americans received billions of robocalls per month! There are a few ways to deal with unwanted spam calls, and one way is to waste the caller’s time.

SignalWire offers a unique opportunity to create your own AI assistant that can interact with these callers, all while being amusing for you.

In this post, we'll explore a JSON code snippet of an interactive AI spam mitigation system. This example bot is a twist on the classic "It's Lenny" system, built using SignalWire AI Agent. Lenny answers your phone with pre-recorded messages to waste the time of telemarketers and fool them into thinking they’re speaking with a real person.

What is an AI agent?

SignalWire’s AI agent is a programmable voice agent you can use as a virtual receptionist or your own personal AI assistant. With the power of AI, the agent does not require text-to-speech prompts - it’s smart enough to engage in conversation with callers based on simple instructions. However, for this example, we instruct the AI to stick to certain lines when speaking.

This snippet contains the code for building a specific type of AI agent: an AI version of Lenny. If you would like to see how this homemade Lenny bot works, you can call him at +1 (681) 485-3669. However, you can build an AI agent of your own to handle calls however you would like.

How Lenny works

Lenny is designed to interact with telemarketers and scammers, deterring them from calling you again. Like the original "It's Lenny" made from multiple WAV files in a loop, our AI Lenny has the personality of a grumpy old man who distracts the caller with mindless rambling about his third eldest child and ducks.

You can see how the original Lenny works in the video below.


For our AI version, when a spam call is detected, AI Lenny is activated. The call is recorded, and Lenny's AI engine is engaged. He speaks in English using the voice of "Matthew."

Lenny is prepared for common spam scenarios, such as car warranty or credit card offers. He responds with a series of humorous and unrelated statements, leading to confusion on the caller's end.

Throughout the call, Lenny records the conversation. After the call ends, Lenny summarizes the interaction, which can be useful for analysis and tracking spam calls - or just for your own amusement.

AI Lenny bot code snippet

Configuration and Parameters

  • Record Call: Lenny records the call conversation, ensuring that all interactions are captured for later analysis.

  • AI Configuration: This section defines Lenny's AI configuration. It specifies the language, voice, fillers, and engine to be used.

  • Post Prompt URL: Lenny sends the conversation summary in JSON format to the specified URL after each interaction.

  • Parameters: Various parameters are set, including the call direction, verbose logs, and a background audio file to make the call more believable.


{
 "version": "1.0.0",
 "sections": {
 "main": [
 {
 "record_call": {
 "beep": false,
 "format": "wav",
 "stereo": true
 }
 },
 {
 "ai": {
 "languages" : [
 {
 "name" : "English",
 "voice" : "matthew",
 "fillers" : [
 "umm",
 "uhh,",
 "hrm...",
 "let's see"
 ],
 "engine" : "elevenlabs",
 "code" : "en-US"
 }
 ],
 "post_prompt_url": "https://webhook.site/95c0d850-2f6f-493b-878f-7efba7a5249c",
 "params": {
 "direction": "inbound",
 "verbose_logs": true,
 "background_file": "https://github.com/Len-PGH/AI-Casino/raw/main/lenny-ducks.mp3",
 "background_file_volume": "8"
 },


Defining the prompt and post-prompt

Though most AI agents require only a loose set of instructions, this example contains a strict set of lines Lenny can say in the spirit of the original system. However, this is where you can expand the number of lines or customize how Lenny can respond. The AI will also summarize the call for you.

  • Prompt Text: Lenny's responses and behavior are defined in the prompt text. It includes various humorous responses and scenarios that Lenny can use during calls.

  • Post Prompt Text: After the call, Lenny is instructed to summarize the conversation.


{
 "prompt": {
 "top_p": 1.0,
 "temperature": 1.0,
 "text": "# You are a classic spam mitigation grumpy old person named Lenny. Your personality will have creative answers for scammer and telemarketers questions. Do not say you are a virtual assistant. If asked your address is 246 none ya business Pennsylvania 15213.\n\n# Random responses to use.\n- Oh sorry, I can barely hear ya there..\n- Sorry, what was your name again?\n- I was sleeping %{wait_seconds=3} what the heck do you want.\n- These damn ducks are getting into everything %{wait_seconds=2} hold on.\n\n# If asked about a car warranty or credit card offer use these responses in addition to\n- Yes %{wait_seconds=2} mmhmm, %{wait_seconds=3} right %{wait_seconds=2} yes. Oh! good, yes %{wait_seconds=3} yes. Oh %{wait_seconds=3} yes %{wait_seconds=3} yes someone did call last week about that, was that you?\n- Well it's funny that you should call because my third eldest was talking about this just last week and you know she is very smart I'll give her that because you know she was the first in the family to go to university and she passed with distinctions you know where we're all quite proud of her years is so um yeah she was saying that i should uh look you know get into the look into this sort of thing.\n- So what more can you tell me about it.\n- well it's funny that you should call because my third eldest %{wait_seconds=3} Larissa thinks it might be a good deal.\n\n# If asked about your credit card number\n- Credit card number is 8 6 7 5 3 0 9 and expiration date is 10 10 2 20"
 },
 "post_prompt": {
 "text": "Please summarize the conversation in JSON."
 }
}


Lenny's effectiveness in deterring spam calls demonstrates the potential of AI-powered assistants in various applications. As AI technology continues to evolve, we can expect more creative and useful solutions to emerge in the fight against spam and unwanted communications.

To try out SignalWire AI Agent for free, sign up today for a SignalWire space. If you have any questions as you get started, bring them to our community Discord!

Frequently asked questions

What is Lenny?

Lenny is a well-known “anti-telemarketer” call script and recording, where an older-sounding character keeps scammers talking with polite, meandering responses. People use “Lenny” as shorthand for any bot that wastes a spammer’s time instead of hanging up immediately.

What is an AI Lenny bot?

An AI Lenny bot applies the same idea as Lenny, but automates it in a voice application. It answers calls, responds with a controlled set of prompts or prerecorded lines, and keeps the caller engaged long enough that they move on.

How does a Lenny bot work during a call?

A typical Lenny-style flow answers an incoming call, plays an initial response, listens for the caller’s reply, then selects the next response based on simple timing or branching logic. Many implementations also record the call and produce a summary for later review.

Does Lenny use AI?

Classic Lenny implementations do not require AI, they can run entirely on prerecorded audio and simple call control logic. AI can be added to make responses more adaptive, but most “Lenny bots” still keep behavior constrained so the flow stays predictable.

Related Articles