Testing a Product & Service Review Invitation Tool With APIs

Testing a Product & Service Review Invitation Tool With APIs

Ok, I admit it. I’m a bit of a nerd who loves to play around with APIs.

A while back, I started experimenting with Trustpilot’s APIs. I knew our APIs were awesome, but I wanted to find out what level of awesomeness could be achieved with them. I ended up building this neat tool that can send review invitations via text message . I was excited about the results and (not to toot my own horn), but so was everyone else.

I got loads of requests to do some more API testing, and product reviews, in particular, was a popular topic. So I delved into a new experiment, hoping to discover more ways to implement Trustpilot’s APIs and hopefully inspire some fellow API-lovers along the way.

Read on to learn about my API journey, or go straight to the fruits of my labor - an invitation tool that triggers product and service reviews.

By the way, I’m sharing this tool as inspiration for how to implement Trustpilot’s APIs. It’s not a part of Trustpilot’s product line, just me having fun.

Basic know-how before you try out my invitation tool

Before getting started, you’ll need a key and secret for the Trustpilot APIs. If you’re not a developer, it’s time to reach out to one for help. You (or your developer) will need access to our full API documentation. 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.

Good times testing APIs - Here’s how I built my invitation tool

Like my last experiment, I chose to work with Google Sheets, so I could create extensions using JavaScript, build small tools to optimize workflow, and call APIs from other services.

I wanted to find out how to call the Trustpilot APIs to trigger invitations for service and product reviews. My goal was to create a spreadsheet that triggered direct email invitations to customers based on a list of customer data, including product purchases. I also wanted the option of pulling one-click links from the list so that the links could be placed in other customer emails e.g. via Mailchimp.

It sounds a bit complicated, but I managed to pull it all together...

Building the Google Sheet

First I had to create the input data sheet. I inserted the columns that include all the parameters needed for creating an invitation link: customer name, email, order ID, locale (language) and the email template ID.

I also included tags as a parameter. Tags are not a requirement, but they’re great if you want to tag review groups about e.g. product lines, store names, store locations, etc.

Then I added all the parameters for products: product name, URL, SKU and image URL. I needed an option for multiple products for each order, so I went with a multiple lines format - one line for each product connected to the same order. And then I repeated the customer data (email, order id, etc.)

Building the Google Script

Now the parameters were ready, so I moved on to build the Google Script. I went over the list and made a single data object for each order, including the product(s) in that order and the service review data.

I found out that the invitation for product reviews only functions in conjunction with a service review. So when I put in an API request for a product review invitation, I started by requesting a product review link, and then I requested a service review invitation.

I noted that the email must instruct the user to follow the product review link once they’ve completed the service review.

Here’s how I built the rest of the script:

I went through my list of orders, and for each order I created a product review invitation link using the getProductInvitationLink. I requested the invitation from the service review invitation API using the sendInvitation method. I used our small library with the Trustpilot API client for Google Sheets.

Note: the main function of Trustpilot’s small library is to handle authentication for the API, trigger invitations and generate invitation links for the product reviews. If you’re interested in seeing the API calls, download the library and take a look.

One-click invitation links

Finally, I wanted the list of invitation links to work in other email tools as well. This could be useful for companies who want more configuration options. For instance, some companies might want to configure their product review invitations to be sent out one or two weeks after their service review invitations. (At the moment, Trustpilot Invitations don’t support this, but companies can send out their Trustpilot invitations by placing a one-click invitation link in an email tool like Mailchimp or similar.)

I followed the same procedure as above, using the getInvitationLink method to get a service review invitation link, and again, I passed in the product review link as a parameter to get a combined invitation link. Then rather than requesting the invitation from the API, I just put all the links into a spreadsheet.

And here it is, the result of my successful experiment: an invitation tool that triggers product and service review invitations .

I hope my experiment encourages other API enthusiasts to jump on the testing wagon. You can get more inspiration from apps.trustpilot.com and developers.trustpilot.com.

Written in collaboration with Oline Damborg Schøler.

New Call-to-action