This guide shows an end-to-end event pipeline that reads an event from a webhook, generates a formatted string, and publishes the result to Slack. While this is a simple example, it has many event notification use cases, such as:
submission from website forms (via Cloudflare workers or your custom backend).
activity from e-commerce platforms on purchases and shopping carts.
notifications from github on your projects’ activities.
alerts from financial products on your transactions.
notifications from any product that can invoke a webhook.
This pipeline uses the following features:
webhook: that creates a public API to receive external events, transform them, and publish them to a topic.
http-sink: that listens to the same topic and publishes them on Slack.
Objective
Show an example of how to build an event streaming pipeline that receives webhook events, transforms the input into a readable form, and generates an alert. We assume the events are generated by a user submitting a form, and we’ll format it accordingly.
Create a webhook configuration file called form-webhook.yaml :
meta:name:form-webhooktopic:form-eventswebhook:outputParts:bodyoutputType:jsontransforms:- uses:infinyon-labs/[email protected]with:spec:match:- key:"/type"value:"subscribe"format:with:"📢 {} ({}) subscribed on {}"using:- "/name"- "/email"- "/source"output:"/formatted"- key:"/type"value:"use-case"format:with:"🎊 {} ({}) wants to solve the following '{}' use-case:\n>{}"using:- "/name"- "/email"- "/source"- "/description"output:"/formatted"default:format:with:"{} ({}) submitted a request"using:- "/name"- "/email"output:"/formatted"
The webhook reads the JSON body, applies the json-formatter smartmodule to generate readable text, and writes the new record to a topic called form-events. Checkout labs-json-formatter-sm in github for additional information.
Create http-sink configuration file
Create an HTTP source connector configuration file called slack-form-alerts.yaml :
The sink connector reads from the form-events topic and uses the jolt smartmodule to shift the formatted string into a field called text per the Slack instructions. Checkout fluvio-jolt in github for additional information.
Add Slack webhook token to InfinyOn Secrets
The Slack webhook link is sensitive information, let’s add the access token part to secret in InfinyOn Cloud :
$ fluvio cloud secret set SLACK_USER_ALERTS <webhook-token>
Check out Slack Webhooks on how to create the webhook token.
Download SmartModules
Download the smartmodules used by the webhook ad the connector:
Check fluvio cloud webhook list to ensure it has been successfully provisioned. In checkout the webhook link that we’ll use to test the pipeline: https://infinyon.cloud/webhooks/v1/[token]