> For the complete documentation index, see [llms.txt](https://docs.nighty.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nighty.one/custom-features-tab/expressions.md).

# Expressions

An **expression** is a block you drop into a text input that gets **replaced with real information** when your feature runs.

You write it once. It comes out different every time, because it's filled in from whatever just happened.

Expressions are built from two things: **values** and **functions**.

<figure><img src="/files/uz8OTxhoTbSHXntJgbcx" alt=""><figcaption></figcaption></figure>

## Values - the basic case

Here's the example that makes it obvious.

You want to reply to whoever sent a message and **@mention them**.

You add a Reply action and start typing: `Hello,` … and then you're stuck. You can't type the @mention, because it's a different person every time. There's nothing to type.

<figure><img src="/files/tz6cAhVNzGQ0yZOztOBV" alt=""><figcaption></figcaption></figure>

**That's what an expression is for.**

Instead of typing a name, you insert the value **user → mention**.&#x20;

<figure><img src="/files/k6A4gum5wrUEIMEOkoNC" alt=""><figcaption></figcaption></figure>

Your reply now reads:

<figure><img src="/files/V0XsEPUaQ7OtUcvpw3Qa" alt=""><figcaption></figcaption></figure>

When the feature runs, <mark style="color:blue;">user→mention</mark> is swapped out for a real @mention of whoever actually sent the message. One reply action, correct for everybody.

Values come from the parameters you already know ([Events and Parameters Page](/custom-features-tab/understanding-events-and-parameters.md)): the message's content, the server's name, the channel, the member's nickname, your own account. Anything listed under a parameter can go into an expression.

You can mix plain text and values freely.

## Functions - doing something to a value

A value gives you information exactly as it is. **A function changes it, or works something out from it.**

{% hint style="info" %}
**Think of a function as a little machine.** You put something in one end, it does one job, and hands you back a result.
{% endhint %}

Every function has:

* a **name** - what job it does
* one or more **inputs** - what it works on
* a **result** - what comes back

The simplest example is `upper`, which makes text capital letters:

You select:

<figure><img src="/files/LwwwYvaN4QC6RwGfIbjn" alt=""><figcaption></figcaption></figure>

You get: `HELLO`

On its own that's useless - you already knew it said "hello." Functions become useful when you **put a value inside them.**

By selecting:

<figure><img src="/files/XcFhKgqspCh0zYclyGgu" alt=""><figcaption></figcaption></figure>

You get: `JOHNSMITH`  (whatever the users' name is).

Now it works on whoever triggered the event.

### Functions can go inside functions

The result of one function can be the input to another. That's where real power comes from.

Say you want someone's nickname, but not everyone has one, and you want it in capitals:

{% stepper %}
{% step %}

## Use upper function

Instead of writing text or selecting a value, select a "default" function.
{% endstep %}

{% step %}

## Get their nickname or display name

Their nickname, or their display name if they don't have one.
{% endstep %}
{% endstepper %}

<figure><img src="/files/DSLGNUhqXPoiVzkCu1Px" alt=""><figcaption></figcaption></figure>

Read it from the inside out, like a set of nesting boxes. The innermost thing is worked out first, and each layer wraps around the result.

## Things worth knowing

**Everything becomes text when combined.** When you mix values, functions and typed text into one field, the result is a single piece of text. A number used in a message comes out as text - that's fine and expected.

**Files are a special case.** Some values aren't text at all - a user's avatar, a message's attachments. When you put one of those into a field on its own, it's handed over as a real file. They are meant to be used in special File inputs.
