Sending emails and notifications
There are two ways of informing the users about events which are not related to the object which they are currently working on:
-
Emails: Regular email which can be sent to users, contacts or any other person. The email text is usually based on a template, see Templates. The recipient can be retrieved from the case or provided manually, see Sending emails.
-
Notifications: Short message shown in the notifications window within the Web Client, next to the quick search. If the user allows notifications in the browser, they can also appear in the Windows system tray, see Sending notifications.
Sending emails
There are different ways of sending emails from workflows. The following list provides an overview of the classes and methods which can be applied and discusses the advantages and disadvantages of each variant.
Class |
Advantages |
Disadvantages |
Comment |
---|---|---|---|
|
|
|
Use the method send() to send the email (not part of the API documentation of the class). |
workflowAPI |
The method sendEmail() has signatures which allow to provide a list of recipients directly as a parameter. |
|
Use the method sendEmail(). |
mailService |
|
|
|
Please refer to the ConSol CM API documentation to learn details about all the methods which are provided by the respective classes.
Please consider the following aspects when sending emails in the workflow:
-
Emails are not inserted into the case history automatically. If required, the respective history entry can be added in the script using the Mail.setAppendToTicket(Ticket) method.
-
The email subject must match the pattern defined for outgoing emails in the Email section, see Email configuration. This is required in order to match replies to the email with the correct case.
-
Depending on the used method, emails might be sent automatically to representing users, see Handling of user representations in emails sent in scripts.
-
If the template on which the email is based has attachments, you can use the method MailTemplate.setIncludeAttachments(boolean) to decide whether they should be included in the email or not.
Handling of user representations in emails sent in scripts
When sending emails using scripts, you need to define the desired behavior if the recipient is a ConSol CM user who is currently being represented by another user. See Configuring representations for details about representations.
The handling of automatic emails can be defined if the class Mail is used to create the email:
-
Do not send a copy of the email to representing users:
Mail.setTo(String pTo)
The parameter is the email address of the original recipient.
-
Send a copy of the email to representing users - one original recipient:
Mail.setTargetEngineer(Engineer pTargetEngineer)
The parameter is the Engineer object of the original recipient.
-
Send a copy of the email to representing users - several original recipients:
Mail.setTargetEngineers(List<Engineer> pTargetEngineers)
The parameter is a list of Engineer objects of the original recipients.
-
Send a copy of the email to representing users:
Mail.setHandleRepresentatives(boolean pHandleRepresentatives)
Sending notifications
Notifications are displayed when clicking the bell icon in the header of the Web Client. If the user allows notifications in the browser, they can also appear in the Windows system tray.
Figure 15: ConSol CM Web Client - Notification with a case link
Automatic notifications can be used to inform users about events which occur in their cases. The code which creates the notification can be placed for example in the automatic activity after a trigger.
Example: When an email is received for a case, you can add an overlay to the case icon and send a notification to the assignee. For this purpose, you only need to add an email trigger connected to an automatic activity, where the overlay is added and the notification is sent. The notification can include a link to the case.
The script for this activity could look as follows:
def myEngineer = workflowApi.engineer.name
def myTicket = workflowApi.ticket.name
if (myEngineer) {
broadcasterService.notificationBuilder().
withSenderName("System").
withMessage("Email received in your case").
withNature("INFO").
withOrigin(myTicket).
withOriginContext("TICKET").
addRecipientName(myEngineer).
build().
send();
}
Code example 22: Workflow script to send a notification
The Missed notifications selector in the user profile allows the users to decide if they want to receive emails for missed notifications:
-
One email per day with the number of missed notifications: The user receives a summary at the end of the day which states the number of unread notifications received this day.
-
One email for each missed notification with its text: Whenever the user receives a notification while he is offline, an email containing the notification text is sent to him.
-
No emails for missed notifications: The user does not receive emails for missed notifications (default).