menu

Finding Leads on Reddit and using Chat GPT to score them


They say Reddit is a gold mine of sales prospects, but who has time to read every post? That would take a team of people. Why not automate this? In this post we build automations to search Reddit for new posts matching keywords, and then use Chat GPT to score the probability that the post is indeed a viable prospect.

What we want to achieve here (and we'll show you how), is:

  • Automatically search Reddit for potential posts where you can plug your product or service
  • Have Chat GPT give a sentiment analysis as to how likely the user posting is looking for what you offer
  • Have Chat GPT create a comment that you can copy and paste and use as a starting point for posting your reply comment on Reddit

Just these steps alone should save you hundreds of man hours.

Setup Assets

Before getting into this, there are 2 integrations you need to set up in your InfoLobby account:

Reddit API Key

Set it up in Reddit at https://www.reddit.com/prefs/apps

Then add it as an oAuth2 API integration in InfoLobby:

OpenAI API Key

Get an API key at https://platform.openai.com/api-keys

Then set it up as Bearer Token API in InfoLobby:

We're also going to need 2 tables to get us started:

  1. A table for keyword lists that we're interested in
  2. A table for hits that the flow finds in Reddit

Searchers Table

The Searchers table has the following fields:

  • Subject - the title of the searcher for easy reference
  • Query - the search query as expected by Reddit. (see this link for modifiers Reddit offers)
  • Status - simple category with "Active" and "Inactive" so we can turn individual searchers on and off
  • After Date - used by the flow to store the last scan date so we don't do double work and overuse our OpenAI credits.
  • Likelihood that this person is ... - will become part of what we ask Chat GPT, eg "looking for a CRM solution".

Reddit Hits Table

The Reddit Hits table has the following fields:

  • Title - title of the Reddit post
  • Actioned - simple category field so we can keep track of which ones we've replied to or decided to ignore
  • Sentiment - a simple calculation that color codes the GPT score
  • SubReddit - the Sub-Reddit the post was found in
  • Searcher - lookup to our Searchers table to link to the Searcher that found the hit
  • URL - URL of the Reddit post so we can look at it
  • Post Body - text content of the post (textarea field)
  • Potential Reply - we may as well get Chat GPT to provide us with a starting point for a reply
  • Created - date and time the post was made
  • GPT Score - score that Chat GPT gives the post regarding the "Likelihood that this person is ..." criteria
  • Reddit ID - a compound ID we'll give each hit to prevent duplicates

Searching Reddit

The main Reddit searching flow will be in the Searchers table.

First, we're going to ask the Reddit API for all search results for our given query.

Then we're going to take just the hits array, and loop through the individual posts.

Next, we're going to look at the post's created date and only continue if it was created after the last logged "After" date.

Next, we're going to calculate a composite ID for the post, search our Reddit Hits table, and only continue if no results were found, thus prevent duplication.

If we got this far, it means we need to save the hit to the table. Next we extract the remaining required field values to make a record.

Then, we'll create the record, and trigger the Chat GPT flow on it (coming up next).

At the very end of the flow, we'll update the searcher with yesterday's date so that future checks won't extend too far into the past.

Scoring with Chat GPT

The flow to get Chat GPT's sentiment on each post will be in the Reddit Hits table because that's where the individual posts are stored.

To prompt GPT correctly, we'll need to collect a fair amount of information.

Firstly, we'll just have a piece of text that describes what we're selling. Naturally you'll need to adjust this to your own products or services.

Then we set the system message.

We'll also initialize some variables - they'll be overwritten later.

Next, we'll loop over the parent Searcher record to get some field values, and construct the actual message we want to feed Chat GPT.

Now we're ready to ask GPT to give us a score on the message.

Because of our prompting, Chat GPT should only reply with a percentage. So we're expecting things like "95%", but we want to convert that to just a number.

If the score is high enough, we'll want GPT to create a potential comment that we can use as a starting block. So we initialize the comment variable, and only continue if the score is higher than 75. There's no point on wasting OpenAI API credits if GPT already determined the poster is likely not looking for what you have to offer.

Now we'll set a NEW system message because it's a different type of task for GPT.

And then we'll construct the message to include. Note this variable includes the "about" variable we created in the beginning that describes our product.

Now we're ready to ask Chat GPT again to create a potential comment that we can post.

And we'll extract the comment body from the JSON payload that we got back.

Lastly, at the very end of the flow, whether or not GPT created a comment, we'll update the Reddit Hits record with the derived score and the comment (if one was asked for).

Running this Setup

Make sure that you're following the Reddit Hits table so that you get notifications when new hits are added.

Then, in the Searchers table, you can create a simple flow to trigger every day at a specific time, and process all searchers.

Closing Thoughts

You now have the automations to regularly search Reddit for new posts matching your search criteria, and having Chat GPT score them and possibly create a comment that you could post.

You might be tempted to have the flow also post the comment in Reddit automatically. We would discourage this. The last thing you want is for your Reddit user to get banned (or worse, shadow banned).

You should always check what any AI thinks and says, and have human user intervention for interacting with the outside world.

 

InfoLobby © 2024 Globi Web Solutions