Modules Communication - happy-geeks/wiser GitHub Wiki

Introduction

This module can be used to send communications to customers or employees, for example, in various ways. With this it is possible to send e-mail and SMS. In the future, WhatsApp and possibly other ways of communication will be added.

With this module, one-time and periodic messages can be sent with dynamic data and/or recipients. For example, a one-time report of certain dates, or automatic congratulations to people on their birthday.

This module works in conjunction with the WiserTaskScheduler (WTS). If no WTS is running, then nothing will be sent, no matter what you set in Wiser.

User's Manual

General

When opening the module, you will be asked whether you want to create a new communication, or edit an existing one. Note that if you edit an existing one and the communication in question has already been sent that day, it will not be sent again that day unless you change the sending time to a later time.

When opening an existing communication, or creating a new one, a new screen will open containing all the options that can be set. These options are divided into several tabs.

At the very top is the name of the communication. With the pencil it can be changed. The trash can be used to delete the communication.

Below is a description for each tab in the module, explaining exactly what you can set on each tab.

Tab 'Receivers' ('ontvangers')

As the name implies, this is where you can set who should receive the communication. This can be a fixed list (for example, to send reports of orders every day/week/month to some specific recipients), or a dynamic list based on a data selector or query (for example, to send reminders all users who are in Wiser). For fixed recipients, multiple recipients can be entered by separating them with commas, semicolons or enters.

The available data selectors come from the "Data selector" module, this contains all data selectors where the option "Make available in communication module" is on. Of course, the data selectors must then be set up to return an e-mail address and/or telephone number of each recipient in the results. The name of the field containing this e-mail address or telephone number can be entered in the "content" tab.

The available queries come from the "Wiser management" module, "Queries" tab (or table wiser_query). Again, only queries where the option "Show in communication module" is on are shown. Of course, that query must then have an email address and/or phone number per line in the results.

If any results come from the data selector or query without email address/phone number, they will be skipped during transmission.

Tab 'Data'

Here a data selector or query can be chosen for use in the **content **of the communication. This data selector or query is run per recipient and therefore should only retrieve data for that recipient. This is completely optional and can be used, for example, to show an overview of current orders. In that query/data selector, that order with all ordered products can then be retrieved and an overview of that can be sent (more on that in the next chapter).

Here also applies that only data selectors and queries are shown with the option "Show in communication module" on.

Tab 'Content'

On this tab you can set the actual message that the recipient will see. Here you can choose different types of communications and this is not limited to 1. It is possible to send an e-mail and SMS at the same time. However, the latter works only with data selectors and queries, not with fixed recipients.

Selector

With each type of communication there is a field called "Selector," this should indicate where the communication module can find the recipient's e-mail address or phone number in the results of the data selector or query.

In the case of a data selector, this should be the name of the property in the JSON results that contains the email address or phone number. What to enter here is easiest to see in Wiser's data selector module. There, open the data selector you want to use for communication and then click the "Show result" button at the bottom. Next, a JSON result will be displayed, in which you can see what the properties are called.

For queries, this is the name of the column or alias that contains the e-mail address or telephone number. You can control this when writing the query.

Content (inhoud)

Each type of communication also has a field for the content, which is the message being sent. Here variables can be used as for example also in the template module of Wiser. These variables may come from the data selector/query of the "Recipients" tab or from the one of the "Data" tab, they can be used interchangeably/simultaneously. For example, if a field named firstName is retrieved in the data selector/query, then in the hold the variable {firstName} can be added at the place where that dynamic value should be displayed.

As indicated in the previous section, this can also be used to show data with multiple lines in the communication, such as an order with multiple products for example. A repeater can be used for this purpose. This is a special variable of the GCL already used, for example, in shopping baskets and other data selectors.

If we stick to the example of an order with multiple products, then you want to show the order number and address at the top, with all ordered products (and the name and price per product) below and the total price of the order at the bottom. For the general data you then just use normal variables, like {orderNumber} and for the list of products you always start with a {repeat}, then after that all the information to be shown per product, like {name} and {price} and finally you end with a {/repeat}.

Note: The HTML editor we use has built-in functionality to automatically correct invalid HTML. This often causes problems when using a {repeat}. For example, if you use a <table> in the HTML and want to put a {repeat} in there to generate a <tr> per product, the HTML editor moves that {repeat} outside the <table>, because a <table> should not contain anything other than a <tbody>, <thead> or <tr>. To work around this, you can put the {repeat} in comments, then the HTML editor will leave it where you want it. Be aware that everything between {repeat} and {/repeat} is repeated per product, including the end of the HTML comment. This can also be solved by using double comments, this way: <!-- {repeat} <!-- -->.

