> ## Documentation Index
> Fetch the complete documentation index at: https://docs.messagedesk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Relay building blocks

> Reference for the triggers, conditions, and actions available when you build a MessageDesk Relay.

Every Relay combines three parts: triggers, conditions, and actions. Use this page as the reference when you build or edit one.

## Triggers

| Trigger | Fires when | Notes |
| - | - | - |
| Message Received | A new inbound SMS arrives | Default trigger on templates. Supports the Reply to message action. |
| Message Sent | Your workspace sends a message, manual or automated | Unlocks Assign to sender. |
| Message Failed | An outbound message fails to deliver | Pairs with the Message failure contains text condition. Unlocks delivery-failure workflows. |
| Conversation Opened | Someone reopens a closed conversation | |
| Conversation Users Assigned | A teammate assigns one or more people to a conversation | |
| Conversation Label Applied | A teammate applies a label to a conversation | Turns a label into an automation trigger. |
| Conversation Label Removed | A teammate removes a label from a conversation | Mirror of Conversation Label Applied. |
| Comment Created | A comment is posted on a conversation | Pairs with the Comment contains text condition. Fires for comments a Relay posts with **Send Comment**, not just comments a teammate types. A Relay's own comment won't re-trigger that same Relay, but it does fire other Comment Created Relays. That's what makes the [contact property bridge](https://docs.messagedesk.com/relays/templates.md#bridge-a-contact-property-to-a-label-and-an-owner) work. |
| Conversation Closed | A teammate closes a conversation | Good for close-out and system-sync flows. |
| Call Received | An MD-owned phone number receives an inbound call | Only fires on MessageDesk-owned numbers. Doesn't fire for Twilio-connected, Telegorithm, or hosted (text-enabled) numbers. |
| Contact Updated | A contact property changes on a saved contact | Non-conversation trigger: it fires against a contact, not a conversation, so conversation-scoped conditions and actions don't apply. Pairs with the **Send Message** action. You pick the outbound channel to send from. |
| Inbound Webhook Received | An external system sends a webhook to MessageDesk | Non-conversation trigger. Fires against the contact identified by the payload's phone number. See [Webhooks](https://docs.messagedesk.com/relays/webhooks.md#inbound-webhooks) for setup and the payload schema. |
| Contact Created | A new contact is saved in your workspace | Non-conversation trigger. Fires against the newly created contact. Pairs with the **Send Message** action. You pick the outbound channel to send from. |
| Opt Out Created | A phone number opts out of receiving your messages | Message-sending actions aren't available. Conversation actions run only on channel-specific opt-outs. Contact actions run only when a saved contact matches the number. See [Opt Out Created](#actions-on-the-new-triggers). |

## Conditions

Every trigger shares a **universal core of eight conditions**:

* **My phone number equals**
* **Conversation label equals**
* **Conversation has label**
* **Is anonymous conversation**
* **Is new conversation**
* **Is unassigned conversation**
* **Teammate Assigned** gates on the conversation's current assignee. Pick a specific teammate, or **Any teammate** to check whether anyone is assigned.
* **Active hours** (with a **Trigger outside of business hours** invert)

On top of that core, three text conditions are trigger-scoped:

