Configuring your server for webhooks
Learn how to set up a server to manage incoming webhook payloads.
Now that our webhook is ready to deliver messages, we'll set up a basic Sinatra server to handle incoming payloads.
Writing the server
We want our server to listen to POST requests, at /payload
, because that's where we told TextMaster our webhook URL was. Because we're using ngrok to expose our local environment, we don't need to set up a real server somewhere online, and can happily test out our code locally.
Let's set up a Sinatra application to do something with the webhook's payload. Our initial setup might look something like this:
Start this server up with:
Since we set up our webhook to listen to word count completion on documents, go ahead and create a new project with at least one document and let the word count analysis complete. Switch back to your terminal, you should see something like this in your server's output:
Congratulations! You've successfully configured your server to listen to webhooks. Your server can now process this information any way you see fit. For example, if you were setting up a "real" web application, you might want to log some of the JSON output to a database and trigger business workflows.
Last updated
Was this helpful?