> For the complete documentation index, see [llms.txt](https://docs.widgelix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.widgelix.com/assets/asset-page/downlinks.md).

# Downlinks

The **Downlinks** tab lets you create downlinks (commands sent to the device) and send them manually. Saved downlinks can also be sent automatically by [Actions](/actions-formerly-rule-engine/action-types-and-placeholders.md) and by the Downlink Button widget.

## Add a downlink

Click **Add Downlink**.

<figure><img src="https://2494440469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fggsr9Xlsze5cwVr4WMof%2Fuploads%2FipdY422yS0OSxUFiTUEZ%2Fadd-downlink.png?alt=media&amp;token=35a2c4c4-5d4e-43ad-8383-9c4bb5db1b35" alt="Add Downlink dialog" width="420"><figcaption><p>Add Downlink</p></figcaption></figure>

| Field                             | Description                                                                                                                  |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| **Name**                          | Name of the downlink, e.g. `Valve open`. This name is used when you select the downlink in actions.                          |
| **Comment**                       | Optional description.                                                                                                        |
| **Pass payload data to downlink** | Passes the last uplink payload to the downlink formatter.                                                                    |
| **Activate after uplink**         | Sends the downlink after the next uplink is received (useful for Class A devices that only listen right after transmitting). |

Define the payload in one of two tabs:

* **Default**: enter values for the downlink data fields. The fields appear only if they are defined under **Downlink Data** in the asset template, together with a valid downlink payload formatter.
* **Custom**: write a custom downlink encoder, for example:

```javascript
function decode(payload, params) {
  const red = ('00' + payload.red.toString(16)).slice(-2)
  const green = ('00' + payload.green.toString(16)).slice(-2)
  const blue = ('00' + payload.blue.toString(16)).slice(-2)
  const on = ('00' + payload.on.toString(16)).slice(-2)
  const off = ('00' + payload.off.toString(16)).slice(-2)
  return `${red}${blue}${green}${on}${off}`
}
```

Click **Save**. The downlink appears in the tab.

## Send a downlink

Click **Send** next to a downlink to queue it for the device.
