Setting up SendGrid GitHub Integration: 2 Easy Steps

• June 16th, 2021

Do you want to leverage SendGrid for monitoring events occurring on GitHub? Are you unable to find resources on setting up SendGrid GitHub integration? If yes, then you have reached the right place. You will find everything related to this integration here. This article will guide you through the step-by-step process of SendGrid GitHub integration.

Upon a complete walkthrough of the article, you will be able to integrate SendGrid GitHub seamlessly. You will be able to carry out the process without any difficulties and find an easy way to build the integration without any hassle and prior technical knowledge.   

Table of Contents

Introduction to Sendgrid

SendGrid GitHub - SendGrid Logo
Source

SendGrid provides a cloud-based service for transactional and email marketing including shipping notifications, friend requests, sign-up confirmations, etc. The company also provides link tracking, open rate reporting, tracking email opens, unsubscribes, bounces, and spam reports. SendGrid also started providing SMS, voice, and push notification services after its partnership with Twilio in 2012.

Key Features of SendGrid

  • Versatile: Any kind of transaction emails, email marketing, email API solutions, newsletters, programmable SMS, and all related solutions can be solved by SendGrid.  
  • Email Scheduling: With SendGrid’s email scheduling functionality, you can send large volumes of emails in the form of queued batches or as individual recipients. This improves the efficiency of processing and distributing large volumes of mails as well as reduces email pre-processing time. 
  • IP Warm Up: It is the process of increasing sending volume over a period of time to establish a reputation of the ISP as a legit sender. 
  • Robust Security: To add a layer of defence a 2-factor authentication was started by SendGrid in case the credentials get compromised.   
  • SSL: When enabled, it encrypts the connection between the recipient click and open actions and allows SendGrid to better protect the confidential user data.  To know more about SSL click here. 

For further information on SendGrid, you can check the official website here.

Introduction to GitHub

SendGrid GitHub - GitHub Logo
Source

GitHub is an internet hosting website, often leveraged for uploading and saving code associated with software and application development, thereby allowing developers and programmers to work collaboratively. The main feature for the popularity of GitHub is that the developer can update or do experimentation on a project freely without affecting the original project.

Key Features of GitHub

  • Collaborative Coding: GitHub provides a common platform for the coders of the same project. The commits in the code can be seen by any user.
  • Project Management Features: These help in tracking the progress of the team, thereby providing clear roadmaps and priorities.  
  • Team Administration: Tasks like accessing, updating, granting, and revoking permissions across the projects and teams can be easily carried out.
  • Developer Features: Functionalities based on automation, security, and client applications are available. 

For further information on GitHub, you can check the official website here.

Understanding the Need for SendGrid GitHub Integration 

The SendGrid GitHub integration is needed to get regular updates on the changes of a particular project in GitHub. With the help of SendGrid GitHub integration, you can seamlessly receive alerts and emails as a result of some triggers which led to these actions.

Triggers in GitHub are the events that initiate a particular action that had already been configured. An action in GitHub is triggered on a particular event. Actions can also be called workflows which get triggered in GitHub. This can be done effectively by using a diverse set of actions and triggers supported by the SendGrid GitHub Integration.

There are more than 20 triggers like NEW REPOSITORY, NEW NOTIFICATION, NEW COLLABORATOR, NO ISSUE, etc. that you can use by integrating SendGrid GitHub. This integration can further provide more than 300 actions or workflows like SEND EMAIL, CREATE REPO ISSUE, SEARCH ISSUES OR PULL REQUESTS, CREATE TAG, CREATE GIT, etc.   

Simplify ETL with Hevo’s No-code Data Pipelines

Hevo Data, a No-code Data Pipeline helps to integrate data from SendGrid that is free of cost & GitHub with 100+ other sources and load it in a data warehouse of your choice to visualize it in your desired BI tool. Hevo is fully managed and completely automates the process of not only loading data from your desired source but also enriching the data and transforming it into an analysis-ready form without having to write a single line of code. Its fault-tolerant architecture ensures that the data is handled in a secure, consistent manner with zero data loss.

It provides a consistent & reliable solution to manage data in real-time and always have analysis-ready data in your desired destination. It allows you to focus on key business needs and perform insightful analysis using BI tools such as Tableau and many more. 

Check out what makes Hevo amazing:

  • Secure: Hevo has a fault-tolerant architecture that ensures that the data is handled in a secure, consistent manner with zero data loss.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects schema of incoming data and maps it to the destination schema.
  • Minimal Learning: Hevo with its simple and interactive UI, is extremely simple for new customers to work on and perform operations.
  • Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with very little latency.
  • Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
  • Live Monitoring: Hevo allows you to monitor the data flow and check where your data is at a particular point in time.

Simplify your data analysis with Hevo today! Sign up here for a 14-day free trial!

Prerequisites

  • Working knowledge of SendGrid.
  • Working knowledge of GitHub.
  • Strong understanding of API calls.
  • A decent idea of writing code snippets.

Building SendGrid GitHub Integration using API Calls

