Respond to customer reviews
Overview
This recipe demonstrates how to use Airtop SDK to automate responses to customer reviews in a restaurant’s Facebook page.
The script below will start an Airtop session, go to Facebook, ask the user to sign-in if required and respond to the first uncommented customer review.
Even though this recipe will walk you through the CLI script, the project contains a Vercel application that you can run locally in your browser.
Prerequisites
To get started, ensure you have:
- Node.js version 20+ installed on your system.
- An Airtop API key. You can get one for free.
Getting Started
-
Clone the repository
Start by cloning the source code from GitHub:
-
Install dependencies
Run the following command to install the necessary dependencies, including the Airtop SDK:
We use turbo to build all the necessary packages in the
examples
repo. Build the packages by running:Follow the turbo installation guide to set it up.
-
Run the script
Go to the project folder and run the Node.js script:
Script Walkthrough
The script in src/cli.ts
performs the following steps:
-
Initialize the Airtop session
First, we ask for an Airtop API key and an optional Profile ID in order to initialize the
FacebookCommenterService
class which is responsible for the session management.cli.tsUnder the Hood
facebook-commenter.service.ts - initializeSessionAndBrowser -
Verify if the user is signed-in
We prompt the home page to verify if the user has signed-in before we continue. In case you need to enter your Facebook credentials you will see printed in the console a link to the session’s Live View in which you can safely log in to your account.
cli.tsUnder the Hood
facebook-commenter.service.ts - checkIfSignedIntoWebsite -
Find the first uncommented review
We now go to the “Reviews” section of the restaurant and extract the first uncommented review, then we generate a reply addressing any positive or negative aspect of the customer’s review.
cli.tsUnder the Hood
facebook-commenter.service.tsYou should be able to see in the console the data extracted from the page and the generated reply in JSON format.
-
Like and comment
If the customer left a positive comment we order the agent to hit the like button, then we reply to the customer with the response previously generated.
cli.tsUnder the Hood
facebook-commenter.service.ts - replyToCustomerLearn more about clicking, typing, and hovering in Page Interactions.
-
Clean Up
Finally, the script terminates the session.
cli.tsfacebook-commenter.service.ts - terminateSession
Summary
This recipe shows how you can use Airtop to improve your customer relations by extracting relevant information and interacting with their reviews while saving time.