How to Scan Book Barcodes with Your Phone and Add Them to the Book Tracker

Book Barcode to Notion.mp4

Welcome to – by far – the coolest tutorial in this Ultimate Books tutorial series!

In this guide, I’ll show you how to build a workflow that lets you scan book barcodes with your phone to automatically add them to Ultimate Books.

Once you have this workflow set up, you’ll be able to scan a barcode and get a new book page that includes:

  • Title

  • Author

  • Cover Image

  • Page Count

  • ISBN Number

In addition to the video guide above, below are full written instructions on setting up this automation.

Heads Up: I’ve made this tutorial as detailed and easy-to-follow as possible. However, this process does involve working with multiple tools and sending HTTP requests. It shouldn’t be difficult to set up, but it’s more involved than just downloading an app.

Full Written Guide

In this guide, I’ll show you how to quickly set this automation up. It consists of two parts:

  • A Pipedream workflow that receives an ISBN-13 number (an identifier for books), using it to look up the book’s information and create a new Notion page with it

  • A method for scanning the book’s barcode via an iOS or Android device

Once you have the Pipedream workflow set up, you can also send it requests with ISBN numbers in any other manner - e.g. sending a basic request with ReqBin.

How the Automation Works

When you run the barcode scanner automation on your phone, you’ll scan the book’s barcode and your phone will send off the ISBN number from that barcode to the Pipedream workflow you’ll set up.

Once the workflow is triggered, the following will happen:

  • If you’ve added a Google Books API key, it’ll search Google Books for that ISBN number

  • If it doesn’t find anything – of if you didn’t set an API key – it’ll use the Open Library API as a fallback. This API has more book records than Google, but typically stores fewer pieces of data about each book.

  • The workflow will construct a “book record” with any details it can find - Title, Author, Cover Image, Publish Year, etc.

  • It then creates a new page in Ultimate Books with all of this information.

This process typically only takes 5-10 seconds, so the upshot is that you’ll scan a book’s barcode and see the book in Notion just seconds later.

Before We Get Started

A few notes before we start building:

No Support Guarantee

The automation I’ll explain below is one that I provide free of charge; it is not officially part of any paid products I sell. I make this distinction primarily because I can’t guarantee support for it.

While I do my best to answer questions, I can’t guarantee an answer to every question – and my support team, who are trained to support our Notion templates, likely can’t answer questions about this automation’s code. Most of them aren’t programmers.

I wish I could guarantee support, but making that promise would prevent me from releasing this code in the first place. (Note: Since the code is provided, you can always ask ChatGPT or another model for help.)

If you do think you’ve found a bug, the best place to post is on the automation’s GitHub repo:

GitHub - TomFrankly/pipedream-notion-book-scanner

Android Support

On that note, I’m also extremely limited in the answers I can provide about making this workflow work with Android devices. I do not currently have access to an Android device – and, unlike iOS, Android does not have a built-in shortcuts app that can scan barcodes and send HTTP requests.

Therefore, I can only provide suggestions for making this automation work with Android devices. I’ll share links to apps that should work, but I’m unable to test them right now.

Pipedream Credits

Pipedream’s free plan is very capable, but note that it only provides you with 10 credits/day to run workflows. This workflow triggers each time you scan a book’s barcode, so on the free plan you’d be able to run it 10 times a day.

This is fine for scanning a few books at the bookstore, but you’ll likely hit the limit if you try to scan your whole collection at once.

In the future, I’d like to modify the workflow to be able to take many ISBN numbers in a single workflow run. Feel free to modify the code yourself to do this, if you’re feeling up to it. My code is free to modify for personal use.

Set Up the Pipedream Workflow

Pipedream is an automation platform similar to Zapier and Make.com, but with a few big differences – namely, Pipedream lets you write your own code in a much more robust way than other platforms.

They also let you share workflows you’ve built, which is exactly what I’ll do here. When you click this link, the entire workflow will be created for you:

Sign Up - Pipedream

Full disclosure: This link contains my referral code for Pipedream. If you end up upgrading to a paid account, I’ll receive a small commission at no cost to you. That said, this automation works perfectly well on their free plan. I share many, many custom-built Pipedream automations, so participating in their referral program helps to support that work! You can also find the full code for this automation near the bottom of this article if you want to build it manually.

Once you have the workflow in your account, you’ll need to configure and test each step.

Test the Trigger Step

