# Reddit

{% hint style="info" %}
The following documentation is for **Reddit v1.0.2** *(BDK)*.
{% endhint %}

## Overview

Reddit is a vast social media platform where communities discuss topics through posts and comments. This integration allows automated content posting, comment monitoring, subreddit management, and community engagement activities. Enhance social media presence and automate Reddit community management.

## Prerequisites

### 1. Required Books

The following Book(s) need to be added to your agent so it can learn and understand the automation procedures defined within them:

* **Reddit**

#### How to Add the Book(s)

1. Go to **Books** → **All Books**.
2. Search for the name of the book and click on it.
3. Click on <kbd>**Install**</kbd> or <kbd>**Add Connection**</kbd> to add the book to your agent.
4. If adding a connection, you'll be prompted for [**connectivity**](#connectivity) details.

## Connectivity

This section outlines the available methods for connecting to the Book, along with the required configuration details for each.

### Connect using Client ID and Client Secret

Connects to Reddit API using client credentials.

| Label         | Description                                   | Type        |
| ------------- | --------------------------------------------- | ----------- |
| Client ID     | The client ID for your Reddit application     | `text`      |
| Client Secret | The client secret for your Reddit application | `sensitive` |

## Procedures

### to get a (*subreddit*'s latest posts)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Gets the latest (newest) post from a specified subreddit.

**Input Concepts**

| Concept                          | Description                        | Type               | Required | Default Value |
| -------------------------------- | ---------------------------------- | ------------------ | -------- | ------------- |
| [`subreddit`](#reddit-subreddit) | The subreddit to get the post from | `reddit subreddit` | Yes      | (no default)  |

**Output Concepts**

| Concept                                    | Description                       | Type          |
| ------------------------------------------ | --------------------------------- | ------------- |
| [`subreddit's latest posts`](#reddit-post) | A list of the latest reddit posts | `reddit post` |

**Examples**

Get the latest 10 posts from the 'announcements' subreddit.

```generic
get the subreddit's latest posts with
    the limit is 10
```

### to get a (*subreddit*'s top posts)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Gets the top posts from a specified subreddit.

**Input Concepts**

| Concept                          | Description                         | Type               | Required | Default Value |
| -------------------------------- | ----------------------------------- | ------------------ | -------- | ------------- |
| [`subreddit`](#reddit-subreddit) | The subreddit to get the posts from | `reddit subreddit` | Yes      | (no default)  |

**Output Concepts**

| Concept                                 | Description                   | Type          |
| --------------------------------------- | ----------------------------- | ------------- |
| [`subreddit's top posts`](#reddit-post) | A list of RedditPost concepts | `reddit post` |

**Examples**

Get the top 10 posts from the 'announcements' subreddit.

```generic
get the subreddit's top posts with
    the limit is 10
```

### to get a (*subreddit*)

Gets information about a subreddit.

**Input Concepts**

| Concept | Description                                       | Type   | Required | Default Value |
| ------- | ------------------------------------------------- | ------ | -------- | ------------- |
| `name`  | The name of the subreddit (without the r/ prefix) | `text` | Yes      | (no default)  |

**Output Concepts**

| Concept                          | Description                                              | Type               |
| -------------------------------- | -------------------------------------------------------- | ------------------ |
| [`subreddit`](#reddit-subreddit) | A Subreddit concept with information about the subreddit | `reddit subreddit` |

**Examples**

Get the 'announcements' subreddit. the name is "announcements"

```generic
get a subreddit with
```

### to get some (*subreddit*'s posts)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Gets a Reddit post by its ID.

**Input Concepts**

| Concept                          | Description                        | Type               | Required | Default Value |
| -------------------------------- | ---------------------------------- | ------------------ | -------- | ------------- |
| [`subreddit`](#reddit-subreddit) | The subreddit to get the post from | `reddit subreddit` | Yes      | (no default)  |

**Output Concepts**

| Concept                             | Description                                               | Type          |
| ----------------------------------- | --------------------------------------------------------- | ------------- |
| [`subreddit's posts`](#reddit-post) | A list of reddit posts matching the filters (if provided) | `reddit post` |

**Examples**

Get 10 posts from the 'announcements' subreddit.

```generic
get the subreddit's reddit posts whose title has "kognitos" with
    the limit is 10
```

## Concepts

### Reddit subreddit

A subreddit in Reddit.

| Field Name           | Description                                        | Type             |
| -------------------- | -------------------------------------------------- | ---------------- |
| `id`                 | The unique ID of the subreddit.                    | `text`           |
| `name`               | The name of the subreddit (without the r/ prefix). | `text`           |
| `title`              | The title of the subreddit.                        | `text`           |
| `description`        | The description of the subreddit.                  | `text`           |
| `subscribers`        | The number of subscribers to the subreddit.        | `number`         |
| `created_on`         | The datetime when the subreddit was created.       | `datetime`       |
| `url`                | The URL of the subreddit.                          | `text`           |
| `public_description` | The public description of the subreddit.           | `optional[text]` |

### Reddit post

A post (submission) on Reddit.

| Field Name        | Description                                                  | Type             |
| ----------------- | ------------------------------------------------------------ | ---------------- |
| `id`              | The unique ID of the post.                                   | `text`           |
| `title`           | The title of the post.                                       | `text`           |
| `author`          | The username of the post author.                             | `text`           |
| `subreddit`       | The name of the subreddit the post was submitted to.         | `text`           |
| `created_on`      | The datetime when the post was created.                      | `datetime`       |
| `url`             | The URL of the post content (may be external or Reddit URL). | `text`           |
| `permalink`       | The permanent Reddit URL for the post.                       | `text`           |
| `score`           | The net score (upvotes - downvotes) of the post.             | `number`         |
| `upvote_ratio`    | The ratio of upvotes to downvotes.                           | `number`         |
| `num_comments`    | The number of comments on the post.                          | `number`         |
| `is_video`        | Whether the post contains a video.                           | `boolean`        |
| `text`            | The text content of the post (if it's a self post).          | `optional[text]` |
| `link_flair_text` | The flair text for the post.                                 | `optional[text]` |