It is also possible to have and display multiple layers of data in communications. For example, a product can have multiple variants. You can do that by adding another repeat, but with the name of the property that contains those variants. So for example like this: {repeat:variants} {name} {/repeat:variants}.

Here is a complete example of HTML for an email that uses all of the above:

<p><strong>Dear,</strong></p>
<p>This is a test mail from Wiser.</p>
<p>Here all items from type "testentiteit" who are in the wiserdemo instance:</p>
<table style="width:100%;border:1px solid black;border-collapse:collapse;">
	<thead>
		<tr>
			<th style="border:1px solid black;text-align:left;padding:3px;">ID</th>
			<th style="border:1px solid black;text-align:left;padding:3px;">Titel</th>
			<th style="border:1px solid black;text-align:left;padding:3px;">Color</th>
			<th style="border:1px solid black;text-align:left;padding:3px;">Article group</th>
			<th style="border:1px solid black;text-align:left;padding:3px;">Subitems</th>
		</tr>
	</thead>
	<tbody>
	<!-- {repeat} <!---->
		<tr>
			<td style="border:1px solid black;">{id}</td>
			<td style="border:1px solid black;text-align:left;padding:3px;">{itemtitle}</td>
			<td style="border:1px solid black;text-align:left;padding:3px;">{color}</td>
			<td style="border:1px solid black;text-align:left;padding:3px;">{repeat:articlegroup}{Articlegroup_title}{/repeat:articlegroup}</td>
			<td style="border:1px solid black;text-align:left;padding:3px;">
				<ul>
					<!-- {repeat:testentiteit2} <!----><li>{Subitem_title} ({Subitem_id})</li><!-- {/repeat:testentiteit2} -->
				</ul>
			</td>
		</tr>
	<!--{/repeat}-->
	</tbody>
 </table>
<p><em>Best regards, Wiser</em></p>

Further options

For sending emails, there are a number of additional options; With template you can choose a mail template (from the module master data) which should serve as a basis for the content of the mail. At language the language of the mail template can be selected (if there are multiple languages at the customer). After choosing a mail template and a language, the subject and content will automatically be filled with the settings of that mail template. After this the subject and content can still be changed, if desired. This adjustment has no effect on the chosen mail template, those adjustments are only for this specific communication. Vice versa the same applies, adjustments in the mail template are not automatically transferred to already existing communications.

Tab 'Send pattern' ('Verzendpatroon')

In this tab you can determine when the communication should be sent. Here, you can choose to send the e-mail immediately (this does depend on the settings in the WTS, see the chapter on the WTS for more information), or at a fixed time (then the communication is sent once at the entered date and time) and periodically - again; provided the WTS is set correctly.

With periodic, you can choose when and how often the communication should be sent. Each time it is to be sent, any selected data selectors and/or queries are re-executed, so the data is always up-to-date and the recipients and/or content of the communication can be different each time.

A start and end date can be entered, the communication is then sent only between those 2 dates. Below that a time can be entered, this is the time of the day on which the message should be sent. For example, if it is set to be sent every Monday, then it will be sent every Monday at the chosen time.

You can also set how often it should be sent, for example every 2 weeks on Monday. Here you only have the choice of weekly or monthly. With weekly, you can choose on which day(s) and with monthly on which day of the month. If you want to send a communication daily, you can do so by entering "every 1 week" with all days checked. For monthly, it also looks at what the last day of the month is, you can enter 31, for example, to send something every last day of the month. The WTS knows that not all months have 31 days and then sends it on the last day of the month, whether that is 28, 30 or 31.

WiserTaskScheduler

See the documentation of the WiserTaskScheduler to set up the actual sending of the communication

Here it is important to note that sending depends on how often the WTS is set to run processing. So if the WTS handles messages every 5 seconds, then a communication set to send immediately will take max 5 seconds to send (or maybe a little longer if a slow query/data selector is set). If the WTS is set to only process communications from the wiser_communication_generated table once a day at 02:00, then a communication that is set to be sent immediately will not be sent until the next night at 02:00 and thus will not be sent immediately.

⚠️ **GitHub.com Fallback** ⚠️