E-mail send, SMS Send and PDF Create API extensions

Publicado
2015-01-15 07:01
Written by
jaapjansma - member of the CiviCRM community - view blog guidelines

This week we have been working for MAF Norway to automate the sending of SMS, E-mail and PDF creation. What we have done in the past for them is that we created a Trigger/Action module to automate their donor journeys. The actions in the trigger/action module are API calls. But what was missing up-to-today was to functionality to send e-mail, or to create a PDF Letter or send an SMS by invoking an API Call.

Note: the trigger/action module is a very experimental module just developed for the MAF. At the same time we are developing a CiviRules modules which will work in a similair way as the Drupal Rules module.

This week we developed three extensions to accomplish this:

org.civicoop.smapi

The SMS Api has one action Send this action takes three parameters:

  • contact_id - the id of the contact to which you want to send the sms
  • provider_id - the id of the SMS provider which you want to use to send the sms
  • template_id - the message template id of the message you want use

org.civicoop.emailapi

The E-mail Api has one action Send this action takes two required parameters:

  • contact_id - the id of the contact to which you want to send the e-mail
  • template_id - the message template id of the message you want use

There are also two optional parameters:

  • from_name - the name of the sender
  • from_email - the e-mail adress of the sender

org.civicoop.pdfapi

The PDF Api works a little bit different from the SMS and the E-mail API. Because the PDF files have to be stored at a location where somebody could print them. We have decided to use an e-mailaddress for this because that was the easiest way in processing the print job.

The PDF Api has one action Create this action takes three parameters:

  • contact_id - the id of the contact to which you want to send the sms
  • template_id - the message template id of the message you want use
  • to_email - the e-mail address which will receive the pdf file. This could be the e-mail address of your printer or of someone who will do the printing of the pdf letters
Filed under

Comments

Great sprinting - CiviCoop :) So good to see organisations taking initiative, pushing things foward, publishing their work as they go, and communicating about it as well - top marks!!

Cool,

Do you think it's generic enough to be put into civicrm core or does it need some more tuning to be ready?

Good work. Is there a convenient way to add token replacement for a particular object from a component? For example, participant or membership or contribution tokens?

Hey Joe,

It is not really possible to set contribution, or event tokens. It works a bit similair to sending an e-mail from the action button above the contact dashboard. So the reference is always a contact.

Jaap

great work!

Could this be extend to print PDFs for a group of contacts? Receving group_id as parameter an loop through its contacts might be very useful instead of printing single contact's pdf

Hey the group_id as a parameter could be very usefull! I have developed those module for my client and they didn't have the requirement of sending to a group. So feel free to fork the extensions and change them. I am happy to merge your code afterwards.

Today Ixiam made it possible to send e-mail, pdf and sms to multiple contacts (splitted by comma's).