Its possible to put inputs in MQTT topic?

I’m trying to create a Blueprint with MQTT:Publish sending commands through a Input text

blueprint:
  name: Test send cmnd MQTT with Blueprint
  description: Test
  domain: automation

  input:
    send_command:
      name: Button of send commands
      description: This button will send command through MQTT
      selector:
        entity:
          domain: input_button
    machine:
      name: Device that will receive the command
      description: This device will receive the command when the button is pressed
      default: ""

mode: single
alias: bese model blueprint
description: ""
trigger:
  - platform: state
    entity_id:
      - !input send_command
condition: []
action:
  - service: mqtt.publish
    data:
      qos: "2"
      payload_template: |
        {% set setpoint = 21 %}
        {% set turn_on = "ON" %}
        {% set mode = "COOL" %}
    
        "STATUS":"{{turn_on}}","MODE":"{{mode}}","SETPOINT":{{setpoint}}
      topic: cmnd/!input machine/PH_SERIAL

this is the code, but its not working, someone have an idea?

This won’t work. To use a !input reference it has to be the entire value of a field. So like this:

some_field: !input some_input

You cannot blend it in a template like you’re doing. To do that you have to first stick the value of the input in a variable and then use that variable in a template. Like this:

variables:
  machine: !input machine
action:
  - service: mqtt.publish
    data:
      qos: "2"
      payload_template: |
        {% set setpoint = 21 %}
        {% set turn_on = "ON" %}
        {% set mode = "COOL" %}
    
        "STATUS":"{{turn_on}}","MODE":"{{mode}}","SETPOINT":{{setpoint}}
      topic: "cmnd/{{ machine }}/PH_SERIAL"

Thanks man!! It worked perfectly!!