Using SendGrid for outgoing emails (notifications) - HTTP Target + Triggers
Posted Sep 21, 2017
A question (Send email via Sendgrid?) made me come up with this tip. Kudos to @Pedro for asking this question.
Disclaimer:
- This tip isn't meant to be replacement of Zendesk's built-in notification system. Zendesk pre-processes (email-template, placeholders, content, signatures, etc.) to generate email-body which is sent. One can build upon following example, and try html/markdown/liquid stuff to generate richer emails.
- Please use a sandbox or test environment; or limit the scope of trigger (by making it run only in presence of a tag or requester-email that you control)
-
I am furnishing the following tip "as is". I (and Diziana) don't provide any warranty of the tip (or results) whatsoever, whether express, implied, or statutory, including, but not limited to any warranty that the contents of the tip will be error-free.
In no respect shall I (and Diziana) incur any liability for any damages, including, but limited to, direct, indirect, special, or consequential damages arising out of, resulting from, or any way connected to the use of the tip.
Objective: Send outgoing email notifications via SendGrid
Prerequisite: SendGrid Account
Part 1: Setting up HTTP Target Extension for SendGrid API
- Login as Admin in your Zendesk Support
(<subdomain>.zendesk.com/agent/)
- Go to Admin (Cog Icon) > Settings > Extensions
(<subdomain>.zendesk.com/agent/admin/extensions)
- Click on "add target"
(<subdomain.zendesk.com/targets/select_target_to_add)
- Enter "SendGrid" in Title field
- Replace highlighted part in URL (below) with your SendGrid username and password.
https://api.sendgrid.com/api/mail.send.json?api_user=<send_grid_user_name>&api_key=<send_grid_password>
- Enter the URL (above with your SendGrid username and password) in URL field
- Select "POST" from Method dropdown
- Select "Form encoded" from Content type dropdown
- Leave "Basic Authentication" UNCHECKED
- Select "Test Target" from dropdown next to "Submit" button
- Enter keys and valid values in the form
- Click on Submit button (shown in above form) to test SendGrid Configuration
- You will see results, an HTTP 200 status for success (i.e. our SendGrid configuration is good)
- Close the Test Form Overlay Popup
- Select "Create target" and Click "Submit" to create HTTP Target
Part 2: Setting up a test Trigger to use SendGrid HTTP Extension
- Go to Admin > Business Rules > Triggers
- Clone any existing trigger by clicking Clone option for trigger. For example, we are going to clone "Notify requester of received request" trigger:
- Change Trigger Name to whatever you want to. I am going to call it "SendGridTest Trigger"
- Change Conditions of Trigger (Ticket is Updated, and Status is not Solved, and Tags contain "sendgridtest").
Note: I have added a tag in conditions to limit the scope of testing to tickets I control, and I don't triggers to run on any other updates until it's ready for production usage.
- Add "Notify Target" Action, and select "SendGrid" as target
- Enter key-values the same way you used earlier while testing HTTP Target; this time we will use placeholders instead of hardcode values:
to: {{ticket.requester.email}}
toname: {{ticket.requester.name}}
from: support@yourcompany.com
fromname: Yourcompany Support
subject: [{{ticket.account}}] Re: {{ticket.title}}
text: {{txt.email.delimiter}} Your request ({{ticket.id}}) has been updated. To add additional comments, reply to this email. {{ticket.comments_formatted}}
- Click "Create" button to create Trigger
Part 3: Testing
- Create or open a test-ticket (where you have access to requester's mailbox)
- Add "sendgridtest" tag in ticket
- Submit as "New" or "Open"
- Check requester's mailbox, and see if you received notification
I hope you it worked for you. If it didn't, please debug it, or feel free to post in this thread.
That's it for now. I think, it's good start and I am looking forward to see if someone can improve upon it -- specially email-template, and html emails.
Cheers
-abdul
==
Abdul Qabiz
diziana • twitter • linkedin • blog
Team Diziana
Visit Diziana to download free and premium custom responsive ready-to-use Zendesk theme or Zendesk template or Zendesk plugins for Zendesk Help Center. Brand your Zendesk Help Center, and provide fantastic self-service customer support experience.
0
3 comments
ShunmugaKumaran Murugesan
Hi
We are unable to send the mail from support@<domain>.zendesk.com using send grid.. in send grid it is saying like this below
550 5.7.26 Unauthenticated email from zendesk.com is not accepted due to domain's DMARC policy. Please contact the administrator of zendesk.com domain if this was a legitimate mail. Please visit https://support.google.com/mail/answer/2451690 to learn about the DMARC initiative. g131-20020a815289000000b0054f5171db93si3507710ywb.506 - gsmtp
Kindly help on this
0
Diziana
Hi Andrey
I thought about it. Though user can reply back (because we are setting reply-to: <support email-id>); but that will create a new ticket. Of course, we don't want that.
Zendesk embeds lot more data in email that's used while handling replies, and appending to an existing ticket instead of creating new ones.
I think, the primary use-case of this example (SendGird) is when you want to handle things programmatically; or hook with an existing system that was built around SendGrid (incoming emails/hooks).
Thank you
0
Andrey Sarapulov
What if recipient of an email sent via Sendgid will reply back? Is this part of a use case or?
0
Sign in to leave a comment.