* **Message contains text** appears on the message triggers (Message Received and Message Sent).
* **Comment contains text** appears only on Comment Created.
* **Message failure contains text** appears only on Message Failed. Matches a substring in the carrier/provider error text (for example, `unreachable`, `landline`, `blocked`). See [Delivery status and errors](https://docs.messagedesk.com/messaging/delivery-status-errors.md).

Two more conditions are each scoped to a single trigger:

* **Contact Property Equals** checks the value of a contact property. Currently available only on the **Contact Updated** trigger.
* **Webhook Payload Field Equals** checks the value of a field in an inbound webhook payload. Available only on the **Inbound Webhook Received** trigger. See [Webhooks](https://docs.messagedesk.com/relays/webhooks.md#inbound-webhooks) for the payload schema.

One more condition matches labels by name:

* **Label name equals** checks whether the conversation has a label whose name matches the text you enter. It matches a name you type, not a label you pick from a list, so the condition can point at a label that doesn't exist yet. Create the label with that exact name before you rely on it, or edit the name in the condition.

Conditions combine with **AND** or **OR**.

> [!NOTE]
>
> **Three conditions check labels.** They behave differently, so pick the one that matches your intent.
>
> * **Conversation label equals** is an operator-based matcher. It exposes an operator selector with **contains**, **equals**, **notEquals**, **startsWith**, and **endsWith**. Use it for fuzzy or namespaced matches, for example `startsWith "Region:"` to match every regional label at once.
> * **Conversation has label** is a simple presence check. It evaluates true when the conversation is currently labeled with the label you pick, and false otherwise. Use it as a gate (for example, only run when the conversation already has the `VIP` label).
> * **Label name equals** is a name-based presence check. It evaluates true when the conversation has a label whose name matches the text you enter. Pairs with the **Remove Label where name equals** action for name-driven cleanup flows like the **Auto Close No Reply Needed** template.

> [!NOTE]
>
> **Relays can scope by line, label, content, and assignee.** **My phone number equals** targets a connected number. **Teammate Assigned** targets the conversation's current assignee. Per-person workflows like out-of-office now work on a shared line. Gate the Relay on **Teammate Assigned** set to the teammate who's out. Add **Is unassigned conversation** with **OR** to also cover brand-new threads. You no longer need a dedicated line per teammate.

## Actions

* **Reply to message** (supports templates, tags, and media, with an optional **Delay**; available on Message Received, Message Failed, and Conversation Label Removed)
* **Send Message** sends an outbound SMS/MMS on non-conversation triggers. There's no conversation to reply into, so you pick which connected phone number MessageDesk sends from (**Outbound Channel**). Currently available on **Contact Updated**.
* **Update Contact Property** updates a contact property you choose. Set it to a **Custom Value**, or pull a value from the triggering event (**Event Data**). A regular **Text** property can take either a Custom Value or an Event Data value. A non-text property, like a dropdown or number, takes either a static value matching its type or the Custom Property mapped from an Inbound Webhook payload. Mapped payload values must pass [type validation](https://docs.messagedesk.com/relays/webhooks.md#custom-property-validation).
* **Assign teammates to the conversation**
* **Assign to sender** (Message Sent trigger only)
* **Add labels to the conversation**
* **Remove labels from the conversation**
* **Remove Label where name equals** removes every label on the conversation whose name matches the text you enter. **Remove labels from the conversation** removes labels you pick from a list; this action matches on the typed name instead. The **Auto Close No Reply Needed** template uses it to clear the `No Reply Needed` label after closing.
* **Remove teammates from the conversation**
* **Remove all teammates from the conversation**
* **Close the conversation**
* **Open the conversation**
* **Send webhook**
* **Send Comment** (also called Post a Comment) posts an internal comment on the conversation. It supports static text and tags. The contact never sees it, and MessageDesk attributes it to the Relay. Use it for handoff notes and captured context.
* **Mark Conversation Unread** moves the conversation back into the **Unread** filter as part of the Relay run. Pair with **Reply to message** when an auto-reply shouldn't count as "handled" and the thread still needs a teammate to review it.
* **Mark Conversation Read** marks the conversation **Read** as part of the Relay run. Use it in acknowledgement or auto-close flows where no human review is required after the Relay runs.
* **Stop Processing** is a terminal control action. When a Relay fires and reaches this action, no lower-priority Relays on the same trigger run. Delayed and time-based Relays are exempt. The Relay list shows when a Relay stops the cascade. Use it for routing: a matched Relay can prevent a catch-all from also firing.

Available actions vary by trigger, so check the **Add Action** menu in the app for the trigger you're using.

### Event Data

Some actions can insert a value from the event that triggered the Relay instead of a fixed value.

* On **Send Message** and **Send Comment**, choose an available Event Data property for the text, or choose **Custom Value** to type your own.
* On **Update Contact Property**, the same choice applies for **Text** properties. Non-text properties can also take Event Data on **Inbound Webhook Received** Relays by mapping the matching Custom Property from the payload. The payload value must pass [type validation](https://docs.messagedesk.com/relays/webhooks.md#custom-property-validation).

Event Data is most useful with the **Inbound Webhook Received**, **Contact Updated**, and **Contact Created** triggers, where the event carries contact and payload fields.

> [!NOTE]
>
> **Missing values exit early.** If the Event Data property an action uses has no value, the action exits early without running. Say the action inserts the custom property `Favorite Color` and the contact has no `Favorite Color` value. Nothing runs, and nothing breaks.

> [!NOTE]
>
> **Changing the trigger clears Event Data inputs.** If you switch a Relay's trigger, MessageDesk removes any Event Data values used as inputs on existing actions. Those fields don't exist on the new trigger's event. Review your action inputs after switching triggers. See [Changing the trigger on an existing Relay](https://docs.messagedesk.com/relays/create-edit.md#3-set-a-trigger).

### Actions on the new triggers

**Contact Created**, **Contact Updated**, **Inbound Webhook Received**, and **Opt Out Created** are non-conversation triggers. They fire against a contact rather than a conversation, so conversation-scoped conditions and actions don't apply. On these triggers, **Send Message** asks which connected phone number to send from (**Outbound Channel**), because there's no conversation to reply into. MessageDesk creates or continues a conversation with the contact on that channel, and standard compliance (opt-outs, 10DLC) still applies.

**Message Failed** supports the following actions:

* Reply to message
* Assign teammates to the conversation
* Close the conversation
* Open the conversation
* Remove all teammates from the conversation
* Remove teammates from the conversation
* Add labels to the conversation
* Remove labels from the conversation
* Send webhook

**Conversation Label Removed** supports the same set as Message Failed with one asymmetry: **Remove labels from the conversation isn't available** on this trigger. Every other action above is available.

**Call Received** is a voice-only trigger. It fires when an MD-owned phone number receives an inbound call, so **Reply to message** isn't available (no inbound SMS to reply to). It doesn't fire for Twilio-connected, Telegorithm, or hosted numbers ([what's the difference?](https://docs.messagedesk.com/get-started/phone-numbers/overview.md)). Use it to label, assign, notify, and log call activity in the same conversation thread. Supported actions:

* Assign teammates to the conversation
* Add labels to the conversation
* Remove labels from the conversation
* Remove teammates from the conversation
* Remove all teammates from the conversation
* Open the conversation
* Close the conversation
* Send webhook
* Send Comment
* Mark Conversation Read
* Mark Conversation Unread

**Contact Updated** fires when a contact property changes. Supported actions:

* Send Message
* Send webhook

**Inbound Webhook Received** runs against the contact identified by the payload an outside system sends. It pairs well with:

* Send Message (pick the **Outbound Channel** to send from)
* Update Contact Property
* Add labels to the conversation
* Send webhook

See [Webhooks](https://docs.messagedesk.com/relays/webhooks.md#inbound-webhooks) for setup and the payload schema.

> [!NOTE]
>
> **Contact Auto-Create checkbox.** Each action on an Inbound Webhook Received Relay includes an **Auto-Create** checkbox. Check it and MessageDesk creates the contact from the payload when the phone number doesn't match a saved contact, then runs the action. Leave it unchecked and the action only runs against saved contacts. The checkbox is set per action and only appears on this trigger. See [Auto-create contacts](https://docs.messagedesk.com/relays/webhooks.md#auto-create-contacts).

**Contact Created** fires when a new contact is saved in your workspace. Supported actions:

* Send Message (pick the **Outbound Channel** to send from)
* Update Contact Property
* Send webhook

**Opt Out Created** fires when a phone number opts out of receiving your messages. What runs depends on the opt-out's scope and whether the number matches a saved contact:

* **Channel-specific opt-outs.** When a contact opts out of a specific outbound channel (for example, by texting STOP to that number), conversation actions run against the conversation on that channel.
* **Global opt-outs.** When the opt-out is global (mostly submitted through the support site), conversation actions don't run, because no single channel conversation is in scope.
* **Contact actions.** Contact actions run only when a saved contact already exists for the opted-out phone number. If no contact matches, the Relay takes no action.

> [!NOTE]
>
> **No message sending on this trigger.** Message-sending actions aren't available on Opt Out Created Relays, because the contact just opted out. MessageDesk already blocks outbound sends to opted-out numbers at the workspace level. Use this trigger to label, assign, or sync the opt-out downstream instead. See [Anonymous, opted-out, and blocked contacts](https://docs.messagedesk.com/contacts/anonymous-opt-out-blocked.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.