In this guide you'll integrate Knock with your application and send your first notification using Knock.
You can find your API key under the 'Developers' section of the Knock dashboard. As a best practice, your API key should be set as an environment variable and should not be checked into source control.
Knock needs to know about your users to be able to send them messages. At a minimum we need the user's name, email address, and a unique id with which to identify them.
You'll keep user information up to date in Knock using the
Best practice is to make an identify call to Knock when a new user is created and when any Knock-relevant user property changes. This way your user data is always up to date in Knock and we have what we need to send them messages.
🔐 Security first 🔐
We don't take your user data lightly. For more on our security practices, contact us at firstname.lastname@example.org.
Next we'll log into the Knock dashboard to create our first workflow in Knock.
A workflow takes a
notify call, runs it through a set of logic configured by you in the Knock dashboard, and outputs the actual messages that will be sent to your end users. All channel routing and message design takes place within the workflow.
To create your first workflow, log into the Knock dashboard and click "+ Workflow" in the top right corner. We're going to be using the "New comment" template for this example, so select that template and we're all set. Before we head back to your backend, we'll want to jump into the workflow and pull out the sample payload data. This sample payload is auto-generated by the workflow creation process within the Knock dashboard. It gives us the JSON blob we'll need to pass through as data in our notify call to populate any of the custom properties required in our workflow.
When you want to notify a set of users simply call the
notify function to trigger the workflow you want to send. When calling the
notify function, you'll pass in the
recipients you want to receive messages sent by the workflow, as well as the
data (which we received during step 4) required to populate those messages.
Knock uses a logically separated environment model to control the roll-out of your notifications. When you're happy with the way your workflows work and look, you just need to publish them to production to start sending notifications to your real users.
This was a simple overview to send your first notification with Knock. Read on to see how Knock can drive your notification needs, no matter how complex they might be.