I want to create a mqtt node subscibe with custom topic that (I set up from another node that has function to add that node)
MQTT-in nodes do not support dynamically settings the topic.
You have a few options
Set the topic in the MQTT-in node to a wildcard e.g. #
and then use a switch node to filter incoming messages based on a comparing the topic of the incoming message to a context variable. If you have a high volume of messages this might cause performance problems
Set the topic with an environment variable. You can use the ${ENV_VAR_NAME}
to set configuration values at flow deployment time. This would mean knowing what topic you need before starting Node-RED
Use the Node-RED Admin API to edit the current flow. While this is closest to the question you have asked, this is a very complex solution as it means crafting the correct payload to modify the currently running flow and then triggering a deploy.