How do I send a topic id just created?

After creating a topic in a given category, I would like to send its topic ID automatically. How can I do it ?
(My goal is to respond to the topic and I need to know his ID)

1 Like

How are you creating the topic? If you’re using the API, it returns a load with the topic ID.

You might also take a step back and describe your whole problem and not just this solution

4 Likes

I would like to create topics in different ways, for example through a custom wizard. When user end the wizard then I know what is the id of the the created topic via completed wizard. I don’t know how to solve this logically best

If you plan to use the Discourse API for this, the response will give you the ID automatically:

How about leveraging the event system?

eg

But we’re talking about the POST or GET request and to which endpoint ?

Then there will be different answers.

Then that’s what you should be asking about.

So maybe your question is something like “how do I do X with a topic created with the custom Wizard plugin?” I suspect that the answer doesn’t necessarily even involve getting the topic_id.

What do you mean by that ?

I mean that if you describe the actual problem that you are trying to solve rather than a piece of your way of solving it, you might be able to get help. If you are trying to accomplish something with the Custom Wizard plugin, then you should ask how to solve that problem.

I think that every problem can be solved in many ways so I don’t know why I should limit it to this plugin. I guess it is better to find / learn a potentially universal solution?

Hi @silvo,

More than likely you will need to extend class TopicCreator and add a method to “send you” (you will need to define exactly what “send you” means) the topic id of a topic when a new topic is created.

https://github.com/discourse/discourse/blob/master/lib/topic_creator.rb

Note: You could also extend the class(es) which calls the TopicCreator class, but hopefully you get the idea.

Hope this helps.