In order to use The Bot Platform’s API with OAuth you need to generate a bearer token using the Client ID and Client Secret from your app. Please note that a bearer token is only valid for 60 minutes. This means that you will need to generate a new bearer token every 60 minutes in order for your API connection to continue running, however this tutorial will show you how to automate this process.
For this demo, we will automatically create a new bearer token every 61 minutes and add this to a spreadsheet. We recommend you store your bearer tokens securely so you may wish to use a secure database or something similar when you build out your solutions.
Go into integromat and create a new scenario.
The first module we need is the Http ‘Make a Request’ module.
We need to set it up as follows:
In the URL field, you want to paste the URL https://api.thebotplatform.com/oauth2/token
You want to change the method to POST
The body type should be Application / x-www-form-urlencoded
Now we need to add some fields.
Create a new field and give it a key of client_id. Now paste in the Client ID from your app on The Bot Platform.
Create another field called grant_type. Use the value client_credentials in the value box.
Create another field called client_secret. Paste the Client Secret from your app into the value field.
Make sure the parse response checkbox is ticked and click ok.
Now we want to save that value into a spreadsheet. Create a new spreadsheet and add two columns, Bearer token and App used in.
Now in your integromat flow you want to add a second module that is a Google sheets, update a row.
Select the spreadsheet you have just created and select an empty row in your spreadsheet. Add the bearer token generated in the first module to your spreadsheet and make sure you reference the name of the app it is used in.
The final step is to make sure this scenario runs every 61 minutes. Click on the clock symbol at the bottom left. Change the Run Scenario to at regular intervals. Set the interval to 61 minutes. Click ok and then turn your scenario on. It will now generate you a new bearer token every 61 minutes that you can use in other scenarios.
Updated over 1 year ago
Prerequisites to this tutorial are: