Dynamic Profanity Filtering Using API Filters + OpenAI's ChatGPT

Lead Prosper has always made it simple to filter leads based on any data points you collect, including things like names, email domains, custom fields, and more. Traditionally, if you wanted to block leads containing profanity, you’d need to maintain a static list of banned words and phrases—manually updating and expanding it over time to stay effective.

But what if you could take a smarter, more dynamic approach?

Thanks to the rise of AI platforms like ChatGPT and the introduction of API Filters in Lead Prosper, you can now automate profanity detection in real time—without relying on a static word list. Let’s walk through how you can use OpenAI’s API in combination with Lead Prosper's API Filters to intelligently screen for inappropriate or offensive language.

To learn more about setting up OpenAI ChatGPT to Dynamically Filter Leads In Lead Prosper check out this article - https://support.leadprosper.io/article/267-using-openai-and-api-filters-to-dynamically-filter-leads-in-lead-prosper

To get started, you'll need an OpenAI account and an API key.

If you don't already have an API key, follow this guide from OpenAI to generate one. Once you have your API key, make sure to copy it—you’ll need it during the setup process.

Adding the OpenAI API Filter to Your Campaign


  1. Navigate to your Campaign.

    Decide where you'd like to apply the filter:

    • Globally, across your entire campaign
    • Or to a specific Supplier or Buyer
  2. Click New Filter > API Filter to start setting up the filter.

Configuring the API Filter


A pop-up window will appear with configuration options. These settings are tailored specifically for use with the OpenAI API. If you're using a different API provider, the setup may look quite different.

  • Run filter on: Choose Pre-Ping, Ping, and / or Post.
  • Post URL: https://api.openai.com/v1/chat/completions
  • Request Method: POST
  • Payload Type: JSON
  • HTTP Timeout: 30 (default)
  • Body:
{
"model": "gpt-4",
"messages": [
{
  "role": "system",
  "content": "You are a content moderation assistant. Only respond with 'Yes' if the input text contains any profanity or offensive language. Respond with 'No' if it does not."
},
{
  "role": "user",
  "content": "This is such a damn mess, I can’t believe this crap!"
}]}
  • Custom Headers:
    • Key: Content-Type

      Value: application/json

    • Key: Authorization

      Value: Bearer {{OpenAI_API_Key}}

  • Response Type:
    • Action: Allow
    • Condition: key equal with
    • Key: choices/0/message/content
    • Value: Yes
  • Customer Error Message (optional): Zip code not within given range.

Understanding the OpenAI ChatGPT Prompt


Lets break down the Body so you can understand what can be modified to produce different results:


"role": "system"

{
  "role": "system",
  "content": "You are a content moderation assistant. Only respond with 'Yes' if the input text contains any profanity or offensive language. Respond with 'No' if it does not."
}

This part of the setup provides context to OpenAI about what you're asking it to do. Here's what the prompt is communicating:

  • You are assigning the role of an content moderation assistant (or character).
  • The assistant’s task is to check given text to see if it contains any profanity or offensive language.
  • If the input text contains profanity or offensive language, the assistant should respond with “Yes.”
  • If the input text does not contain profanity or offensive language, the response should be “No.”

"role": "user"

 {
      "role": "user",
      "content": "This is such a damn mess, I can’t believe this crap!"
    }

This section is where you will set the input text that will be evaluated for profanity or offensive language. You can put any campaign fields you want in the "content" value, such as {{first_name}} {{last_name}} if you want to check the first and last name of the lead for profanity. Here is how it might look with placeholders.

 {
      "role": "user",
      "content": "{{first_name}} {{last_name}}"
    }

Here is how this API filter would look in the end:

By combining the flexibility of Lead Prosper’s API Filters with the power of OpenAI, you can now intelligently detect and filter out profanity or inappropriate language in real time—without the need for maintaining static keyword lists. This AI-driven approach not only streamlines your lead validation process but also helps protect the quality and integrity of your lead flow. As AI technology continues to evolve, so do the tools at your fingertips. We’re excited to see how you’ll leverage these capabilities to create cleaner, higher-quality pipelines and deliver better experiences for your partners and clients.

Still need help? Contact Us Contact Us