In the trigger step, first hit Continue to set it up.

Next, copy the unique URL from the Select Event section. This is the URL to which you’ll want to send HTTP requests from your iOS Shortcut or Android app.

Don’t share this URL with others. Anyone who has it could send requests that will trigger your workflow, which would use up your Pipedream credits and add books pages to your Notion workspace. As a rule of thumb, you should only ever share these unique trigger URLs with people who should be using the workflow.

For now, we need to send it a Test Event, and the easiest way to do that is with ReqBin: https://reqbin.com/

At ReqBin, paste in your unique trigger URL and change the method from GET to POST. In the Content area, leave the method as JSON (application/json) and paste in the following:

{"isbn": "9781978632271"}

Finally, hit Send. This will send a POST request to your Pipedream workflow. The request has a JSON body with a single property (or “key”) called isbn - and its corresponding value is the ISBN-13 number of the book.

Back at Pipedream, select the POST event from the event selector. Do not hit Generate Test Event - it won’t work. You need to select the event from the dropdown.

In the Results section, you’ll see the ISBN-13 number you sent from ReqBin:

Hit Continue.

Test the Fetch_Book Action

The Fetch_Book action will use the ISBN number to fetch information from either the Google Books API or the Open Library API.

The Open Library API is truly open; you don’t need any API key or any kind of authentication to use it. It also has records for far more ISBN numbers than Google Books because it tries to have a record for every edition of a book. Google Books often doesn’t bother to store more than the first edition.

Best of all, it has an open cover images database, which means we can use it to set cover images in our Notion database. (The Notion API won’t let us upload images, so we have to rely on publicly-linkable images.)

However, Google Books usually has more data on each book title – e.g. it’ll often have the subtitle of a book, where Open Library won’t.

To use Google Books, you do need an API key.

For this reason, using Google Books is optional in this workflow, if you’d like to use it, obtain a Google Books API key using your Google account and set it in the Google Books API Key field.

Alternatively, you can create a Pipedream environment variable called GOOGLE_BOOKS - the workflow looks for either one. If you don’t know what an environment variable is, don’t worry about it - the field pictured above will work.

Set up your Google Books key (or don’t), and then hit Test.

If you sent that ReqBin request earlier, you should see the following in the Exports tab:

Hit Continue.

Testing the Create_Notion_Page Step

In this final step of the Pipedream workflow, we’ll create a new page in Notion with the information we fetched about the book.

First, authenticate your Notion account with Pipedream. When selecting pages, I recommend searching for and checking your entire Ultimate Books page – it contains the Books database, so Pipedream will get access to it.

Under Books Database, select your Books database. I’ve renamed my personal copy to “Books [T]” to make to differentiate it from the “Books” database in the main Ultimate Books template.

Under Book Information, paste in {{steps.Fetch_Book.$return_value}} or find this path in the dropdown. This gives the Create_Notion_Page step access to the returned book record from the Fetch_Book step.

The rest of the fields will show you options that correspond to properties in your Books database. The only required one is Book Title, but you can fill in any others you like.

Note that this action will work for any other Notion database - it doesn’t require Ultimate Books. As I mentioned, only the Book Title property is required, and all Notion databases have a title property by default. Currently, the properties shown below are the only ones my code supports.

Hit Test, and you should see a confirmation in the Exports tab:

Back in Ultimate Books, you’ll see the new page in the To Read section:

To finish, go back to your Pipedream workflow and hit Deploy. This will make your workflow live, ready to accept new requests.

Set Up the Mobile Workflow

To finish up, we’ll create a mobile workflow so you can scan a book’s barcode with your phone’s camera and send off the ISBN number to Pipedream.

In these instructions, I’ll show you how to do this on iOS using the built-in Shortcuts app.

If you’re using an Android device, scroll down to the Android section below for suggestions on how you can set up a similar workflow.

Set up an iOS Shortcut

Creating an iOS shortcut for scanning a barcode is very easy. Open the Shortcuts app and tap the + icon at the top-right to create a new shortcut. Give it a name, such as Book to Notion.

Add your first action and find the Scan QR or barcode action.

Then add a second action; for this one, search for the Get Contents of URL action. Tap the small arrow to open up the options, and configure it like so:

  • URL: Paste in the unique URL from the trigger step of your Pipedream workflow. (I usually use Slack to send myself this URL from my computer to my phone)

  • Method: POST (the default GET method is for requesting information from an external source. We want POST, as it’s the method for sending information)

  • Request Body: JSON

