> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/discourse.md).

# Discourse

Publish, search, and reply to discussions on a Discourse site.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector | Authentication   |
| --------- | ---------------- |
| Discourse | API key or token |

#### Discourse

Connect to a Discourse site to publish, search, and manage discussion posts.

**Set up in Discourse**

1. Prepare the Discourse account or service that the workflow will access. Grant access to the required resources and operations.
2. **API Key:** Create an API key with topics:read\_lists for connection checks and topic lists, topics:write for topics, replies and private messages, search:show for search, and categories:list for the category picker. The acting account must also have permission for the selected content.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Discourse**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field   | Required | What to enter                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Site URL        | Yes      | The HTTPS root URL of the Discourse site, without a path. [Provider instructions](https://docs.discourse.org/).                                                                                                                                                                                                                                                                                                                |
| API Key         | Yes      | Create an API key with topics:read\_lists for connection checks and topic lists, topics:write for topics, replies and private messages, search:show for search, and categories:list for the category picker. The acting account must also have permission for the selected content. [Provider instructions](https://github.com/discourse/discourse/blob/fb7467a27364bca252e34594e7023e4383ce1cdf/app/models/api_key_scope.rb). |
| Acting Username | Yes      | The Discourse account that performs requests with this API key.                                                                                                                                                                                                                                                                                                                                                                |

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **Discourse** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Create Topic

Publish a new topic on the connected Discourse site.

**Inputs**

| Field              | Type            | Required | Description                                                                           |
| ------------------ | --------------- | -------- | ------------------------------------------------------------------------------------- |
| Title              | string          | Yes      | The topic title readers will see.                                                     |
| Content            | textarea        | Yes      | The topic body, with Markdown formatting if useful.                                   |
| Category           | select (string) | No       | Optional category where the topic belongs. Options load from the selected connection. |
| External Reference | string          | No       | Optional unique reference from another system for later lookup.                       |

**Outputs**

| Field         | Type    | Description                                                    |
| ------------- | ------- | -------------------------------------------------------------- |
| Status        | string  | Whether Discourse created the topic or queued it for review.   |
| Post ID       | integer | The created first-post ID when creation completed immediately. |
| Topic ID      | integer | The created topic ID when available.                           |
| Post Number   | integer | The first post's number when available.                        |
| Topic Slug    | string  | The topic's URL slug when available.                           |
| Pending Count | integer | The pending review count when Discourse reports it.            |

#### Reply to Topic

Add a reply to an existing Discourse topic.

**Inputs**

| Field                | Type            | Required | Description                                                               |
| -------------------- | --------------- | -------- | ------------------------------------------------------------------------- |
| Topic                | select (string) | Yes      | The visible topic to reply to. Options load from the selected connection. |
| Reply                | textarea        | Yes      | The reply text, with Markdown formatting if useful.                       |
| Reply to Post Number | integer         | No       | Optional post number within the topic to reply to directly.               |

**Outputs**

| Field         | Type    | Description                                                  |
| ------------- | ------- | ------------------------------------------------------------ |
| Status        | string  | Whether Discourse created the reply or queued it for review. |
| Post ID       | integer | The created post ID when available.                          |
| Topic ID      | integer | The topic ID returned by Discourse when available.           |
| Post Number   | integer | The new reply's number within the topic when available.      |
| Topic Slug    | string  | The topic's URL slug when available.                         |
| Pending Count | integer | The pending review count when Discourse reports it.          |

#### Search Posts

Search public posts visible to the connected Discourse account.

**Inputs**

| Field  | Type    | Required | Description                                                   |
| ------ | ------- | -------- | ------------------------------------------------------------- |
| Query  | string  | Yes      | Words and optional Discourse search filters for public posts. |
| Cursor | integer | No       | Optional next search page returned by a previous call.        |

**Outputs**

| Field       | Type          | Description                                           |
| ----------- | ------------- | ----------------------------------------------------- |
| Posts       | object\_array | A typed list of minimized public post search results. |
| Next Cursor | integer       | The next search page, or no value when results ended. |

#### List Latest Topics

List the latest topics visible to the connected Discourse account.

**Inputs**

| Field           | Type            | Required | Description                                                                                                                                             |
| --------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Cursor          | integer         | No       | Latest-topics page to fetch, starting at 0. Minimum: 0.                                                                                                 |
| Topics Per Page | integer         | No       | Exact maximum number of topics to return in this page. Minimum: 1. Maximum: 100.                                                                        |
| Order           | select (string) | No       | How Discourse should order the topic list. Available values: Default, Created, Activity, Views, Posts, Category, Likes, Original Poster Likes, Posters. |
| Ascending       | boolean         | No       | Sort in ascending order instead of Discourse's descending default. Default: false.                                                                      |

**Outputs**

| Field       | Type          | Description                                                  |
| ----------- | ------------- | ------------------------------------------------------------ |
| Topics      | object\_array | A typed list of visible topic summaries.                     |
| Next Cursor | integer       | The next latest-topics page, or no value when results ended. |

#### Send Private Message

Send a private Discourse message without exposing its content in the result.

**Inputs**

| Field      | Type     | Required | Description                                                     |
| ---------- | -------- | -------- | --------------------------------------------------------------- |
| Recipients | string   | Yes      | Comma-separated Discourse usernames or messageable group names. |
| Subject    | string   | Yes      | The private message subject.                                    |
| Message    | textarea | Yes      | The private message body, with Markdown formatting if useful.   |

**Outputs**

| Field         | Type    | Description                                                       |
| ------------- | ------- | ----------------------------------------------------------------- |
| Status        | string  | Whether Discourse created the message or queued it for review.    |
| Post ID       | integer | The created first-post ID when creation completed immediately.    |
| Topic ID      | integer | The private message topic ID when creation completed immediately. |
| Post Number   | integer | The first post's number when creation completed immediately.      |
| Pending Count | integer | The pending review count when Discourse reports it.               |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/discourse.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
