Automatic responses to emails
In this tutorial we will show how you can send automatic email responses within todo4teams.
If your ticketing system converts incoming emails into tickets and passes by your service structure, it is useful to confirm the customer via a direct response to the reception of his message and give him the ticket-number in which his request is being processed.
Proceed as follows:
- Login to todo4teams as administrator or superadministor
- Switch to the Tab "E-Mail"
- Choose the email-account for which you want to define an automatic response
- Click "Edit"
- Switch to the Tab "Receive-Action"
Add in the text box below the following script:
The script in detail:
var email = message.getFrom()[0].getAddress();
var footer = task.source.sourcemailbox.footer;
var text = "<html><head></head><body><p>Dear madam or sir,<br/><br/>\n";
text += "we herewith confirm having received your message.<br/><br/>";
text += "We will check your request and get in touch with you shortly.<br/>\n";
text += "Please note your ticket id for further processing: "+id+"<br/><br/>\n";
text += "With kind regards<br/>\n";
text += "Service Team<br/></p><br/>\n";
text += "</p><br/>\n";
text += "Subject of your request:<br/><pre>"+ message.getSubject()+"</pre>";
text += "\n<br/><br/>"+footer+"</body></html>";
helper.sendmail(
task.source.sourcemailbox.emailAddress, // sender email address
"Your request to "
+task.source.sourcemailbox.emailAddress+" (ID: "+id+")", // subject
text, // message
email, // addressee
null, // cc
null, // bcc
"support@bergener-partner.de", // reply to
true // html formatted message
);
This script determines first the email-address of the sender:
The message-Object is the received email-message as a java-object. It possesss a list of from-addresses and writes the first value (in practice there is exactly one) into the variable email.
We want to add the footer of the email-account to the automatic response-email, therefore we add the corresponding value to another variable.
This variable is determined by the attribute footer of the email-account which has sent us the message, therefore task.source.sourcemailbox.footer.
The message content is then put together into the variable text. We will write the email in HTML-format for a more pleasing presentation to the receiver.
There will be used the ID of the ticket (extracts the ID as in the first line), the subject of the received message message.getSubject() and the above-identified footer.
Then the function helper.sendmail() is executed in order to send the message. Please note that there are quite a number of call formats for helper.sendmail() (with or without attachments, with and without CC, BCC for example). For more details please refer to the API documentation on the main page of your todo4teams installation.
During the execution of helper.sendmail() the following parameters are submitted:
- the email-address with the sender has sent the message. If you have here a string-constant (eg "service@mycompany.com"), it must be written exactly as the address as it is configured in todo4teams.
- the subject of the message
- the message itself in HTML-format
- the destination address/addressee
- the CC-address (here suppressed by zero)
- the BCC-address (here suppressed by zero)
- the ReplyTo-address
- true as the attribute that the e-mail should be sent in HTML-format
Save the configuration of the email-account. Please click "Validate" to perform a syntax check and remove any errors.
Test the script by sending a message to this mailbox in your e-mail program. todo4teams sends and receive emails every two minutes, so it can take up to four minutes until the automatic response arrives back at you.
Modify the sample code according to your needs. Style the HTML-code for example with the HTML-style-construct or embed an image in order to adapt the messages to the corporate design of your company.