# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