Under Request Body, click Add new field and choose Text:

  • Key: isbn

  • Text: Select variable → QR/Barcode

Hit Done.

That’s it! You can now tap the shortcut from the Shortcuts app.

You can also tap and hold your Home Screen, then hit the + icon to add a Shortcuts widget to it. Choose your Book to Notion shortcut. Now you’ll be able to run it directly from your Home Screen.

Set Up an Android Shortcut

Android does not have a built-in app for building automations like iOS does. However, in doing some research, I’ve found a couple of alternative solutions that may work for you.

First, there’s an app called QR & Barcode Scanner, POST & G that says it can scan QR codes and barcodes, as well as send POST and GET requests.

QR & Barcode Scanner, POST & G - Apps on Google Play

From what I can tell, there is an ad-supported free version, along with a $10 paid version.

Since I don’t have access to an Android device, I can’t test this app. But it seems to be a pretty simple solution.

Alternatively, there is a plugin for Tasker called AutoBarcode:

What It Is

Again, I can’t test this since I don’t have access to an Android device. However, you may find this post in the Coda forums to be a good guide:

Scanning a barcode to Coda using webhooks

Full Automation Code

You can use the template link above to automatically create the entire workflow in your account with just a few clicks. But if you’d like to build it manually – or just study the code here – here’s all the code.

This code is up-to-date as of June 14, 2024, but you’ll always find the most recent versions at the Github repo: https://github.com/TomFrankly/pipedream-notion-book-scanner

Note that the names of the steps are important! They must be Fetch_Books and Create_Notion_Page.

Fetch_Books

// Import Axios, which is used to make HTTP requests to APIs (in this case, Google Books and Open Library): <https://axios-http.com/docs/intro>
import axios from "axios";

// Import async-retry, which is used to retry requests if they fail: <https://github.com/vercel/async-retry>
import retry from "async-retry";

