# How to generate tailored email or message when problem Solved

**URL:** https://meta.discourse.org/t/how-to-generate-tailored-email-or-message-when-problem-solved/263630
**Category:** Support
**Created:** [May 3, 2023, 2:18am UTC](https://meta.discourse.org/t/how-to-generate-tailored-email-or-message-when-problem-solved/263630 "2023-05-03T02:18:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ianm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ianm/32/200859_2.png) [@ianm](https://meta.discourse.org/u/ianm)
#### Post date: [May 3, 2023, 2:18am UTC](https://meta.discourse.org/t/how-to-generate-tailored-email-or-message-when-problem-solved/263630/1 "2023-05-03T02:18:54Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [May 16, 2023, 10:23am UTC](https://meta.discourse.org/t/how-to-generate-tailored-email-or-message-when-problem-solved/263630/3 "2023-05-16T10:23:01Z")

</div>

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:

1. Create the webhook in `/admin/api/web_hooks/`

2. Create a script that will receive the webhook. A PHP example can be found here: [Use Discourse webhooks with PHP](https://meta.discourse.org/t/use-discourse-webhooks-with-php/50543)  
You’ll need to ensure that the `X-Discourse-Event` header is set to `accepted_solution`.

3. 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 🙃

4. You can then return the data of `/t/[topic_id].json`\[1\].  
There are a few ways to get the topic’s author:

5. 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](https://docs.discourse.org/#tag/Posts/operation/createTopicPostPM)

Video proof of concept:

[https://global.discourse-cdn.com/meta/original/4X/2/6/5/2654e59f377c53e7d4f207e874e38722c01a9e4e.mp4](https://global.discourse-cdn.com/meta/original/4X/2/6/5/2654e59f377c53e7d4f207e874e38722c01a9e4e.mp4)

* * *

1. `/t/[topic_id].json` endpoint also contain solution-related data in `[accepted_answer]`
