# Discourse Chatbot 🤖

**URL:** https://meta.discourse.org/t/discourse-chatbot/256652
**Category:** Plugin
**Tags:** ai
**Created:** [March 1, 2023, 11:08am UTC](https://meta.discourse.org/t/discourse-chatbot/256652 "2023-03-01T11:08:25Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [March 1, 2023, 11:08am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/1 "2023-03-01T11:08:25Z")

</div>

| | | |
| --- | --- | --- |
| ℹ | **Summary** | The Original AI Chatbot for Discourse |
| 🛠 | **Repository Link** | [GitHub - merefield/discourse-chatbot: An AI bot with RAG capability for Topics, Chat & Customer Support in Discourse, currently powered by OpenAI · GitHub](https://github.com/merefield/discourse-chatbot) |
| 📖 | **Install Guide** | [How to install plugins in Discourse](https://meta.discourse.org/t/install-plugins-in-discourse/19157) |
| ❤ | **Sponsorship** | Please consider becoming an ongoing [sponsor of my open source work](https://github.com/sponsors/merefield) at a level that suits your or your organisation’s resources and needs to ensure this plugin gets the maintenance it deserves and continues to work for your site in the future. |

Enjoying this plugin? Please ⭐ it on [GitHub](https://github.com/merefield/discourse-chatbot)! 🙏

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/c/a/3ca63c806443af80e72bf1fe04d96b4b8cd09006.jpeg)

> ℹ As this is an independently contributed plugin, please make support, bug, ux, and feature requests here in this topic. NB This plugin is _not_ available on [Discourse.org](http://Discourse.org) hosting. You can install it if you are self-hosted and possibly if you are on third party hosting (but check with your provider).

# The original AI Chatbot for Discourse

Chatbot brings configurable AI conversations to Topics, Personal Messages, Chat channels, and Chat threads. Give the bot a character that suits your community, decide which groups may use it, and choose different models and tools for low-, medium-, and high-trust users.

It can:

- answer normally from the current conversation;
- search selected forum content with semantic or hybrid search;
- search Wikipedia, current news, and the web;
- crawl remote pages and retrieve end-of-day market data;
- perform reliable expression-based calculations;
- see uploaded images and optionally read PDFs;
- generate and edit images;
- collect outstanding editable User Fields in private conversations;
- escalate private Chat conversations to configured staff groups;
- respond automatically to new Topics in selected Categories; and
- accept additional tools supplied by other plugins.

For a practical support workflow, see [Building a technical support chatbot](https://meta.discourse.org/t/building-a-technical-support-chatbot/319825).

With local forum search enabled, the bot can ground answers in your community’s content:

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/6/7/167d67f013933fcebb8806c6a634bca4b541dc67.png)

For simpler conversations, expose fewer or no tools to reduce calls, latency, and cost:

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/b/6/2b62ec5fa27b52a0cb49cb14ed900650cf9d6021.png)

## Provider support

Choose providers independently for replies, embeddings, vision, and image generation. Each capability reuses the API key belonging to its selected provider.

| Capability | OpenAI | Anthropic | Google Gemini | xAI |
| --- | --- | --- | --- | --- |
| LLM replies and tools | ✅ | ✅ | ✅ | ✅ |
| Embeddings | ✅ | — | ✅ | ✅ |
| Vision | ✅ | ✅ | ✅ | ✅ |
| Image generation | ✅ | — | ✅ | ✅ |
| Image editing | GPT Image models | — | — | ✅ |
| PDF conversation input | ✅ | — | — | — |

If no custom URL is set, Chatbot uses its built-in official endpoint for the selected provider. Custom model names and URLs support Azure OpenAI, Ollama, proxies, and other services that implement a supported provider’s API shape.

Provider-specific model dropdowns are shown only when that provider is active. The reply model can differ by trust level, while embeddings, vision, and image generation each have their own provider and model selector.

[Read the full provider and custom-endpoint guide](https://github.com/merefield/discourse-chatbot#model-providers).

## Access, quotas, and tools

Nobody has access until you assign groups to Chatbot’s low-, medium-, or high-trust group settings. Users inherit the quota, model, and tool allowlist of their highest matching Chatbot trust level. Quotas can be measured by queries or tokens.

Built-in tools are selected independently for each trust level. Credentials and supporting settings still control runtime availability, so selecting a web tool without its API key does not expose it.

Read about [access and quotas](https://github.com/merefield/discourse-chatbot#access-and-quotas) and [trust-level tools](https://github.com/merefield/discourse-chatbot#tools-by-trust-level).

## Local forum search and privacy

☣ **Please understand the embedding scope before enabling local forum search.**

The default `benchmark_user` strategy embeds content visible to a suitable user at the configured trust level. The `categories` strategy embeds content from explicitly selected Categories. Semantic search is optimised for speed and does not repeat a visibility check for every person asking the bot, so matching content may be shared outside its original audience if the scope includes restricted content.

Private Messages are never embedded. Keep the benchmark trust level low, avoid private Categories unless their contents may be disclosed to every Chatbot user, and remove `local_forum_search` from trust levels that should not use it.

The selected providers may receive conversation content, uploads, embedded search matches, and tool results. Review their retention and data-use terms, and disclose this processing in your forum’s terms and privacy notice.

[Read the full embeddings, scope, and privacy guide](https://github.com/merefield/discourse-chatbot#creating-the-embeddings).

## Quick start

1. Install the plugin using the normal self-hosted plugin procedure.
2. Select `chatbot_llm_provider`, enter that provider’s API key, and choose models for each trust level.
3. Add groups to the low-, medium-, or high-trust access settings and configure quotas.
4. Choose the built-in tools available to each trust level.
5. If you enable `local_forum_search`, configure its embedding provider and carefully review its scope.
6. Mention the bot, reply to it, use the quick-access button, or configure a Category auto-response prompt.

### Quick OpenAI example

1. Create an [OpenAI API key](https://platform.openai.com/api-keys) and ensure API billing is enabled.
2. Set `chatbot_llm_provider` to OpenAI and paste the key into `chatbot_open_ai_token`.
3. Leave the custom URL blank, choose an OpenAI model for each trust level you intend to use, and add your test group to the matching Chatbot access setting.
4. Mention the bot in an allowed Topic, Personal Message, or Chat to test it.

The repository README is the source of truth for prerequisites, every major setting group, provider-specific behavior, custom endpoints, embedding maintenance, prompt customization, debugging, extension development, and uninstalling:

📚 **[Open the complete README](https://github.com/merefield/discourse-chatbot#readme)**

## Selected UI features

Categories can welcome a new Topic and ask the bot to search for relevant community content:

 ![Category auto-response configuration](https://global.discourse-cdn.com/meta/original/4X/b/3/0/b3030a8dd199c219c761e32afadbb5a42e1d0f97.png)

The optional quick-access button can open a direct Chat or Personal Message with the bot:

 ![Quick-access Chatbot button](https://global.discourse-cdn.com/meta/original/4X/3/3/2/3323f98fc56f2aa4002d65d4b7a437a5a7d239ed.png)

The User Fields tool can collect supported empty fields privately:

![User Fields collection](https://global.discourse-cdn.com/meta/original/4X/1/6/8/168a778c187b0183f1eb19475dd3a7422476497d.png)

## Support and sponsorship

Please report support requests, bugs, UX feedback, and feature ideas in this Meta topic. Include the provider, model name, relevant settings, HTTP status and provider response body, while removing API keys and private content.

This work depends on community support. If the plugin is valuable to your site, please [sponsor its ongoing maintenance](https://github.com/sponsors/merefield).

## Project sponsors

| Sponsor | Level | Website |
| --- | --- | --- |
| Surety | Silver Plus | [suretyhome.com](https://suretyhome.com/) |

## Disclaimer

LLMs can produce convincing but incorrect output. Test the plugin against your community’s needs, understand the privacy and cost implications, and apply appropriate moderation. Generated-output terms differ by provider and jurisdiction; review the terms for every provider you enable.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 12, 2024, 4:31pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/904 "2024-08-12T16:31:46Z")

</div>

I added Jina.ai to the list of supported API’s which can be used for web search and web crawling. One key serves both services. Existing API’s are used if you do not remove their keys.

> <https://github.com/merefield/discourse-chatbot/pull/115>

There were two main reasons:

- crawling performance seems really good
- they offer a pay as you go model as opposed to a monthly fee which suits me and may suit you.

Link in settings.

> **[Jina AI - Your Search Foundation, Supercharged.](https://jina.ai)**
>
> Best-in-class embeddings, rerankers, web reader, deepsearch, small language models. Search AI for multilingual and multimodal data.

 ![This image is a screenshot of a Twitter conversation discussing the challenges involved in creating electronics that use graphene. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/3/8/e/38e43ca98aba1bfbda09733b67a11375cc671db5.png)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 16, 2024, 10:10am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/906 "2024-08-16T10:10:21Z")

</div>

Hey thanks for your interest in [Discourse Chatbot](https://meta.discourse.org/t/discourse-chatbot/256652).

Two things may be relevant:

- the bot will Reply to every Post if invoked in a Topic with only a single User until more people join the Topic
- Per Category, you can get Chatbot to Reply to every new Topic and you can give it special instructions on what to do, governed by a Category specific prompt that you set up in the Category settings.

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/3/0/b3030a8dd199c219c761e32afadbb5a42e1d0f97.png)

the bot will always be invoked if you @ mention it so I don’t know if you can utilise that feature too.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 16, 2024, 10:25am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/908 "2024-08-16T10:25:45Z")

</div>

> [@Festinger](#):
>
> We have a second private support category where the AI chatbot should reply to ‘every’ post without being mentioned. The AI chatbot should be triggered by a keyword.

‘every’ post? Or only those with a keyword? Are those two different requirements?

> [@Discourse AI - AI triage](https://meta.discourse.org/t/discourse-ai-ai-triage/281227/1):
>
> **Automated Responses:** The post classifier can generate replies to posts using predefined responses. This is useful for addressing frequently asked questions or common queries, sending spam to junk categories, and more.

Perhaps you could mention Chatbot in the predefined response and the bot will follow up? That would mean two Posts but might work.

So if your predefined response was “@Chatbot (or whatever you’ve renamed it to) please handle this” then Chatbot would follow up. Obviously you can tailor that response.

Note Chatbot can respond to whispers too (if you configure it so), so if the predefined response was in a whisper then normal users would only see the Chatbot response which might look neater.

I’m open to extending the capability of Chatbot if you wish to hire me to do so, so long as we can come up with a sufficiently generic solution that would be useful to others, but it makes sense to leverage what exists I think?

I wonder if the best action here is to add a Whisper capability to the AI Post Classifier? You could hire someone to PR that or raise it as a #Contribute > Feature and hope it gets prioritised. That would undoubtedly be genericly useful?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 21, 2024, 6:40am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/909 "2024-08-21T06:40:49Z")

</div>

I made some code simplifications by making use of a feature that was added to the Open AI API. Let me know if you encounter any issues.

[https://github.com/merefield/discourse-chatbot/pull/116](https://github.com/merefield/discourse-chatbot/pull/116)

I decided it was time to call this 1.0.0 🍾 🎉 🥳

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 27, 2024, 6:16pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/910 "2024-08-27T18:16:33Z")

</div>

Added the ability to add other functions in separate plugins, so you don’t have to maintain a fork of the Chatbot repo.

Example function plugin here:

[https://github.com/merefield/discourse-chatbot-function-extension-example](https://github.com/merefield/discourse-chatbot-function-extension-example)

but of course you could add this to any plugin …

PR:

[https://github.com/merefield/discourse-chatbot/pull/117](https://github.com/merefield/discourse-chatbot/pull/117)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 28, 2024, 8:10am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/911 "2024-08-28T08:10:26Z")

</div>

@Festinger did you solve this?

---

<div class="post-metadata">

### Author: ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)
#### Post date: [August 30, 2024, 11:31am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/912 "2024-08-30T11:31:35Z")

</div>

> Post Embedding: There was a problem, but will retry til limit: undefined method `destroy!’ for nil

After the last update, I started getting the above error. I get this error especially when it comes to images. My vision mode setting is: directly. I wasn’t getting such an error before.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 30, 2024, 11:33am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/913 "2024-08-30T11:33:58Z")

</div>

Do you recall deleting a Post (or Topic) shortly after creating one?

This error will occur if you create a Post then delete it before it has chance to create an embedding, so when you delete it, Chatbot tries to delete a non-existent embedding which creates an annoying log message but does not harm 😉

If you can think of a better way of doing that, feel free to PR.

---

<div class="post-metadata">

### Author: ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)
#### Post date: [August 30, 2024, 11:36am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/914 "2024-08-30T11:36:48Z")

</div>

It gave an error like this in the issue sent by the user. It wasn’t something I deleted.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 30, 2024, 11:40am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/915 "2024-08-30T11:40:14Z")

</div>

> [@ozkn](#):
>
> Post Embedding: There was a problem, but will retry til limit: undefined method `destroy!’ for nil

How did the user see this? This is only in logs?

---

<div class="post-metadata">

### Author: ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)
#### Post date: [August 30, 2024, 11:45am UTC](https://meta.discourse.org/t/discourse-chatbot/256652/916 "2024-08-30T11:45:27Z")

</div>

I saw it in the logs. I’ve been following it for a day, especially the problem occurs in the posts of users who have been members for a long time. If a new member opens a topic with a picture, there is usually no problem, no error is received. When old users open a topic with a picture, there is a problem.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 30, 2024, 12:05pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/917 "2024-08-30T12:05:09Z")

</div>

Can you please share the backtrace?

> [@ozkn](#):
>
> I saw it in the logs.

Then why did the user send you an issue? What did they tell you? The user should not be aware of any issue, it just shows up in the logs?

Sounds like your “old members” might be deleting their recently new topic or post (as they know how to do this) ?

Do you have any automation of any kind in place?

There is no destruction during posting of a post containing a picture, so I’m not sure how that could happen.

Update: I just uploaded an image to a site and cannot repro.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [August 30, 2024, 1:54pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/918 "2024-08-30T13:54:29Z")

</div>

SerpAPI is ok, and theirs statistic shows that request to use Google is done, but Chatbot claims it can’t use Google. That situations has been on for longer time, but I didn’t react because at the moment DAI didn’t want to use Google either.

No error messages.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 30, 2024, 1:55pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/919 "2024-08-30T13:55:32Z")

</div>

What happens if you say “search the web for …”?

The internal prompt is generic so doesn’t assume Google …

Let me show you a very good demo of this powerful capability:

> **[Star Wars Outlaws impressions](https://www.starzen.space/t/star-wars-outlaws-impressions/20395)**
>
> @StarZenBot, from searching the web, what are the reviews of star wars outlaws saying in summary? Include links to sources.

(although this is using the bundled alternative `jina.ai`)

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [August 30, 2024, 2:11pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/920 "2024-08-30T14:11:17Z")

</div>

I tried that. The system prompt had ”when an user asks seaching using Google user actually means you should use that web seaching function you had access to”. I deleted that part and then tried web search wording in my user prompt — after all, it isn’t using API by Google. No luck and similar answer: I can’t do web search…

This is only I found, but it doesn’t open this:

```plaintext
{
  "id": "chatcmpl-A1wT9Dp1fCIVSzRsVPhr3NnNCcPjW",
  "object": "chat.completion",
  "created": 1725026447,
  "model": "gpt-4o-2024-05-13",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_MvzexRPsDj6EGuXhuiFcmtrd",
            "type": "function",
            "function": {
              "name": "web_search",
              "arguments": "{\"query\":\"International Dog Day date, reason, and history\"}"
            }
          }
        ],
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1203,
    "completion_tokens": 20,
    "total_tokens": 1223
  },
  "system_fingerprint": "fp_157b3831f5"
}

```

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [August 30, 2024, 2:15pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/921 "2024-08-30T14:15:33Z")

</div>

I can live without that because my target is using Chatbot as an internal Q/A-bot, and Jina may solve out the issue of using my maincontent site (by WordPress).

But the result when I tried searching from outside world wasn’t expected.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 30, 2024, 2:15pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/922 "2024-08-30T14:15:38Z")

</div>

I’ll see if I can repro

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 30, 2024, 2:42pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/923 "2024-08-30T14:42:15Z")

</div>

It’s working for me either via Serp API or Jina.ai.

Can you provide the bots “inner thoughts” from the PM please?

> **Inner Thoughts**
>
> ```json
> [
> {
> "role": "assistant",
> "content": "",
> "tool_calls": [
> {
> "id": "call_mKY7pfG54xRduRKCz5xee9E0",
> "type": "function",
> "function": {
> "name": "web_search",
> "arguments": "{\"query\":\"list of English butterflies\"}"
> }
> }
> ]
> },
> {
> "role": "tool",
> "tool_call_id": "call_mKY7pfG54xRduRKCz5xee9E0",
> "content": "A-Z of butterflies · A. Adonis Blue · B Black Hairstreak · Brimstone · Brown Argus · Brown Hairstreak · C Chalk Hill Blue · Chequered Skipper · Clouded Yellow · D."
> }
> ]
> 
> ```

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [August 30, 2024, 2:50pm UTC](https://meta.discourse.org/t/discourse-chatbot/256652/924 "2024-08-30T14:50:11Z")

</div>

Should we do this using PM? We are now just polluting this topic.

But:

```plaintext
[
  {
    "role": "assistant",
    "content": "",
    "tool_calls": [
      {
        "id": "call_4xitHqRBJ8Wc1HI546r3Wj1U",
        "type": "function",
        "function": {
          "name": "web_search",
          "arguments": "{\"query\":\"International Dog Day date and history\"}"
        }
      }
    ]
  },
  {
    "role": "tool",
    "tool_call_id": "call_4xitHqRBJ8Wc1HI546r3Wj1U",
    "content": "International Dog Day date and history: my search for this on the internet failed."
  }
]

```

[Next page](https://meta.discourse.org/t/discourse-chatbot/256652.md?page=2)
