[Free Module] Use Groq AI to filter spam emails and form submissions!

In this example, we are using Groq AI (free), to parse content and determine whether it is spam.

Example Output

Screenshot_2024-08-07_200837

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

Click to Expand Module Export Code

JSON - Copy and Paste this directly in the scenario editor

{
  "subflows": [
    {
      "flow": [
        {
          "id": 1,
          "module": "groq:createJSONChatCompletion",
          "version": 1,
          "mapper": {
            "model": "llama-3.1-70b-versatile",
            "systemPrompt": "Classify the provided email as spam or not spam. Consider factors such as language, grammar, urgency, suspicious links, and requested actions. Provide a confidence score and a concise reason for the classification.\n\nThe JSON should look like this:\n\n{\n  \"is_spam\": true,\n  \"confidence_score\": 0.98,\n  \"reason\": \"The content contains a suspicious link and keywords not typically found in a form submission.\",\n  \"suspicious_keywords\": [ \"p0rn\", \"pu$y\", \"loli\", \"sex\", \"weight loss\", \"casino\", \"gamble\", \"seo\" ],\n  \"suspicious_links\": [ \"https://bit.ly/example\" ]\n}",
            "userMessage": "",
            "temperature": "0.15"
          },
          "metadata": {
            "designer": {
              "x": 0,
              "y": 0,
              "name": "AI Spam Filter"
            }
          }
        }
      ]
    }
  ],
  "metadata": {
    "version": 1
  }
}

Where to get a free Groq AI API key

  1. Go to https://console.groq.com/keys

  2. Register for a free account

  3. Click on “Create API Key”
    Screenshot_2024-08-08_190851

— @samliew

5 Likes

2025 Update

Hello everyone who has been using this module, and for those who want to test this module out:

Since my last post above in 2024, Groq has deprecated the ilama-3.1-70b-versatile model, and also the example words in the prompt used above may trip Groq’s “unsafe” filters. Hence, an update to this module is due.

Here’s a screenshot of the new settings with the latest model, improved prompt:

Get the module below —

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":2,"module":"groq:createJSONChatCompletion","version":1,"parameters":{"__IMTCONN__":1},"mapper":{"model":"llama-3.3-70b-versatile","systemPrompt":"Analyse the provided content. Consider factors such as language, grammar, urgency, suspicious links, and requested actions. Provide a score ranging from 0.00 for legitimate to 1.00 for definitely spam, and a concise reason for the classification. If the content is not in English, then provide a translation.\n\nIf the content is similar to \"hello I want to know your price\" and has a link from a link shortener or suspicious TLDs (like .ru), then it is likely spam.\n\nYour response must strictly follow the following example JSON object format and property types. Never wrap the JSON output with codefences, markup, or explanations.\n\n{\n  \"is_spam\": true,\n  \"score\": 0.74,\n  \"reason\": \"The content contains a suspicious link and keywords.\",\n  \"suspicious_keywords\": [ \"click\" ],\n  \"suspicious_links\": [ \"https://bit.ly/example\" ],\n  \"translation\": null\n}","userMessage":"{{join(map(toArray(1.data); \"value\"); newline)}}","temperature":"0.10"},"metadata":{"designer":{"x":300,"y":600,"name":"AI Spam Filter"},"parameters":[{"name":"__IMTCONN__","type":"account:groq","label":"Connection","required":true}]}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Hope you continue to find this module useful!

— @samliew

2 Likes