webhook setup
In order to run the solution without mocks we have two dependencies:
Setup Overview
Start up our service
In the project root directory type docker-compose up - to start Kafka and Kowl (Kowl is a Kafka UI)
You should be able to see the Kowl interface ku running on pot 8080
Next, run the event activity service listening on port 5000.
At this point we are listening for messages on port 5000 and -- when we receive them -- we'll forward them on to Kafka. But Sendgrid needs a public ip address to send messagefs to. That's where ngrk comes in.
Using ngrok
Ngrok provides a public IP address for us, and forwards any traffic it receives on that address to our local service.
Start up the ngrok service -- giving it the port our event activity service is listening on (5000) and get the public Forwarding IP address in the output. ngrok will proxy any trafiic received on that address to our local service.
prompt>
npx ngrok http 5000
in the example above ngrok is proxying public ip http://78e3-73-96-191-223.ngrok.io to our local event activity listener.
Configure Sendgrid to send events
In the SendGrid account site navigate to:
settings --> Mail Settings --> Event Webhook
And fill out the webhook form:
To be on the safe side also go to:
settings--> Tracking
and set:
Open Tracking on
Click Tracking On
Sample email
We can use the Sendgrid mailer service from the previous walk-through to send and email.
Viewing events
In a few minutes we should see events coming across our service, and if we open Kowl at port 8080 we'll see those events being saved in the sendgrid_events
topic.
Sendgrid will return a batch of events - having different schemas -- on the event activity feed. We'll get this payload in the response body of our POST /events endpoint.
Last updated