Is is possible to automatically send a tailored email or message when a topic is marked as Solved ? If so how?
We are trying to use it for marketing and to determine how happy customers are with the solution.
In a support discussion titled ‘How to generate tailored email or message when problem Solved,’ ianm asks whether Discourse can automatically send a customized message when a topic is marked as solved, aiming to use it for marketing and customer satisfaction insights. Canapin responds that no built-in feature exists, but a custom solution is feasible using a webhook triggered by the accepted_solution event. Steps include: (1) creating the webhook via /admin/api/web_hooks/, (2) building a script (e.g., in PHP) to handle the payload, which includes the solution author’s name, username, cooked content, and topic_id, (3) retrieving topic details via /t/[topic_id].json to identify the topic author (via [post_stream][posts][0] or [details][created_by]), and (4) sending a private message via a POST to /posts.json. A video proof of concept is provided, and additional solution data can be found in the [accepted_answer] field of the topic JSON. This approach requires some coding knowledge but is described as fairly straightforward.
Is is possible to automatically send a tailored email or message when a topic is marked as Solved ? If so how?
We are trying to use it for marketing and to determine how happy customers are with the solution.
Hello @ianm!
There’s no built-in solution for this. It would require a plugin or a custom script.
If you know a bit of coding, the later would be fairly easy using a solved event webhook.
The steps would be:
Create the webhook in /admin/api/web_hooks/
Create a script that will receive the webhook. A PHP example can be found here: Use Discourse webhooks with PHP
You’ll need to ensure that the X-Discourse-Event header is set to accepted_solution.
The webhook payload contains informations that can be used for the message you want to send:
name and username: the author of the post marked as solution
cooked: the HTML content of the post marked as solution
topic_id: the topic’s ID ![]()
You can then return the data of /t/[topic_id].json[1].
There are a few ways to get the topic’s author:
[post_stream][posts][0] contains the author’s data: [id],[name], [username], etc.
[details][created_by] will also contain this information.
Do a POST request to /posts.json with the proper payload to send a PM to the topic’s author.
More info about the post POST request: Discourse API Docs
Video proof of concept:
/t/[topic_id].json endpoint also contain solution-related data in [accepted_answer] ↩︎