# How to set an output in the template block to send data to MQTT (out)

**URL:** <https://discourse.nodered.org/t/how-to-set-an-output-in-the-template-block-to-send-data-to-mqtt-out/74137>\
**Category:** Dashboard\
**Created:** [24 January 2023 20:44 UTC](https://discourse.nodered.org/t/how-to-set-an-output-in-the-template-block-to-send-data-to-mqtt-out/74137 "2023-01-24T20:44:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melih](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@Melih](https://discourse.nodered.org/u/Melih)\
**Post date:** [24 January 2023 20:44 UTC](https://discourse.nodered.org/t/how-to-set-an-output-in-the-template-block-to-send-data-to-mqtt-out/74137/1 "2023-01-24T20:44:41Z")

</div>

![chrome_mSwRzrzAk6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6f89b67f3a84b48c710208707439be17d905bdb.png)  
Hi,

my goal is to get an request from mqtt to extend the cylinder (created in SVG), in the template block, when the cylinder is extended, it must send a data to MQTT. But I actually don't know how to set an output there.  
I tried with $scope.msg.action, $scope.msg.payload, but still, the function block after the template block can't recognize the data I filled in the template.

How template looks like:

 ![chrome_XiSV0ytM5N](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/2844688b2c3dc0738e2fd055fa5dc3e8d2b54301.png)  
What do I need to write here to write stuffs from template into mqtt block?

Thank you!

Sincerely

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [25 January 2023 18:48 UTC](https://discourse.nodered.org/t/how-to-set-an-output-in-the-template-block-to-send-data-to-mqtt-out/74137/2 "2023-01-25T18:48:06Z")

</div>

Bit incomplete but if you are trying to send a `msg` with `$scope.msg.<WhatShouldIdo?>` try `$scope.send({payload: "HALLO"})`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 February 2023 18:48 UTC](https://discourse.nodered.org/t/how-to-set-an-output-in-the-template-block-to-send-data-to-mqtt-out/74137/3 "2023-02-24T18:48:11Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
