You could do something like this in your button’s action:
const { CREATE_TOPIC, DRAFT } = require('discourse/models/composer').default;
composer = Discourse.__container__.lookup('controller:composer');
composer.open({
action: CREATE_TOPIC,
draftKey: DRAFT,
title: "Pre-filled topic title!",
topicBody: "Pre-filled topic body goes here"
});
You can pass additional data to the composer’s open() method such as tags, category ID, target usernames if you’re sending a message and so on. There are a lot of clues in this file: