# Sending a Command from an Experience WorkFlow to the device connected by RESTful

**URL:** <https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309>\
**Category:** Help\
**Tags:** experience, workflow, rest-api\
**Created:** [October 24, 2019, 11:56am UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309 "2019-10-24T11:56:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)\
**Post date:** [October 24, 2019, 11:56am UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309/1 "2019-10-24T11:56:16Z")

</div>

Hi Losant Team,

I am looking for the best approach how to send a command to the device from the experience workflow.

The device is connected by RESTful API therefore, using Device Command node does not seem to be an option (or not?). Another option I would consider is triggering an application workflow with a command logic from the experience workflow, but it is not supported.

I would like to avoid having HTTP nodes+supporting logic for a command inside of my experience workflow. Is there a way to implement it nicely in Losant?

Thank you in advance for your reply.

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [October 24, 2019, 1:29pm UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309/2 "2019-10-24T13:29:54Z")

</div>

Hi @Alexander_Kondrov,

I believe the Device Command Node should be an option [as long as the device is authorized](https://docs.losant.com/rest-api/overview/#device-based-authentication). The documentation for the Device Command Node can be found [here](https://docs.losant.com/devices/commands/), and the Send Command action can be found [here](https://docs.losant.com/rest-api/device/#send-command). Have you attempted to send a command from a workflow? If so, have you run into any documentable errors or issues, or has nothing been received by your device?

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)\
**Post date:** [October 24, 2019, 2:10pm UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309/3 "2019-10-24T14:10:57Z")

</div>

Hi Julia,

Thank you for your response. I am still confused. I tried to send a command through the Device Send Command. The value was shown on device’s payload in Devices, but my device is not MQTT connected device. Therefore, I don’t see any usage of that values being “sent” using this approach.

The device is connected by RESTful. In other words, the command format is RESTful post request and it has to follow a specific pattern including authentication defined by the device. Can Device Command Node send restful requests of the pre-defined format?

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [October 24, 2019, 8:07pm UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309/5 "2019-10-24T20:07:42Z")

</div>

Hi @Alexander_Kondrov,

My apologies, thank you for the clarification. I am interpreting this to mean the command is displaying as sending from Losant, but the device does not handle these commands as expected or hoped.

When utilizing the REST API, you have two options:

1. If you want Losant-triggered Commands accessible to the device full-time, you could use the [Command Stream](https://docs.losant.com/rest-api/device/#command-stream), as it utilizes server-sent events.
2. If you are interested in obtaining data periodically, you could use the [Get Command](https://docs.losant.com/rest-api/device/#get-command) REST action.

I am curious, what is the configuration of the “pre-defined command format”? Given that the command payload type is configurable, it _should_ be easy to configure to the correct format.

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)\
**Post date:** [October 25, 2019, 7:26am UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309/7 "2019-10-25T07:26:42Z")

</div>

Julia,

Thank you for your response. Basically, I know how to send command and read Status with HTTP Node, my concern was how to split Experience and Application workflows but keep a channel for device management commands sent (by an user) from the experience to application workflows.

At the same time Losant API Node: Device Command Stream looks as something that I may potentially utilize. In terms of using Device: Command node in the Experience workflow and this API Node in the application workflow to catch a moment when a command sent, the command itself and the device ID. At the same time this Device Command Stream requires specification of a particular device ID. What if I want to organize a control of a set of devices? Is there the same Device Command Stream but based on Device Tags?

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [October 30, 2019, 7:35pm UTC](https://forums.losant.com/t/sending-a-command-from-an-experience-workflow-to-the-device-connected-by-restful/2309/9 "2019-10-30T19:35:51Z")

</div>

So, one thing that you can do to communicate between application and experience workflows is to use MQTT. You can subscribe to an arbitrary MQTT topic using the [MQTT Trigger](https://docs.losant.com/workflows/triggers/mqtt/), and publish using the [MQTT Output Node](https://docs.losant.com/workflows/outputs/mqtt/). Along with the [Workflow Trigger Node](https://docs.losant.com/workflows/outputs/workflow-trigger/), this technique is a great way to facilitate workflow to workflow communication.

Just backing up a bit, I can also clarify a couple of things. One, Julia’s recommendation for the command stream was for your device, not within a workflow. It was in response to here:

> [@Alexander\_Kondrov](#):
>
> The device is connected by RESTful API therefore, using Device Command node does not seem to be an option (or not?)

Yes, you can use the Device Command Node using REST. Your device would just have to be listening to the Device Comand Streaming Endpoint using HTTP. The other option is polling.

> [@Alexander\_Kondrov](#):
>
> At the same time, this Device Command Stream requires the specification of a particular device ID. What if I want to organize control of a set of devices? Is there the same Device Command Stream but based on Device Tags?

At this time no, this is something that we are thinking about. I’ll add your request in 🙂

I hope this clears up somethings! I’m happy to answer more questions.
