Response Demo Application
This repository contains an example implementation of the Bazaarvoice Response API for our clients to reference in building their own integrations.
- Obtain a API key for Response API.
- Obtain a API key for Conversations API.
- Obtain OAuth credentials.
- Obtain a test reviewId to respond to. This can be done through the Bazaarvoice workbench or using the reviews endpoint that is part of the Conversations API.
What is the sample doing?
The response demo application uses three Bazaarvoice solutions - Conversations API, Response API, and OAuth in one application.
After modifying the configuration files, described below, and starting the application, users must authenticate.
They are then directed to a generic search interface requesting a reviewId.
At that point, an call to the Conversations API returns review data.
An API call is also made to the Response API to obtain any existing client responses. This is done to ensure the latest response data is obtained. There is a slight delay for responses to ELT back to the Conversations API data store.
For existing client responses, HTML controls are available to EDIT and DELETE the responses. There is also the ability to create a new response. Two inputs are required for new responses, Department(string) and Response(string). For the purpose of the demo, the Department uses an hard-coded input dropdown.
Open the Command Line or Terminal.
Run the following commands to get a copy of this repository on your PC and navigate into it.
git clone https://github.com/bazaarvoice/response-demo.git cd response-demo
Make sure you have
- For instructions on installing Docker, see this
server/server-config.jsfile to contain your backend credentials for different services.
client/src/utils/config.jsfile to contain your client-side credentials for different services.
- Make sure you are in the cloned directory and run following commands from your terminal:
docker build -t response-demo . docker run -p 127.0.0.1:5000:5000/tcp -i -t response-demo:latest
- You can use the application by going to
http://localhost:5000in your browser.
This application is split into two components - a Node.js Express server and a client-side React app. You can read more about this kind of setup here.
- The server makes calls to the Bazaarvoice OAuth2 service for authentication and exposes endpoints to interact with the Response API.
- On the client-side, client.js provides modular functions which are used by front-end components to interact with the application's back-end, and with Bazaarvoice Conversations API to fetch reviews.
- The core front-end consists of two pages which are composed from four React components:
- Search Page: This is a simple page with a search bar which expects user to enter a Review ID which leads them to the Review Page.
- Review Page: This page expects a Review ID from the query parameters. It then queries the Conversation's API to fetch the corresponding review. Further, it queries the Response API to fetch all client responses for that review and renders the ClientResponsesSection component with that data. In turn, this section renders each client response as a ClientResponse component.
The application cannot maintain proper user sessions
The express server currently uses just short-lived cookies for storing OAuth2 tokens. In a production application, you should maintain user sessions using cookies and session storage.
Current server implementation does not explicitly all handle error responses from API
All of the Bazaarvoice APIs send different error responses for invalid calls and a production application should handle and display them properly to the end user. Currently, this application assumes most calls to be valid and doesn't do explicit error handling.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Found a bug or missing feature? Please open an issue! Send your feedback. Send your pull requests. All contributions are appreciated.