Routing based on the recipient's address


In the tutorial Routing based on the sender's address we have shown how you can route newly created jobs within todo4teams depending on the sender's address of an incoming email.

In the following example we will show how you can make a routing based on the the addressee of the email. This case is a little more complicated because an email may have several addressees - which may also just be mentioned in the CC- and BBC-part of the email's recipients.

An example how this will work:
You offer your customer a variety of email addresses which provide a possibility of contact. Internally the incoming emails to these addresses are routed to a collective mailbox. In this case the whole subset of addresses is called alias addresses.

Now based on to the actual email addressees in the incoming mails to todo4teams the generated tasks are routed on to a specified group or to a specified skill.
This functionality can be mapped using the arrival-action within the properties-dialog of the corresponding collective mailbox.
For this purpose it is necessary to implement a Javascript in this arrival-action.

In order to implement this Javascript an example.
The following Java Script performs the following functions:
There are the individual e-mail addresses test@test.com (as the collective mailbox) and test1@test.com and test2.@test.com as the alias addresses.

addressbased.png

Tickets to the address test1@test.com shall be processed to group 25, tickets for the address test2@test.com to the group 26.

All other messages that do not include these recipients are routed to the group 27; this for example may be the mails that were addressed directly to the collective mailbox test@test.com.

Please adjust for your own purposes the email addresses and the affected groups/skills.

If further adjustments are required, please feel free to contact us at support@bergener-partner.de.

In the script, all the addressees are first summarized in a string  AllRecipients.

In the if/else construct is then checked whether the relevant addressee is contained therein and based on the result of this inquiry the matching ticket route is chosen.


var numRecipients = message.getAllRecipients().length;
var allRecipients = "";
for (var i = 0; i < numRecipients; i++) {
 var recipient = message.getAllRecipients()[i];
  allRecipients += recipient.toString()+", ";
}
 
if(allRecipients.indexOf('test1@test.com')>-1) {
   helper.routeToGroup(25);
} else if(allRecipients.indexOf('test2@test.com')>-1){
   helper.routeToGroup(26);
} else {
   helper.routeToGroup(27);
}
     

Child Pages