Example of a customer portal integration#
You can integrate Allegra into your website. There are two ways to do this: a direct connection to the Allegra server, so that your customers can track the status of their reports directly on your website, or a connection via email, without the customer being able to follow up on their items through the website.
Connection with traceability of one’s own items#
In order to submit and query reports, the user must first authenticate. To do so, they can register with the system or simply provide their email address.
After signing in, the user sees the list of their reports, including those recently closed. They can now also submit new reports.
The integration into your own website naturally depends on the CMS you use. The design of the user interface likewise depends on your corporate design and the CMS in use.
You can download a sample implementation of a website integration from the download area. It is based on PHP, jQuery and Bootstrap. The integration into a Contao CMS with support for the German and English languages could look like this, for example:
{{iflng::de}} <iframe src="/service-desk/index-de.php" width="100%" height="600px"/> {{iflng}}
{{ifnlng::de}} <iframe src=/service-desk/index-en.php width="100%" height="600px"/> {{ifnlng}}
In the files index-de.php and index-en.php you must specify the address
of your Allegra REST interface. You must also make sure that the web services
are active on your Allegra server.
<?php // insert your server access here
$SERVER_BASE_URL = "https://www.yourserver.com/track/rest";
$THEME = "custom"; // [custom | default]
// style sheet for custom is in "Resources/custom-style.css"
// Available locales: en_US, de_DE $PAGE_LANG = "de_DE";
// leave the path empty if no logo should be shown
$NAVBAR_COMPANY_LOGO_SRC = ""; ... ``
Connection without traceability of one’s own items#
If it is not necessary for your customers to be able to view the current status of the items they have submitted at any time via your website, connecting the Allegra server to your website by email offers the security advantage that you do not have to open up an additional system to the outside world.
To do this, you provide a corresponding contact form whose content is then sent by email, upon submission by the customer, to the relevant receiving address of your Allegra server.
By formatting the email appropriately, it is possible to populate data in the Allegra system easily. To do so, proceed as follows: Add the following Groovy script with the type “Workflow Activity Script” to the scripts. If you do not use workflows, name the script “EmailActivityScript”. If you embed the script in workflows, please use a different name, e.g. “EmailWfActivityScript.”``
import java.util.Locale;
import java.util.Map;
import com.aurel.track.beans.TPersonBean;
import com.aurel.track.beans.TWorkItemBean;
import com.aurel.track.fieldType.runtime.base.WorkItemContext;
import com.aurel.track.util.emailHandling.EmailJSONUtil;
import com.aurel.track.admin.customize.scripting.BINDING_PARAMS;
public class EmailActivityScript { // “EmailWfActivityScript” when used in workflows
public Map<String, Object> handleEvent(Map<String, Object> inputBinding) {
WorkItemContext workItemContext = (WorkItemContext) inputBinding.get(BINDING_PARAMS.WORKITEM_CONTEXT);
String body = (String) inputBinding.get(BINDING_PARAMS.EMAIL_BODY);
if (body == null) {
return inputBinding;
}
TPersonBean senderUser = (TPersonBean) inputBinding.get(BINDING_PARAMS.USER);
if (senderUser == null) {
return inputBinding;
}
Locale locale = (Locale) inputBinding.get(BINDING_PARAMS.LOCALE);
String fromAddress = (String) inputBinding.get(BINDING_PARAMS.EMAIL_FROM_ADDRESS);
if (fromAddress != null && fromAddress.equals("info@yourdomain.com")) { // adjust
EmailJSONUtil.updateItem(workItemContext, body, senderUser, locale);
}
return inputBinding;
}
}
The body of the email must be a valid JSON object. The object’s attributes then become the attributes of the item to be created. Example:
{"Attributname1":"Attributwert1", "Attributname2":"Attributwert2", "..." }
so, for example:
{
"Build":"5.2.4",
"Description":"Some decription of the problem",
"EndDate":"2017-09-12",
"ItemType":"Requirement",
"Manager":"Guest, John",
"StartDate":"2017-09-10",
"Status":"analyzed",
"Synopsis":"Title of problem",
"Shorttext":"A custom field here",
"CustomSimpleSelect":"g1",
"CustomInteger":3,
"CustomDouble":7.0
}
For attribute names, use the original attribute names. You can use localized attribute names if the sender of the email (i.e. your website form) is known as a user in your system and has a preferred language permanently set.