Configure an email connector
In order for a process to interact with external systems such as publishing a document on a CMS, calling a REST API, or sending an email, Bonita provides connectors. In our example we will configure an email connector to notify the manager that a task Deal with unsatisfied customer requires their attention.
A connector is a piece of code that is executed when starting or finishing a process or a task. It will process input data (for example business variable values) and generate (optionally) some outputs. Connector code might only transform inputs but can also perform interaction with external systems. |
In order to avoid settings that are specific to real email provider, we will use a tool for a fake email server "FakeSMTP":
-
Download FakeSMTP from this https://nilhcem.github.io/FakeSMTP/downloads/fakeSMTP-latest.zip
-
Unzip the file
-
Run FakeSMTP by double-clicking on the JAR file, or by running this shell command:
java -jar fakeSMTP-2.0.jar
-
When the user interface is displayed, set the listening port to 2525
-
Click on the Start server button.
Now that we have a fake server running, let’s configure the email connector on the Deal with unsatisfied customer task:
-
Select the task Deal with unsatisfied customer
-
Go to
-
Click on the Add… button
-
Select the Email (SMTP) connector
-
Click on the Next button
-
Name the connector configuration Send notification
-
Click on the Next button
-
Set the following parameter values:
-
SMTP host: localhost
-
SMTP port: 2525 (the port number specified in FakeSMTP)
-
SSL (in the Security section): unchecked
-
-
Click on the Next button
-
Enter
no-reply@acme.com
in the From field -
Use the icon to edit the expression of the To field
-
Set the Expression type to Script
-
Paste the following Groovy script into the code editing zone:
BonitaUsers.getUserProfessionalContactInfo(apiAccessor,taskAssigneeId).email
-
Click on the OK button
-
Click on the Next button
-
Set You have a pending task as the subject
-
Click on Finish
If you run the process with the connector configured, you should see a new incoming email in the FakeSMTP user interface when task Deal with unsatisfied customer becomes available.
You have now a process definition that uses a wide range of Bonita features. In the next chapters, we will create an application on top of this process.