export default defineComponent({
  props: {
    google_books_key: {
      type: "string",
      label: "Google Books API Key",
      description: `If you'd like to use the Google Books API to fetch book data, either enter your Google Books API key here or store is as an environment variable with the name GOOGLE_BOOKS.
      
      You can get a Google Books API key by following the instructions here: <https://developers.google.com/books/docs/v1/using#APIKey>.
      
      If you don't enter a key here or store on as an environment variable named GOOGLE_BOOKS, this step will only use the Open Library API to fetch book data.`,
      optional: true,
      secret: true,
    },
  },
  methods: {
    /**
     * Fetches the book data from the given URL. This is a generic method that can make requests to multiple APIs.
     *
     * In this case, we'll use it to fetch data from both Google Books and Open Library.
     *
     * Uses async-retry to retry the request up to 3 times if it fails.
     */
    async fetchBookData(url) {
      return await retry(
        async (bail, attempt) => {
          try {
            console.log(`Fetching data from URL: ${url} (Attempt ${attempt})`);
            const response = await axios.get(url);
            if (response.status === 200) {
              return response.data;
            } else {
              throw new Error(`Status code: ${response.status}`);
            }
          } catch (error) {
            if (
              error.response &&
              error.response.status >= 400 &&
              error.response.status < 500
            ) {
              bail(
                new Error(
                  `Cannot retry due to error: ${error.message} (Status code: ${error.response.status})`
                )
              );
            } else {
              console.error(
                `Retrying due to error: ${error.message} (Status code: ${error.response.status})`
              );
            }
          }
        },
        {
          retries: 3,
        }
      );
    },
    /**
     * Gets the highest-resolution cover image available from Open Library, given the book's ISBN.
     */
    async fetchBookCover(isbn) {
      // Get the highest-resolution cover from Open Library that we can
      console.log(`Attempting to fetch the cover image.`);
      const sizes = ["L", "M", "S"];

      const baseCoverURL = `https://covers.openlibrary.org/b/isbn/${isbn}`;

      // For each size, starting from the largest size, see if the cover exists.
      for (let size of sizes) {
        console.log(`Checking cover size: ${size}`);

        // When we add "?default=false" to the URL, cover images that don't exist will return a 404.
        const coverURL = `${baseCoverURL}-${size}.jpg?default=false`;

        try {
          const response = await axios.get(coverURL, {
            validateStatus: (status) => status === 200 && status !== 404,
          });

          if (response.status === 200) {
            console.log(`Cover found for size: ${size}`);
            return coverURL.replace(/\\?default=false$/, "");
          }
        } catch (error) {
          if (error.response.status === 404) {
            console.log(`Cover not found for size: ${size}`);
          } else {
            console.error(`Encountered error fetching cover: ${error.message}`);
          }
        }
      }
    },
    /**
     * Builds the book title, appending the subtitle to the original title if it exists.
     */
    buildBookTitle(book) {
      console.log(`Building the book title.`);
      let title = book.title;

      if (book.subtitle && book.subtitle !== "") {
        title += `: ${book.subtitle}`;
      }

      return title;
    },
    /**
     * Constructs the final book record, removing any empty fields.
     */
    constructBookRecord(book) {
      // Remove empty fields from the book record
      const finalBookRecord = Object.keys(book).reduce((acc, key) => {
        if (book[key] !== "") {
          acc[key] = book[key];
        }

        return acc;
      }, {});

      console.log(`Final book record with blank fields removed:`);
      console.dir(finalBookRecord);

      return finalBookRecord;
    },
  },
  async run({ steps, $ }) {
    try {
      // Set a variable for the Google Books API key. If it ends up null, we'll use the Open Library API instead.
      let googleBooksAPIKey =
        process.env.GOOGLE_BOOKS && process.env.GOOGLE_BOOKS !== ""
          ? process.env.GOOGLE_BOOKS
          : this.google_books_key && this.google_books_key !== ""
          ? this.google_books_key
          : null;

      // Set up variables for the ISBN number and the initial book object
      const isbn = parseInt(steps.trigger.event.body.isbn.replace(/-/g, ""));

      const book = {
        db: "",
        db_id: "",
        status: "",
        title: "",
        author: "",
        cover_image: "",
        isbn_13: isbn,
        publish_year: "",
        page_count: "",
        full_record: "",
      };

      // Set up Google Books search variables in a high enough scope to use later
      let searchURL = null;
      let searchResponse = null;

      // Search for the book in the Google Books API, if the key is set. If not, skip directly to searching Open Library.
      if (googleBooksAPIKey) {
        console.log(`Searching Google Books for book with ISBN: ${isbn}`);
        searchURL = `https://www.googleapis.com/books/v1/volumes?q=isbn:${isbn}&key=${googleBooksAPIKey}`;
        searchResponse = await this.fetchBookData(searchURL);

        console.log(`Search response from Google Books:`);
        console.dir(searchResponse);
      } else {
        console.log(
          `Google Books API key not set. Only searching Open Library.`
        );
      }

      // Create an Open Library variable in a high enough scope, in case we need to use it later
      let openLibraryBook = null;

      // If the search was successful, store the book ID. Otherwise, use our fallback method to do it.
      if (
        searchResponse &&
        searchResponse.items &&
        searchResponse.items.length > 0
      ) {
        book.db = "google_books";
        book.db_id = searchResponse.items[0].id;
        book.status = "Exact match";
        console.log(`Found book in Google Books with ID: ${book.db_id}`);
      } else {
        console.log(
          `No book found in Google Books, or API key not set. Using Open Library method.`
        );

        // Search for the book in the Open Library API
        const openLibraryURL = `https://openlibrary.org/search.json?q=${isbn}`;
        const openLibraryResponse = await this.fetchBookData(openLibraryURL);

        console.log(`Search response from Open Library:`);
        console.dir(openLibraryResponse);

        // If the search was successful, get the book's other ISBN numbers and search Google Books for a valid match.
        if (openLibraryResponse.docs && openLibraryResponse.docs.length > 0) {
          console.log(`Found book in Open Library.`);
          if (googleBooksAPIKey) {
            console.log(
              `Searching Google Books for a match using other ISBN numbers for this title.`
            );
          }

          // Store the Open Library entry data in case we need to fall back on it
          openLibraryBook = openLibraryResponse.docs[0];
          // Get only the ISBN-13 numbers
          const ISBNArray = openLibraryResponse.docs[0].isbn.filter(
            (edition) => edition.length === 13
          );

          // If Google Books API is set, search Google Books for the book returned by Open Library
          if (googleBooksAPIKey) {
            // Loop through the ISBN-13 array, searching Google Books until we find a valid record.
            for (let number of ISBNArray) {
              console.log(`Searching Google Books for ISBN: ${number}`);
              const searchURL = `https://www.googleapis.com/books/v1/volumes?q=isbn:${number}&key=${googleBooksAPIKey}`;
              const searchResponse = await this.fetchBookData(searchURL);

              if (searchResponse.items && searchResponse.items.length > 0) {
                console.log(`Found a valid match in Google Books.`);
                book.db = "google_books";
                book.db_id = searchResponse.items[0].id;
                book.status = "Nearest match";
                break;
              }

              console.log(`No match found in Google Books.`);
              book.db = "open_library";
              book.db_id = openLibraryBook.key;
            }
          } else {
            // If Google Books API is not set, use the Open Library record.
            console.log(`Setting Open Library as the book database.`);
            book.db = "open_library";
            book.db_id = openLibraryBook.key;
          }
        } else {
          // Search wasn't successful in either book database. Return a generic record with the ISBN number alone.
          console.log(
            `No book found in Open Library. Returning generic record.`
          );
          book.title = `Unidentified Book with ISBN: ${isbn}`;
          book.isbn_13 = isbn;
        }
      }

      if (book.db !== "") {
        // If we found a valid Google Books match, query Google Books with the book ID to get the full record.
        if (book.db === "google_books") {
          console.log(`Fetching full book record from Google Books.`);
          const fullRecordURL = `https://www.googleapis.com/books/v1/volumes/${book.db_id}?key=${googleBooksAPIKey}`;
          const fullRecordResponse = await this.fetchBookData(fullRecordURL);

          console.log(`Full record response from Google Books:`);
          console.dir(fullRecordResponse);

          // Add the info to the book object
          book.title = this.buildBookTitle(fullRecordResponse.volumeInfo);
          book.author = fullRecordResponse.volumeInfo.authors?.join(", ") ?? "";
          book.page_count = fullRecordResponse.volumeInfo.pageCount ?? "";
          book.publish_year =
            parseInt(
              fullRecordResponse.volumeInfo.publishedDate.substring(0, 4)
            ) ?? ""; // Get only the year
          book.full_record = fullRecordResponse.volumeInfo;
        } else if (book.db === "open_library" && openLibraryBook) {
          // We didn't find a valid Google Books match, so we'll use the Open Library record.
          console.log(
            `No valid Google Books match found. Using Open Library record.`
          );

          book.title = this.buildBookTitle(openLibraryBook);
          book.author = openLibraryBook.author_name?.join(", ") ?? "";
          book.page_count = openLibraryBook.number_of_pages_median ?? "";
          book.publish_year =
            parseInt(openLibraryBook.first_publish_year) ?? "";
          book.status = "Exact match";
          book.full_record = openLibraryBook;
        }

        // Try to get the cover image from Open Library
        book.cover_image = await this.fetchBookCover(book.isbn_13);
      }

      // Construct and return the final book record
      return this.constructBookRecord(book);
    } catch (error) {
      throw new Error(`Error fetching book data: ${error.message}`);
    }
  },
});