SendGrid GitHub Integration can be implemented using the following steps:

Configuring SendGrid

Configuring GitHub 

Configuring SendGrid

Step 1: Logging into a SendGrid Account

To begin integrating SendGrid GitHub, you first need to log in to your SendGrid account. To do so, you can go to the official website of SendGrid and log in using your credentials such as username and password. The link to the official login page is: https://app.sendgrid.com/login

Step 2: Choosing a Setup Method

Once you’ve logged in, you’ll now need to select a set-up method, choosing between Web APIs and SMTP relays. Web API is accessed using HTTP protocol while SMTP is procedures to send mails or messages to a server.  

Sendgrid Github - Web API or SMTP
Source: Self

Step 3: Selecting Language in Case of Web APIs

Web APIs are built on programming languages. In case, you choose web APIs, you will also have to select a programming language from the following options:

Sendgrid Github - Language for Web API
Source: Self

Step 4: Installing the SendGrid Package

Once you’ve selected the language of your choice, you’ll now need to install the latest version of the same, along with the SendGrid Package. For example, if you choose Python as a Web API language, you can use the following code to install the SendGrid package:

pip install sendgrid

The terminal now should print something like this:

Collecting sendgrid
  Using cached sendgrid-6.4.6-py3-none-any.whl (73 kB)
Requirement already satisfied: python-http-client>=3.2.1 in /usr/local/lib/python3.8/site-packages (from sendgrid) (3.3.1)
Requirement already satisfied: starkbank-ecdsa>=1.0.0 in /usr/local/lib/python3.8/site-packages (from sendgrid) (1.0.0)
Installing collected packages: sendgrid
Successfully installed sendgrid-6.4.6

Step 5: Creating an API Key

You now need to create an API key to set up the SendGrid Github integration. To do so, copy the URL for your GitHub repository and paste it into SendGrid. To store the SendGrid API key, use the following command in your command prompt:

setx SENDGRID_API_KEY the_key_you_copied_from_SendGrid

Step 6: Creating Environment Variable using the API Key 

Now, after completing the previous step, create an environment variable using the API key by running the following lines of code: 

echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

Configuring GitHub

Step 1: Logging in to GitHub Account and Reaching the Project

After completing the process of SendGrid configuration, as the next step to SendGrid GitHub integration, you need to configure the GitHub repository now. The first step is to log in using the credentials of the repository on the official GitHub website. The link is given here: https://github.com/login.

Step 2: Setting up Webhooks and Integrations

After logging in and navigating to the required repository, select the INTEGRATIONS and WEBHOOKS subsections in the settings section for providing the required URL, API keys, and corresponding actions.

Sendgrid Github - Integrations and Webhooks option in Github
Source: Self

Step 3: Entering SendGrid Credentials in Integrations

While configuring the above step, provide the SendGrid credentials for the integration like API key, URL, etc. which you generated in the SendGrid steps in the integrations subsection. Now, to access the above-created API variable, use the convention provided by your coding language. In the case of Python, it should look something like the following:

api_key = os.environ.get('SENDGRID_API_KEY')

Step 4: Coding Triggers and Actions/Workflows 

After configuring the integration, it’s time to navigate to the actions section of the repository and edit workflows in the code section with SendGrid scripts which basically helps in adding actions to their corresponding triggers in the repository.

Sendgrid Github - GitHub workflows
Source: Self

A sample SendGrid-based script written in Python to send emails is as follows:

import sendgrid
import os
from sendgrid.helpers.mail import Mail, Email, To, Content

sg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("test@example.com")  # Change to your verified sender
to_email = To("test@example.com")  # Change to your recipient
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, to_email, subject, content)

# Get a JSON-ready representation of the Mail object
mail_json = mail.get()

# Send an HTTP POST request to /mail/send
response = sg.client.mail.send.post(request_body=mail_json)
print(response.status_code)
print(response.headers)

Limitations of Manually Setting up SendGrid GitHub Integration 

  • Using the manual method of SendGrid GitHub integration requires you to make API calls and code custom workflows. Hence, it requires strong technical knowledge. Also, it is very time-consuming.  
  • Updating the existing API calls and managing workflows in both platforms requires immense engineering bandwidth, and hence can be a pain point for many users.

Conclusion

This article teaches you how to integrate SendGrid GitHub manually. It provides in-depth knowledge about the concepts behind every step to help you understand and implement them efficiently. Building a SendGrid GitHub Integration manually, using API calls can be challenging especially for a beginner & this is where Hevo saves the day. Hevo Data, a No-code Data Pipeline, helps you transfer data from a source of your choice such as SendGrid and GitHub in a fully automated and secure manner without having to write the code repeatedly. Hevo, with its strong integration with 100+ sources & BI tools, allows you to not only export & load data but also transform & enrich your data & make it analysis-ready in a jiff.

Want to take Hevo for a spin? Sign up here for the 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at our unbeatable pricing that will help you choose the right plan for your business needs!

No-code Data Pipeline for your Data Warehouse