Learn From Your Customers
My API experiment - sending review invitations by text message
keskiviikkona 13. kesäkuuta 2018
Trustpilot APIs are great, we get that. But what can you actually do with them?
After being asked that question a lot, I decided to embark on a journey of fun API experimentation. My goal? To discover cool new ways to use our APIs that you won’t find in our product line.
Keep reading to get all the details of my cool experiment, or jump straight to the results - a Twilio-Google Sheets-tool that can send review invitations via text message.
I’m sharing this tool as fun inspiration for how to implement Trustpilot’s APIs. You won’t find it anywhere else, and it’s not a part of Trustpilot’s product line. I hope my experiment inspires you to do some API testing of your own.
My review invitation text message tool
To get started, you’ll need a key and secret for the Trustpilot APIs. Don’t know what that means? Then it’s time to get your developer involved.
To open and see the code for any of the Google Sheets, go to the Tools tab, and then the script editor. Most of the code that interacts with Trustpilot APIs is hidden away in a small library included in the script.
To get our full API documentation, look here.
The details of my experiment
I started off by testing our APIs with nifty Google Sheets. I chose this method because with Google Sheets you can create extensions using JavaScript, you can build small tools to optimize workflow, and to top it off, you can call APIs from other services.
Using Twilio and Google Sheets
I wanted to see how hard it would be to build a small tool that would let me send review invitations via SMS. Turns out, it was fairly easy.
After checking out some different tools for sending text messages, I decided to go with Twilio.
Twilio has well-documented APIs and a free trial, so I could easily test out my ideas. I set up my account, played around with the Twilio APIs, and figured out how to set up the authentication and finally, how to send out text messages.
Now I was ready to build a Google sheet with columns that include all the parameters needed for creating an invitation link:
-
Trustpilot API parameters - order ID, customer name, email, locale (language)
-
Twilio API parameters - country code, phone number and the actual text message copy
I also included tags as a parameter, making it possible to tag review groups about e.g. product lines, store names, etc.
Building the Google Script
Once the parameters were in place, I could write the Google Script. Trustpilot has a small library with a Trustpilot API client for Google Sheets. Its main function is to handle authentication for the API and generate invitation links. Here are the steps I went through to build the script:
-
I got an instance of the Trustpilot API client
-
I used the “findBusinessUnitId” method to get the unique ID of my domain/website address (this is required when using the Trustpilot API)
-
I went through the Google Sheet rows using the “getInvitationLink” method to create an invitation link with order ID, customer name, email, locale and tag
-
I merged the copy for the text message with the link
-
I used the Twilio API client to send the merged text message using the “sendSMS” function.
And voilà! The result is a Twilio-Google Sheets-tool that can send review invitations via text message.
I hope my experiment will inspire you to do some API testing of your own. For more information and inspiration visit apps.trustpilot.com and developers.trustpilot.com.
Some final pointers
If you want to try the same experiment using a Twilio trial, keep in mind that you’ll only be able to send text messages to your own phone number.
Also, make sure to select an SMS enabled number when you pick your free trial phone number. Have fun!
Written in collaboration with Oline Damborg Schøler
Find out more about Trustpilot reviews, read our Complete Guide to Reviews here.