Create_Notion_Page

// Import the official Notion SDK: <https://github.com/makenotion/notion-sdk-js>
import { Client } from "@notionhq/client";

// Import async-retry, which is used to retry requests if they fail: <https://github.com/vercel/async-retry>
import retry from "async-retry";

export default defineComponent({
  props: {
    notion: {
      type: "app",
      app: "notion",
    },
    databaseID: {
      type: "string",
      label: "Books Database",
      description: "Set you Books database.",
      async options({ query, prevContext }) {
        const notion = new Client({
          auth: this.notion.$auth.oauth_access_token,
        });

        let start_cursor = prevContext?.cursor;

        const response = await notion.search({
          ...(query ? { query } : {}),
          ...(start_cursor ? { start_cursor } : {}),
          page_size: 50,
          filter: {
            value: "database",
            property: "object",
          },
          sorts: [
            {
              direction: "descending",
              property: "last_edited_time",
            },
          ],
        });

        const options = response.results.map((db) => ({
          label: db.title?.[0]?.plain_text,
          value: db.id,
        }));

        return {
          context: {
            cursor: response.next_cursor,
          },
          options,
        };
      },
      reloadProps: true,
    },
    book_info: {
      type: "string",
      label: "Book Information",
      description: "Select the book information object from the previous step.",
    },
  },
  async additionalProps() {
    if (!this.databaseID) {
      return {};
    }

    const notion = new Client({
      auth: this.notion.$auth.oauth_access_token,
    });

    const database = await notion.databases.retrieve({
      database_id: this.databaseID,
    });

    const allowedTypes = ["title", "number", "rich_text", "files"];

    const properties = database.properties;

    const allowedProperties = Object.keys(properties).filter((key) =>
      allowedTypes.includes(properties[key].type)
    );

    return {
      title: {
        type: "string",
        label: "Book Title",
        description: "The title of the book.",
        optional: false,
        options: allowedProperties.map((prop) => ({
          label: prop,
          value: prop,
        })),
      },
      author: {
        type: "string",
        label: "Author",
        description: "The author of the book.",
        optional: true,
        options: allowedProperties.map((prop) => ({
          label: prop,
          value: prop,
        })),
      },
      publish_year: {
        type: "string",
        label: "Publish Year",
        description: "The publish year of the book.",
        optional: true,
        options: allowedProperties.map((prop) => ({
          label: prop,
          value: prop,
        })),
      },
      page_count: {
        type: "string",
        label: "Page Count",
        description: "The page count of the book.",
        optional: true,
        options: allowedProperties.map((prop) => ({
          label: prop,
          value: prop,
        })),
      },
      isbn_13: {
        type: "string",
        label: "ISBN-13 Number",
        description: "The ISBN-13 number of the book.",
        optional: true,
        options: allowedProperties.map((prop) => ({
          label: prop,
          value: prop,
        })),
      },
      cover_image: {
        type: "string",
        label: "Book Cover Image",
        description: "The file path to the book's cover image. You can select a Files & Media property here if you want to fill it with the book's cover image URL, which will also be set as the page's cover image.",
        optional: true,
        options: allowedProperties.map((prop) => ({
          label: prop,
          value: prop,
        })),
      },
    };
  },
  methods: {
    /**
     *  Creates a new Notion page using the constructed data object
     * */
    async createNotionPage(data) {
      // Create a new Notion client
      const notion = new Client({
        auth: this.notion.$auth.oauth_access_token,
      });

      // Log the data object for debugging
      console.log(`Data object for the new Notion page:`);
      console.dir(data);

      // Build a request that will retry upon failure
      try {
        return await retry(
          async (bail, attempt) => {
            try {
              console.log(`Creating new page in Notion (Attempt ${attempt})`);
              const response = await notion.pages.create(data);
              return response
            } catch (error) {
              if (error.status >= 400 && error.status < 409) {
                bail(
                  new Error(
                    `Cannot retry due to error: ${error.message} (Status code: ${error.status})`
                  )
                );
              } else {
                console.error(
                  `Retrying due to error: ${error.message} (Status code: ${error.status})`
                );
              }
            }
          },
          {
            retries: 3,
          }
        );
      } catch (error) {
        throw new Error(
          `Failed to create the new page in Notion due to error: ${error.message}`
        );
      }
    },
  },
  async run({ steps, $ }) {
    // Set an easily-referenced variable for the book object
    const book = this.book_info;

    // Construct the new page object. Conditionally add properties if they are set by user AND have a value in the book object to set.
    const data = {
      parent: {
        database_id: this.databaseID,
      },
      // We'll use short-circuit evaluation to conditionally add the cover and optional properties.
      ...(book.cover_image && {
        cover: {
          external: {
            url: book.cover_image,
          },
        },
      }),
      properties: {
        [this.title]: {
          title: [
            {
              text: {
                content: book.title,
              },
            },
          ],
        },
        ...(this.author &&
          book.author && {
            [this.author]: {
              rich_text: [
                {
                  text: {
                    content: book.author,
                  },
                },
              ],
            },
          }),
        ...(this.publish_year &&
          book.publish_year && {
            [this.publish_year]: {
              number: book.publish_year,
            },
          }),
        ...(this.page_count &&
          book.page_count && {
            [this.page_count]: {
              number: book.page_count,
            },
          }),
        ...(this.isbn_13 &&
          book.isbn_13 && {
            [this.isbn_13]: {
              number: book.isbn_13,
            },
          }),
        ...(this.cover_image && book.cover_image && {
          [this.cover_image]: {
            files: [
              {
                name: "Cover Image",
                external: {
                  url: book.cover_image,
                }
              }
            ]
          }
        })
      },
    };

    // Add the new page to the database
    const response = await this.createNotionPage(data);

    // Return the response from Notion
    return response;
  },
});