# How to create a Template

It is a recommended practice to develop your processes as usual. Do not think about templates while your develop. However, think about re-usability, about patterns when you create processes / components.

Imagine you have an API endpoint listener process based on the standard Boomi patter Deploy/Impl/Test:

<figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-40675c99dd661b546a8c010095dff5a4a14fcb3a%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Create a template from an existing process

We need a copy of the implemented process / components that we will use a the template for all future copies.

Start and copy the Deploy-Process with dependent components (full-copy):

<div align="left"><figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-f7a292d39dbfa82a7912a567b7925da2b9335ce8%2Fimage.png?alt=media" alt="" width="199"><figcaption></figcaption></figure></div>

As always, when you use the Boomi-Copy there is some work to do, to cleanse the copy we got. The copy contains a `psg.LogProps` script component, which is used in the original implementation.

<div align="left"><figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-cff6a333518ea1e3761641ef8b259b0d2a2e269f%2Fimage.png?alt=media" alt="" width="172"><figcaption><p>The Script component is shared- resides in the #Common folder</p></figcaption></figure></div>

Actually, we do not want this script component to be part of each and every endpoint we create. The script component is shared and we want to reference the same component from all endpoints. Let's cleanse the *Copy* and a) reference the shared script and b) remove the local script.

<div align="left"><figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-69d4ee5c70bb827d7d8b70933dd3a50415ae07ce%2Fimage.png?alt=media" alt="" width="185"><figcaption><p>Local script component removed</p></figcaption></figure></div>

We do have a clean copy of our endpoint with all components in one folder. This is the basis for the Template.

### Insert placeholder variables

If we take a closer look at the end point, we recognize a name that is always repeated. With a normal copy, we would have to open each component and adapt the name to the new endpoint. We do the same now. However, we use a placeholder instead of a concrete name:

```
Post --> ${EndpointMethod}
UpdateRedemption --> ${EndpointName}
```

{% hint style="info" %}
Boomi Console uses the [Freemarker](https://freemarker.apache.org/) templating engine to replace variables. This allows us to use fancy stuff, like `${EndpointMethod?`**`lower_case`**`}`

<img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-3ede7a23854b705406c51776069db62614234451%2Fimage.png?alt=media" alt="" data-size="original">
{% endhint %}

We use variables everywhere: component names, shape captions, property names and values, ...

<figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-36a8012352db35d59d18ffaa27e2c7ae39ad7d3d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The *Copy* folder is now ready to act as a template.

#### Boomi Console Preparation

* Create a new folder for your template in your [Boomi Console Workspace](https://boomi.markusschmidt.pro/boomi-console/library/the-workspace)
* collect the id of your template components in the `components.txt` file and
* create a `datSet.json` for your placeholder variables.

<figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-2f735cef7c65688083496c9120ba8ca3dd740cf9%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Use the template

From now on, creating any new endpoint has become as simple as that:

1. Edit the `dataSet.json` variables. For example, `EndpointName=CreateContact,Number=199`
2. Run `bc comp smartcopy /wd APITemplate /d dataSet.json @APITemplate\components.txt`

<div align="left"><figure><img src="https://856602315-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJ5pAMZk3evA8VCVuQL%2Fuploads%2Fgit-blob-6a8dff134cada523c836a78ee8f90f131b3f3da0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

All that has to be done is to move the components to another folder.

<sub>P.S.: Do not forget to check whether the shared script from the #Common folder is used in your new endpoint</sub> :wink: <sub>!</sub>
