The WebCRM can send a notification email after a comment has been added to an activity.
The following example for notification_email_body illustrates how the contact person and the latest comment of an activity can be accessed. This template includes another template, contact_salutation, which calculates the form of address for the person.
{% assign contact = activity.contact %}{% include "contact_salutation" %}
a comment has been added to your request "{{ activity.title }}":
{% assign comment = activity.comments.last %}
--- Comment date: {{ comment.updated_at | date:"%Y-%m-%d, %H:%M" }} ---
{{ comment.notes }}
--- End of comment ---
Sincerely,
Your Services Company
Next to the login of the author of a comment (comment.updated_by), the individual comments also include the author as a person (comment.contact), unless the person has not been specified as the comment was saved. This enables you retrieve the author’s details such as their full name (comment.contact.first_name and comment.contact.last_name).
The contact_salutation template has the following contents:
{% assign salutation = '' %}
{% case contact.language %}
{% when 'en' %}
{% if contact.gender == 'N' %}
Dear Sir or Madam,
{% else %}
{% case contact.gender %}
{% when 'M' %}{% assign salutation = 'Mr. ' %}
{% when 'F' %}{% assign salutation = 'Mrs. ' %}
{% endcase %}
{% if contact.name_prefix %}
{% capture salutation %}{{contact.name_prefix}} {% endcapture %}
{% endif %}
Dear {{salutation}}{{contact.last_name}},
{% endif %}
{% when 'de' %}
{% if contact.gender == 'N' %}
Sehr geehrte Damen und Herren,
{% else %}
{% case contact.gender %}
{% when 'M' %}{% assign salutation = 'Sehr geehrter Herr ' %}
{% when 'F' %}{% assign salutation = 'Sehr geehrte Frau ' %}
{% endcase %}
{% if contact.name_prefix %}
{% capture salutation %}{{salutation}}{{contact.name_prefix}} {% endcapture %}
{% endif %}
{{salutation}}{{contact.last_name}},
{% endif %}
{% endcase %}
The template for notification_email_to should only return an email address if the new comment is to be published:
{% if activity.comments.last.published %}
{{activity.contact.email}}{% endif %}