Good Vibe supports access tokens and a REST API, so that users can integrate it with other services to automate and create dynamic command responses.
In this article we will show how to use this feature to integrate Good Vibe with IFTTT, the That part of an IFTTT applet. This way you can select any trigger event available from the IFTTT catalog and update a Good Vibe commands based on it. In our example we will integrate the Weather Underground service to update our "The weather tomorrow" command every day.
Generating an access token
In order to access Good Vibe's REST API, we need to generate an access token. We can do this by opening the user settings menu and clicking on the "API Access Token"
Once we click we are presented with the option to generate an access token, so let's do this
After a while, our access token is generated.
Generating a token is needed only once. With this token we will tell Good Vibe that this is actually us and that we want to update commands using the API. This is why we should not share our access token with anyone. If you lose your token, you can revoke it or generate a new one.
Now let's copy the token, as we will need it later when making calls to the API.
Exposing a command for API access
By default the commands and their responses can only be updated through the UI, but if we want to expose the command for API access we need to explicitly do that. This is needed for better experience so that we know exactly which commands are exposed to the outside and it also allow us to remove the access at any time.
After we click, we are presented with details how to update the response of the command once it is exposed.
Let's copy the URL of the second sample, where the access token is provided as a query param
https://alexavibe.com/commands/e33d7327ae11c1fe13ada45f09c89680/response?access_token={YOUR_ACCESS_TOKEN}
you can now replace {YOUR_ACCESS_TOKEN} with the actual token from the first step.
Do not forget to expose the command by clicking on the "Expose" button.
Once a command is exposed you will see it labeled with "API access". Let's go on and save the commands.
At this point you may want to validate that we have configured everything properly, using your favourite REST client, or with curl we can do that:
curl -X PUT -H "Content-Type: text/plain" --data "this is the new response" https://alexavibe.com/commands/e33d7327ae11c1fe13ada45f09c89680/response?access_token={YOUR_ACCESS_TOKEN}
If the request returns 200 and in the Good Vibe application the value of the reponse is updated, we can continue forward.
Creating new IFTTT applet
Now let's go to IFTTT and create our own applet
You can choose any trigger you want, in our example we will use the Weather underground service and it's "Tomorrow's weather report" trigger.
This trigger is pretty simple to configure, we just need to set when to get the report for tomorrow's weather. Let's configure it for 4 PM, that means that every day at 4 PM it will trigger an event.
Wire up the
That part of the applet
IFTTT supports a generic Webhook as an action service that makes a web request to any service.
Now, let's configure how this service will call Good Vibe to update our command.
- For URL we need to provide the URL we prepared few steps above:
https://alexavibe.com/commands/e33d7327ae11c1fe13ada45f09c89680/response?access_token=f5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX7d
- For method, select PUT
- Content type: text/plain
-
The body we can construct however we like, we can pick ingredients that the trigger provides and mix them with custom text. In our example we will use
Looks like tomorrow, {{TomorrowsDate}}, will be: {{TomorrowsCondition}}. With temperatures varying between {{LowTempFahrenheit}} and {{HighTempFahrenheit}}
The keys wrapped with {{}} are ingredients and will be evaluated at the moment of the request with actual values.
And this is it!
Everything is ready and we can expect that every day at 4 PM the response of our Good Vibe command will be updated to contain the weather forecast for the next day.
For the sake of validating that everything works you may want to update the applet trigger to a time more close to the time you are developing the applet and wait if it will be triggered at the specified time.
Now we can invoke Alexa by saying
"Alexa, ask Good Vibe about the weather tomorrow".