DEV Community

Cover image for Building a Discourse bot: API keys, signed webhooks, and rate limits

Building a Discourse bot: API keys, signed webhooks, and rate limits

Nathan Tarbert on November 30, 2026

I work on answerLoops, an open-source tool that answers community support questions, and one of our channels is Discourse. Getting the Discourse si...
Collapse
 
dafili profile image
Renhua Wei •

Webhooks make this mostly a non-issue" is the line I'd push back on: the 50-per-10-seconds per-IP row is what actually fires, and a hot thread with 40 replies queues 40 POSTs in about 3 seconds whether or not you're event-driven. Delivery is at-least-once, so a timed-out POST comes back and you answer the same post twice unless you dedupe on (post_id, post_number) before the call. Token bucket at 5/s burst 50, and drop the low-value replies instead of queueing them.

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Hey @dafili, I really appreciate the thoughtful feedback. You're right that eliminating polling doesn't eliminate outbound rate limits, and it prompted me to dig into it deeper.

We already deduplicate incoming webhook events using the Discourse post ID, and subsequent replies in tracked conversations don't automatically trigger another AI response. However, there's still room to improve outbound rate limiting and how we handle uncertain delivery outcomes.

I've opened an issue to address those concerns:

github.com/answerLoops/answerLoops...

I've kept the scope focused on outbound rate limiting and safe retry behavior while preserving the conversation context.

I'd love to get your perspective on the proposed approach. This is one of the things I appreciate most about open source. Having people challenge assumptions and bring different engineering perspectives makes the project better.

Collapse
 
dafili profile image
Renhua Wei •

On the safe-retry issue, the hard part is the timeout that actually landed: at-least-once means your POST can commit on their side and still fail on yours, so a blind retry double-posts. Keep an outbound send-log keyed on (post_id, post_number) with sent_at/confirmed_at, mark it in-flight on any timeout, then reconcile by reading the thread tail before re-sending -- only rows where the reply is genuinely absent get retried. And treat Retry-After as a floor, not a fixed backoff.

Thread Thread
 
nathan_tarbert profile image
Nathan Tarbert •

That makes a lot of sense, Renhua. A timeout tells us that we didn't receive confirmation, not that the operation failed.

I particularly like the outbound send-log approach and reconciling the delivery state before attempting another POST. I'd also want to account for concurrent replies and delayed commits so that the absence of a matching reply doesn't automatically trigger another send.

Good point about Retry-After being a floor rather than a fixed backoff, too.

I've updated the issue to incorporate these considerations: github.com/answerLoops/answerLoops...

I really appreciate you taking the time to dig into this further!

Collapse
 
paullovelace profile image
Paul Lovelace •

The bot-answering-itself loop is the mistake I'd have made first — your own reply firing the post webhook is so obvious in hindsight and so easy to miss while you're wiring it up. The confidence gate is the part I'd actually steal though: knowing when not to answer is the whole job for a support bot. How do you set that threshold in practice — fixed score, or does it move with how busy the human queue is?

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Hey Paul, I really appreciate that! I completely agree that knowing when not to answer is just as important as knowing how to answer.

We use a configurable confidence threshold that is set in the platform. A separate read only AI agent evaluates the generated answer against the available knowledge sources, assessing both how well-supported the answer is and whether it fully addresses the question.

The threshold doesn't dynamically adjust based on the human queue. I'd be hesitant to lower the quality bar simply because the support team is busy. That could ultimately create more work and erode community trust.

I'd recommend starting with human approval enabled, reviewing the quality of the answers, and adjusting the threshold as you build trust in the system.

Your point about queue volume is interesting, though. How would you approach that without compromising answer quality?

Collapse
 
jal_c_68347 profile image
Jalissia_C •

Can I control which parts of my Discourse community the bot monitors?

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Hi Jalissia, you can choose specific categories or monitor the entire forum. For example, you might want AI-assisted answers in your technical support category while leaving general discussions entirely human-led. Every community operates differently, so having that flexibility is important.

Collapse
 
johnywalker21 profile image
johny walker •

Thanks for this answer. I actually had the same question.

Collapse
 
danny_9746 profile image
Danny T •

How do you prevent the bot from responding to every message in a discussion?

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Hi Danny, once a conversation is being tracked, subsequent replies are added to the existing ticket without automatically generating another AI response. Your team retains the context and can decide when further assistance is needed. Nobody wants a bot interrupting a productive conversation between community members :)

Collapse
 
johnsnow221 profile image
ethan_snow •

Can the bot pull answers from our existing documentation and previous community conversations? Is this specific to Discourse, or does it apply to other communities?

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Yes, answerLoops uses your connected knowledge sources and relevant, previously resolved tickets to generate answers.

One of the benefits is that knowledge your team has already shared can continue helping other community members, rather than requiring someone to answer the same question repeatedly.

This process works across the other communities that are supported, such as Discord, Slack, Circle, etc.

Collapse
 
hajusef_908 profile image
Hajeem Usef •

Great article. Our community is hosted in Discourse and this looks like it would be really helpful.

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Thanks Hajeem, I'm curious if your community is technical or non-technical.

Do you have frequent questions that keep coming back up?

Collapse
 
cameran-755 profile image
Cameran •

What happens if someone asks a follow-up question in the same Discourse thread? Does the bot try to answer again?

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Currently, follow-up messages are added to the existing ticket without triggering another automatic AI response. We wanted to avoid a situation where the bot keeps jumping into an ongoing conversation. The team retains the conversation context and can decide how best to respond.

Collapse
 
dawoodkarim profile image
dawoodkarim •

What happens if someone reports a bug that isn't covered in the documentation?