> For the complete documentation index, see [llms.txt](https://docs.locoia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.locoia.com/automation/flow-builder/email-formatting.md).

# Email-formatting

Usually you can find email addresses as attribute of a lot of entities, e.g. "user", "owner", or "contact" in various third party systems. This depends on the system, but the output often looks something like this:

```
{
  "first_name": "Oliver",
  "last_name": "Doe",
  "email": "oliver.doe@gmail.com",
  ...
}
```

However, sometimes the email might be a free-form text field in the third party system, so some customers add a comment or even just use non-valid emails. Here are two examples:

1. `"email": "oliver.doe@gmail.com (brother)"`
2. `"email": "oliver.doe@go"`

In theses cases we have to make sure that the email is either fixable or recognized as a non-valid email. One can use the following Jinja code to do so:

```
 "email": {% if owner.email != None %}{% set mail_list = regex_search(owner.email, "([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+" ) %}{% if probe(mail_list, 0) %}"{{ mail_list.0 }}"{% else %}""{% endif %}{% else %}""{% endif %}
```

This returns the email in a correct format, or if it's not possible, an empty String "". For our examples that would mean:

1. `"email": "oliver.doe@gmail.com"`
2. `"email": ""`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.locoia.com/automation/flow-builder/email-formatting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
