A webhook is provided by some application to issue a HTTP POST request when a particular event happens. This is sometimes called a HTTP callback as one system will register to receive a call when something happens. In other words, call the registered system back when a certain event happens. Many applications support webhooks and this wiki post will illustrate a webhook using SendGrid and Slack.

In this scenario, a message will be sent from SendGrid to Slack when an email fails to be delivered. SendGrid offers a webhook for this and Slack provides an API. The only issue is request will need to be transformed during delivery so an Azure Logic App will be used for this. This is illustrated below:


Slack is a great service for collaboration and one great feature is the ability to post messages to a channel. In this example, there is an operations channel that we will post messages to when an email fails. This can be done in the Manage section of the directory in the Incoming WebHooks section:

Slack has done an impressive job with their documentation. I will not repeat the steps here other than to highlight the essentials. The following shows the channel that will receive a posted message.

And the webhook url details are shown below:

An example json message is also shown but we will not need this as Slack is supported in Azure Logic Apps.

Azure Logic App

An Azure Logic App is created to receive the callback from SendGrid and post the message to Slack. The image below provides an overview of the new logic app:

The first is create an endpoint for the SendGrid request to be received. Fortunately in the SendGrid documentation there is a sample response message that can be used to train the endpoint so that it knows how to parse the inbound message (note the HTTP POST URL as it will be entered in SendGrid below).

The message is then parsed and each body (as the request could contain multiple failed emails), is then sent to Slack as indicated below:

Posting the message to Slack is straightforward as their is a Slack component for posting messages:

After authenticating with Slack, the component allows you to pick the channel:

The following shows the configured component with a simple message:


SendGrid offers a powerful and full-featured solution to email delivery.  The service is highly scalable and extremely easy to provision in Azure. SendGrid offers several pricing plans including a free plan allowing up to 25,000 emails/month. SendGrid has many capabilities and the one we are interested in is the ability to send a message when an email fails to be delivered. This is called Event Notification and is located under Mail Settings:

The HTTP POST URL of the Logic App is entered as shown below and also note the control over the different type of events:

The following illustrates what the message looks like over in the Slack channel using the Test Your Integration button:


Webhooks are a convenient, simple and versatile way of performing simple integration between applications. This article provided a sample illustration and many of the features could be expanded upon. For example, the formatting of the message sent to SendGrid can contain rich content and the graphic associated with the event changed.

An important thing to mention is now that this integration has been put in place with an Azure Logic App, the flexibility is enormous.