Custom components in CompuSoft's Composer
Tags: compusoft, automation, email
Published: 2024-05-29 10:43:15

Composer is CompuSoft's product for easily creating emails related to bookings, invoices and whatever else you might have used and/or is currently using emails for.

Composer is included in your subscription and can be access in CompuSuite by going to Settings -> Document Templates -> [Composer](https://compusuite.dk/document-templates/composer).

The article will assume you have some knowledge of Composer or similar email builders.

## Components to the rescue

Once you get started (and hooked) on using the Composer you will quickly find that some items are often repeated in your emails, such various branding visuals, buttons and text.

To make it easier for you to reuse items the Composer allows you to create custom _components_. Components are essentially just "blocks" that can be dragged and dropped into your other emails*, thus giving you the option for better reusability.

\* The template/markup for your email in Composer is often referred to as a "form".

## Creating components for better reusability

The example below will use a _Branding header_ as an example component. When inserted into Composer forms it will display a company logo along with the customer's name (the customer being the individual eventually receiving an email using this form).

**1** Go to Composer in CompuSuite and click _+ Create new_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oplyx4lqim1hb3aj6znr.png)

**2** You will have the option to choose from a template. Templates will be covered in a later post. For now simply click on _Empty document_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojyz83lnjds24pfbsv0w.png)

**3** You will now have a new, unsaved Composer form. Click on _Settings_ in the top left and provide a name for the new component

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yor8wxln328h462rl21t.png)

**4** Insert an _image_ and _text_ block by clicking on them and provide whichever information your would like

Notice how the text on the image says `{{ "Hej" | translate:6249 }} {{ Customer.Name }}`. Composer supports a template language called Liquid, which will be covered in depth in another post. 

`{{ "Hej" | translate:6249 }}` will insert the translation item with the given id (6249) from the CompuSuite [translator](https://compusuite.dk/translator) library, making sure the text is always translated correctly for the customer's local language.

`{{ Customer.Name }}` will insert the name of the customer when the email is sent.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xmc35j420h2eims0hny0.png)

**5** Click _Save and Close_ in the bottom right, set the type to _Component_ and click _Save_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ts5q2ss96fq5hu80wybd.png)

**6** Components can be found under _Components_ on the Composer page, including built-in components provided by CompuSoft. 

Note that you can only edit your own components.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zsy6cjcsv7cz86b9nae6.png)

## Using your custom component in an email

With a component created it is time to insert it into an email.

**1** Go to the Composer page in CompuSuite and create a new empty form just like in the previous step 1

**2** Looking at the components available to the right you will see _Branding - Header_, which can be inserted by clicking on it

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwxd1in7q3lw3afsjygy.png)

**3** You can expand the component to see the contents of it by toggling the arrow

Note that some information (such as `{{ Customer.Name }}`) will not be visible in the editor as the information is not available at this level. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9082iivuerroj89b7v1r.png)

**4** Clicking the three dots followed by _Preview_ will allow you to preview the form

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yggyhiw6qlyiba9u0boo.png)


**5** On the right-hand side you can select a customer to preview the form as

Notice how the customer's name is inserted correctly in the component.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oxge8rz0vx0fj6tl19ch.png)

Your new component can be inserted into any new Composer email and will make it a lot easier to reuse the (in this case) branding for the header of the email :)