This is a step by step tutorial on how you can get your most searched terms into a Slack channel by using Postman.
This tutorial assumes you already have Algolia implemented and have data to send to Slack. If you would like to get started with that first, here is a tutorial on how I implemented Algolia in our Gatsby App.
Here is what we are going to do:
- Set up a Slack App
- Get the Algolia API Keys
- Create a GET request in Postman to store our Algolia Search Results in a global variable
- Post the global variable data from Postman to Slack
- Setup a Monitor in Postman to update Slack with Algolia Search Terms every week
Let’s get started 🦄
Setting up a Slack APP in your Slack App
Slack has some pretty slick docs on how to get started on creating an APP in Slack. I am going to walk you through the process with images. We first have to create a new Slack App here and attach the newly created APP to a workspace.
Once this is done, you can select ‘Incoming Webhooks’ settings on the next screen
You can then add a New Webhook to Workspace, which will open up a new screen and you can select the Slack Channel that you want to send your Algolia search results too.
You should now see a new Slack Channel in your overview and your sample request will show the URL to post to a channel. We will need this URL for our POST Request in Postman later.
Yay! Slack has already been setup. Now on to Postman 🏃
Setting up your Postman collection
We are going to create a new collection in Postman with a GET request, to get the most searched terms from the Algolia Analytics REST API and a POST Request, to post those terms to the Slack API.
We are then going to setup a monitor to control when the most searched terms are pushed to Slack in order to inform our Stakeholders.
So let’s first create a new collection in our Postman Client:
And then add a GET and a POST request:
GET request from Algolia
We first want to get the results from the Algolia Analytics API. This is the URL:
Index, should be the name of the Algolia Index you want target for most searched terms.
Algolia analytics API Auth
In order to get the results, we have to send the Algolia Application ID and the Algolia API key for the Algolia Index in the headers of the request.
Navigate to the Headers Tab in Postman and add\
- `X-Algolia-Application-Id` for your Algolia Application ID\
- `X-Algolia-API-Key` for your Algolia Admin Key like
You can find your Algolia Header Keys in your Algolia Dashboard under ‘API Keys’:
You should now see your results returning when hitting send:
How do I pass these now on to Slack via the Post Request?*Luckily Postman, makes this super easy with Global Variables. Let’s do it!
POST Request to Slack
Navigate to the ‘Tests’ tab and in here we are going to push our API response, most searched terms, into an array and store this array in a global variable. We can then call this variable in the POST request and push the data in the array to Slack.
In this example, I want to report on most searched term and how often that term was searched for. I store both values in a global variable called: `topSearchBlog`
When you click on the eye button in the top right hand corner, you can see your results being stored in the section `Globals`
In our POST request, we now have to define one Header:
`Content-Type` and give it the value: `application/json`.
In the Body tab, select ‘raw’ and define the message that you want to post in your Slack Channel.
This is what I am posting to ours:
You can find the Slack API call in your Slack App ‘Incoming Webhooks’ tab, which we set up earlier: This is what mine looks like:
Hit send and you should get a status ok.
And bing, here are our most searched terms:
💥 BOOM! Most Search Terms from Algolia are now in our Slack Channel.
Setting up a Postman Monitor
I want update the slack channel with most searched terms, every Monday morning at 9 am. I can set this up in a few clicks with a Postman Monitor.
In order to do that go back to Postman and next to the collection name, there is a button that looks like play.
Just click ‘Create Monitor’ and set the time you want to push the most searched terms to Slack.
Hit `Create` and you are all set for automatic run of your collection. The monitor will now, every Monday morning at 9am, GET your data from Algolia and POST it into your Slack channel.
Congratulations, this completes the tutorial on how to setup an Algolia/Slack integration with Postman and push your search analytics to a Slack channel on a regular basis with Postman Monitors.
You can also report on ‘most searched terms with No Results from the Algolia REST API. Simply create a new collection and hit the correct Algolia Analytics endpoint
Do not forget to create a different global variable for each endpoint you query to not pollute the same variable with different request results.