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

# Opening line from a Before step

> Look the caller up before the call is answered, then open with the sentence your own server wrote.

A workflow agent's opening line (`greeting_message`) is said word for word as the call connects. It can now include the result of a **Before the call** step:

```
{{before.<step_id>.<field>|<fallback>}}
```

That makes a common pattern a few lines of setup: look the caller up in your own system before they are answered, and greet them with the sentence your system returns.

## The pattern

1. **A tool that asks your server about the caller.** Create an HTTP tool ([Create tool](https://docs.goyappr.com/api-reference/tools/create.md)) whose output declares the field you will say, for example `greeting`:

   ```json theme={null}
   { "type": "object", "properties": { "greeting": { "type": "string" } } }
   ```

   Your server answers `{"greeting": "Hi Dana, your order 4411 shipped today. How can I help?"}`.

2. **A Before step that runs it.** In the workflow document ([Save workflow](https://docs.goyappr.com/api-reference/workflows/save.md)), bind the tool and run it before the call. Pass the caller's number as a fixed input that is exactly one call reference:

   ```json theme={null}
   {
     "bindings": [
       { "id": "lookup", "tool_revision_id": "TOOL_REVISION_ID",
         "inputs": { "phone": { "kind": "literal", "value": "{{call.caller_number}}" } } }
     ],
     "before": {
       "steps": [{ "id": "lookup", "label": "Look up the caller", "binding_id": "lookup" }],
       "on_failure": "continue_with_available"
     }
   }
   ```

   `continue_with_available` answers the call even when the lookup fails, which is what you want for a greeting.

3. **The opening line reads its result.** Set it with [Update agent](https://docs.goyappr.com/api-reference/agents/update.md):

   ```bash theme={null}
   curl -X PATCH 'https://api.goyappr.com/agents/AGENT_ID' \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     -H 'Content-Type: application/json' \
     -d '{ "agent_speaks_first": true,
           "greeting_message": "{{before.lookup.greeting|Hello, thanks for calling. How can I help?}}" }'
   ```

4. **Check and publish.** [Check workflow](https://docs.goyappr.com/api-reference/workflows/validate.md) and [Publish](https://docs.goyappr.com/api-reference/workflows/publish.md) validate the line's references against the document's Before steps. Calls from then on open with your server's sentence.

In the dashboard, open **Answer the call** on the workflow: the list under the opening line offers every field your Before steps return and inserts the reference where your cursor is.

## What the caller hears

| The Before step | The caller hears |
| - | - |
| Returned a value for the field | The value, word for word, in place of the reference |
| Failed, timed out, or returned no such field | The text after `\|` |
| Same, and no `\|` was written | The rest of the line, without the reference (`Hi {{before.lookup.name}}, welcome` says `Hi, welcome`) |
| Same, and the line was only the reference | The agent opens in its own words |

A raw `{{...}}` is never said. The value is said as written: it is not read as a variable or a random variation, and braces in it are dropped. Values the platform treats as secrets (tokens, keys) are never filled in; the fallback is used instead.

The reference works next to everything else the line already supports: `{{Hi|Hello}} {{FirstName}}, {{before.lookup.greeting|how can I help?}}`.

## Rules

* `<step_id>` must be one of the workflow's **Before the call** steps. Dots walk into the result and a number addresses a position in a list: `{{before.lookup.orders.0.status}}`.
* A result is read at most 8 levels down, and only the first 64 items of a list. A reference that goes deeper, or names a position of 64 or more, says its fallback although Publish accepts it.
* Write it exactly as shown — lowercase, no spaces inside the braces. A near miss such as `{{ Before.lookup.greeting }}` is refused.
* Every engine and every model, on inbound and outbound phone calls (the channels a Before phase runs on).
* The line is rendered once per call, after the Before phase has finished and before the agent speaks; it is never prepared ahead of the result.

## Errors

Check and Publish answer `422 WORKFLOW_VALIDATION_FAILED` with an issue at path `/settings/greeting_message`:

| Code | Meaning |
| - | - |
| `placeholder_unknown_step` | No Before step has that id. Add the step, or change the reference. |
| `placeholder_phase` | The id is a during-call or follow-up step, which has produced nothing when the call connects. |
| `placeholder_unknown_path` | The step's tool does not return that field. |
| `placeholder_syntax` | The reference is not written exactly as `{{before.step_id.field}}`, optionally ending with `\|text`. |
| `placeholder_too_long` | The reference or its fallback is too long (512 and 1,000 characters). |
| `placeholder_reserved_variable` | The document declares a call variable named `before`, which would take the reference's place. |


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