Reddit PraisonAI Integration

Guide for integrating Reddit search capabilities with PraisonAI agents, including API setup and configuration

python
from praisonaiagents import Agent
from praisonaiagents import reddit_search

agent = Agent(
    name="Reddit Researcher",
    instructions="Search Reddit for community discussions.",
    tools=[reddit_search],
)
agent.start("What are people saying about PraisonAI on Reddit this week?")

The user asks about community sentiment; the agent searches Reddit and summarises top threads.

Diagram

Input

Agent

Tool

Output

Diagram
Reddit PraisonAI IntegrationAgentUserReddit PraisonAI IntegrationAgentUserRequestProcess requestResultResponse

Reddit PraisonAI Integration

bash
export REDDIT_USER_AGENT=[USER]
export REDDIT_CLIENT_SECRET=xxxxxx
export REDDIT_CLIENT_ID=xxxxxx

[USER] in this format script:APP:v1.0(by/u/USERNAME)

bash
pip install praisonai langchain_community praw
bash
export OPENAI_API_KEY="Enter your API key"

Quick Start

  1. Install
    bash
    pip install praisonaiagents praw
    export REDDIT_CLIENT_ID=your_client_id
    export REDDIT_CLIENT_SECRET=your_client_secret
  2. Search Reddit with agent
    python
    from praisonaiagents import Agent
    
    agent = Agent(
        name="RedditAgent",
        instructions="Search Reddit for relevant discussions and insights.",
    )
    
    agent.start("Find the top discussions about Python in the last week")

Code

Single Agent

python
from praisonaiagents import Agent
from langchain_community.tools.reddit_search.tool import RedditSearchRun

agent = Agent(name="RedditSearchAgent",instructions="Search Reddit for information", tools=[RedditSearchRun],)

agent.start("Search Reddit for information about the latest AI advancements in subreddit all")

Multi Agents

python
from praisonaiagents import Agent, Task, AgentTeam
from langchain_community.tools.reddit_search.tool import RedditSearchRun

agent = Agent(name="RedditSearchAgent",instructions="Search Reddit for information", tools=[RedditSearchRun],)

task = Task(description="Search Reddit for information about the latest AI news in subreddit all", agent=agent)

agents = AgentTeam(agents=[agent],tasks=[task])

agents.start()

No Code

tools.py

python
from langchain_community.tools.reddit_search.tool import RedditSearchRun

agents.yaml

yaml
framework: crewai
topic: research about the causes of lung disease
agents:  # Canonical: use 'agents' instead of 'roles'
  research_analyst:
    instructions:  # Canonical: use 'instructions' instead of 'backstory' Experienced in analyzing scientific data related to respiratory health.
    goal: Analyze data on lung diseases
    role: Research Analyst
    tasks:
      data_analysis:
        description: Gather and analyze data on the causes and risk factors of lung
          diseases.
        expected_output: Report detailing key findings on lung disease causes.
    tools:
    - 'RedditSearchRun'

Best Practices

Use read-only scopes for research

When only reading Reddit content, use read-only OAuth scopes to limit permissions.

Respect rate limits

Reddit has rate limits – add delays between requests when processing many posts.

Filter by subreddit

Specify target subreddits in agent instructions for more relevant, focused results.

Check content age

Reddit results can be years old – filter by created_utc when you need recent information.

Related