Sending Email From Celigo

Comments

12 comments

  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    Dave Guderian using an email connector like Gmail would definitely give you more flexibility since you could compose the email message to however you need. That being said, you could add the customer service email as a monitor user and then setup error notifications for that user. The email sent would include the error message which may be good enough for you. If that error message isn't good enough, you can manipulate the error message via a postSubmit script.

    0
  • Dave Guderian
    Engaged
    Celigo University Level 4: Legendary
    Awesome Follow-up

    Thanks so much Tyler for the help on this. I did end up going with the Gmail Connector because I think long term its probably our best solution here.

    I made the connection and plugged it into the flow, but have been receiving an error (below). I'm trying to determine if this is something with my mapping, or with the connection itself but haven't been able to find much documentation on it. Any help on where to look would be greatly appreciated!

    0
  • Steve Klett Strategic Partner
    Celigo University Level 4: Legendary
    Answer Pro
    Great Answer
    Top Contributor
    Awesome Follow-up
    Engaged

    Dave Guderian What's it show on the HTTP request tab? Do you see a recipient address?

    0
  • Dave Guderian
    Engaged
    Celigo University Level 4: Legendary
    Awesome Follow-up

    Hey Steve-

    Here is what I see on that tab.

    0
  • Steve Klett Strategic Partner
    Celigo University Level 4: Legendary
    Answer Pro
    Great Answer
    Top Contributor
    Awesome Follow-up
    Engaged

    What's in the body?

    0
  • Dave Guderian
    Engaged
    Celigo University Level 4: Legendary
    Awesome Follow-up

    It appears nothing. I am trying to send a website link, but it appears its not rendering here.

    0
  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    Dave Guderian do you have a mapping made for this?

    0
  • Dave Guderian
    Engaged
    Celigo University Level 4: Legendary
    Awesome Follow-up

    Sure, see below. Also note that CC info and SSN are test data (just wanted to call that out!). I would like the view link to be in the email and it would be different for each instance. After doing some reading, it looked like I may need to use the base64Decode handlebar potentially????

    0
  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    Dave Guderian it's a bit tricky because you have to format the raw field with text that conforms to RFC 2822, but it can be done.

     

    You're flow could look something like this. Notice there is a response mapping on the step fails and it maps in the error data to the record. Additionally, we've specified for the record to proceed to the next step even if there is an error.

     

    On the gmail step, I set this up like this.

     

    On the mapping step, you need to keep the fields as I have them because the next step is to formulate the HTTP body and it requires these mappings to be in place. I set it up like this so you would only need to modify the mappings and not touch the HTTP request body. For this, use the mapping handlebar expressions below and change your to and from email and subject of course.

    Date mapping handlebar:

    {{{dateFormat "ddd, d MMM YYYY HH:mm:ss ZZ" (timestamp) "YYYY-MM-DDTHH:mm:ss.SSS[Z]" "America/Chicago"}}}

    Message ID mapping handlebar:

    {{{random "uuid" 10}}}@celigo.com

    Message handlebar. You would change this to what you need.

    Order number {{{record.test}}} failed within the integration. Please check.

     

    Finally, add this handlebar expression to your request body.

    {"raw": "{{{base64Encode (join "

    " (join "" (join "" (join "" (join "" (join "" 
    "From: " record.From) "
    To: " record.To) "
    Subject: " record.Subject) "
    Date: " record.Date) "
    Message-ID: " record.[Message-ID])  

    record.Message
    )}}}"}

     

    Example output:

    0
  • Dave Guderian
    Engaged
    Celigo University Level 4: Legendary
    Awesome Follow-up

    Tyler - As always this is an EXCELLENT explanation and I am going to give this a shot today.

    One question that I did have (since this is seems to be pretty complicated) is if this is how the gmail connector is intended to be used? Is what you describe above the "standard" protocol (i.e. anytime this connector is used similar steps would need to be done for this connector), or am I trying to use this connector in a more complicated fashion and not necessarily how its intended to be used?

    0
  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    Dave Guderian we definitely could improve the UI for this specific use case. It's just a bit complex given that the body has to be an encoded string and within a specific format to follow the standard email protocol.

    0
  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Engaged
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    Dave Guderian I modified this flow a bit to add some more functionality. Instead of using the handlebar expressions in the body, I ended up converting it to a postMap script so that I could add some validation and notify users if they don't have all the required mappings. Additionally, I made it so the message field can have HTML in it so that your emails can be more than just plain ole text. So if you use this, the mappings are the same as I have above, but you need to remove the handlebars from the HTTP request body, then add this postMap script to the step.

    import sjcl from 'sjcl';

    function postMap (options) {
      
      let output = [];
      
      for (let d of options.postMapData) {
        
        if (!d.To || !d.From || !d.Subject || !d.Message) {
          output.push({
            errors: [{
              code: "missing_field_mappings",
              message: "You must include field mappings for the following fields: To, From, Subject, and Message.",
              source: "postMap"
            }]
          })
          continue;
        }
        
        let message = "";
        message += "To: " + d.To + "\r\n";
        message += "From: " + d.From + "\r\n";
        message += "Subject: " + d.Subject + "\r\n";
        if (d.Date) message += "Date: " + d.Date + "\r\n";
        if (d["Message-ID"]) message += "Message-ID: " + d["Message-ID"] + "\r\n";
        message += "Content-Type: text/html; charset=utf-8" + "\r\n";
        message += "Content-Transfer-Encoding: base64" + "\r\n";
        message += "MIME-Version: 1.0" + "\r\n";
        message += "\r\n" + d.Message;
        
        let encodedMessage = sjcl.codec.base64.fromBits(sjcl.codec.utf8String.toBits(message));
        
        output.push({
            data: {
              raw: encodedMessage
            }
          })
      }
      
      return output;
    }
    0

Please sign in to leave a comment.