Skip to main content

Crafting Your Brand Monitor Bot with BotFleet - A Reddit Keyword Tracker

· 3 min read
Bakar Tavadze

Crafting Your Brand Monitor Bot with BotFleet: A Reddit Keyword Tracker

Ever wondered what the world is saying about your brand or a topic you're deeply interested in? With the vast ocean of conversations happening on Reddit, there's a goldmine of insights just waiting to be unearthed. But who has the time to sift through countless posts manually? That's where BotFleet, comes in! Today, we're building a bot that does the heavy lifting for us, monitoring Reddit for specific keywords related to our brand or topic of interest. Let's dive in!

The Plan of Attack

Our mission is simple: create a bot that scans Reddit posts for mentions of our chosen keywords and saves those insights. This bot is perfect for brand managers, marketers, or curious cats who want to keep a pulse on specific topics without constantly refreshing Reddit pages.

Toolkit Assembly

Before we start crafting our bot, make sure you're equipped with:

  1. A BotFleet account, for deploying our bot.
  2. Basic Python skills, to converse with our bot in its native tongue.
  3. A Reddit account and an API key, because we'll be using Reddit's API to search for posts.

The Blueprint

Here's the game plan for our Python script. We'll use Reddit's API to search for recent posts containing our specified keywords, then save any hits for our review. Here's a straightforward version to get us started:

import praw
import os
from datetime import datetime

# Reddit API credentials
client_id = 'your_client_id'
client_secret = os.environ['CLIENT_SECRET']
user_agent = 'brand_monitor_bot'

# Keywords and subreddit to search
keywords = ['brandName', 'anotherKeyword']
subreddit = 'all' # or specify like 'technology', 'gadgets' etc.

def search_reddit(store):
reddit = praw.Reddit(client_id=client_id, client_secret=client_secret, user_agent=user_agent)

for keyword in keywords:
for submission in reddit.subreddit(subreddit).search(keyword, limit=10):
# Simplified data capture: title, url, and timestamp
post_info = {
'title': submission.title,
'url': submission.url,
'timestamp': datetime.fromtimestamp(submission.created_utc).strftime('%Y-%m-%d %H:%M:%S')
}
store[datetime.now().isoformat()] = post_info
print(f"Found post for '{keyword}': {submission.title}")

def main(request, store)
search_reddit(store)

Analyzing the Script

We're using the Python Reddit API Wrapper (PRAW) to make our calls to Reddit. It's a handy tool that simplifies interacting with Reddit's API. search_reddit function: This function does the legwork, searching for our keywords in specified subreddits and saving the findings.

Setting Up the Bot on BotFleet

Head over to BotFleet and go to the bots section. Name it something memorable, like "BrandSpy".

Indicating script

Copy the Python script we just wrote into the script section.

Indicating requirements

We're using the praw library. Let's add this to our requirements:

praw

Indicating environment variables

Set CLIENT_SECRET as an environment variable:

CLIENT_SECRET=your_client_secret

Schedule It

Set your bot to run every hour. You can use the following cron expression to run your bot every hour:

0 * * * *

Going Beyond

Now that you've set your BrandSpy bot loose on Reddit, think about the next steps. Maybe you want to extend the bot's capabilities to analyze sentiment, compile weekly summary reports, or even alert you in real-time for specific trigger words.

Wrapping It Up

Congratulations, you're now the operator of a brand monitoring bot that keeps an eye on Reddit for you. No more FOMO on what the internet is saying about your favorite topics or brand. Sit back, relax, and let BotFleet and your bot do the stalking... or, monitoring.

Got an epic idea for a bot or a question about tweaking this one? Reach out.