This app card, built with HubSpot’s UI Extensions, use the free, open-source Open Library API to search for books, add them to a quote, and generate a deal from a Contact record.
This project is split into two parts:
book-quote-api/- A backend built with NextJS to expose endpoints to both HubSpot and open-source APIssrc/- The frontend public app containing one app card that works on contact records
There are a few things that must be set up before you can make use of this project.
- You must have an active HubSpot account.
- You must have the HubSpot CLI installed and set up.
- You must have an OAuth flow which will be used to obtain a HubSpot Access Token. To learn more about OAuth, visit our documentation. To get up and running with our NodeJS OAuth Quick Start, check out the GitHub repo.
- With your OAuth flow running in the background, navigate to the
book-quotes-api/directory and runnpm installto install the required dependencies for the NextJS project. - Create a
.env.localfile in this directory to house your HubSpot Access Token (generated from the OAuth workflow). You can find an example of this file insample.env.local.
HUBSPOT_ACCESS_TOKEN='YOUR_ACCESS_TOKEN'
- Now, you’re ready to start the development server! Be sure to take note of the port the project is running on, as the local proxy will need to be configured later.
npm run dev
- Clone this project to your local machine for local development
git clone https://github.com/hubspotdev/ui-extensions-examples
- Navigate to the app card extensions directory
cd deal-generator
- If you haven’t already done so, install the HubSpot CLI globally with NPM
npm install -g @hubspot/cli@latest
- Connect your HubSpot account with the HubSpot CLI. This will prompt you to open your browser and copy/paste your account’s personal access key.
hs account auth
- Install project dependencies with the HubSpot CLI
hs project install-deps
- Upload the project to your connected HubSpot account. This should automatically trigger a deployment of the project as well.
hs project upload
- Start the local development server. If the project did not previously exist on the connected HubSpot account, this will prompt you to install the app onto your connected HubSpot account. Connect the app, and select
Return Home.
hs project dev
- Add the app card(s) to a Contact record by going to
Settings>Integrations>Connected Appsand selecting the desired app. Navigate toApp Cardsand find all app cards available with the project. To add a card to a record view, selectManage Locationand add the card to your desired view and location. Navigate to a Contact record where the card was recently added and ensure there is aLocal Developmentbadge next to the title of the card. You’re ready to start coding!
When making changes to configuration files ({CARD_NAME}-hsmeta.json and app-hsmeta.json), be sure to stop the development server and use hs project upload to update the project before restarting the development server.
This app card offers users the ability to: Search for books: Search for books by title, author, or ISBN using the OpenLibrary API
Build a Cart: Add or remove books from the cart and toggle between the book search and cart views
Generate a quote deal from the cart items: Generate a quote deal from the cart items and add it to the contact record with the HubSpot Deals API. After the quote is generated, click the link in the banner to view the deal in HubSpot.
To learn more about building app cards with UI Extensions, visit the HubSpot app cards landing page and check out the HubSpot app cards developer documentation.
Created By: Bree Hall