2

This feels like a simple one but I am not sure if there is a way to do this.

Does anyone know if you can automate an email to a activity assignee when the activity is created and include activity tokens like {activity.subject}, {activity.activity_date_time} etc.

I want to send emails along the lines of:

Your meeting is scheduled with Michael McAndrew at 'Wednesday 4th March, 2pm'. The subject is 'How can I get more involved with your organisation'.

I haven't tried the CiviRules route yet (not sure if it supports tokens for activity emails) I'm going to try it now.

3

This will work in 5.24! As the new "tokenprocessor" functionality in core now has support for activity tokens. You'll also need a modified version of the emailapi extension https://lab.civicrm.org/extensions/emailapi/-/merge_requests/3 and you can then use civirules to trigger.

| improve this answer | |
2

You can solve this in two ways:

  1. Use schedule reminders. You can then use all the activity tokens. Draw back is that this one sends e-mail based on the (scheduled) date of the activity.

  2. Use CiviRules and the email api extension. Create a civirule based on the trigger activity is added. Add a condition to limit the civirules to only the activity assignnee and add an action to send an e-mail. I am not sure if all activity tokens work with this solution.

| improve this answer | |
1

I'm pretty sure it only happens automatically in the UI form in core (related but separate ticket: https://lab.civicrm.org/dev/core/issues/1582).

But for the api it shouldn't be too hard have hook_post or something call CRM_Core_BAO_MessageTemplate::sendTemplate(), which will automatically parse CONTACT tokens. If you want activity tokens you could get the same effect by putting smarty variables of your choosing in the template, and then passing in the appropriate activity's values in the $tplParams parameter to the sendTemplate() function. I'm pretty sure I've done something like that in a different context elsewhere, e.g.

$tplParams = array('the_subject' => $activity->subject);

and then in the message template:

Here is the activity subject: {$the_subject}

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.