How to Auto-Generate Social Media Posts For a Business Conference Using Bannerbear (Node.js)

Save time and enhance your event’s online presence with this step-by-step Node.js tutorial. Learn how to use Google Sheets, Google Drive, and Bannerbear to automatically create images for social media posts and streamline your content creation process.
by Josephine Loo ·

Contents

    In today's digital age, social media is essential for promoting events, including business conferences. Creating engaging content is crucial to attract and inform attendees. However, manually crafting posts for each speaker, session, and announcement can be time-consuming and tedious.

    In this tutorial, we'll learn how to use Google APIs and Bannerbear, a powerful visual automation tool, to simplify the process of generating social media posts for a business conference. We'll write a Node.js script to retrieve the conference's guest list from a Google Sheets and the guests' photos from a Google Drive folder. This information will then be passed to Bannerbear to automatically generate images for social media posts.

    By the end of this tutorial, you'll be able to write a script that creates consistent and visually appealing social media posts for a business conference with minimal effort:

    LinkedIn Post.png

    What is Bannerbear

    Bannerbear  is a tool that allows you to automatically generate custom images, videos, and more from templates. It offers APIs and libraries in various popular programming languages, such as Nodes.js, Ruby, and PHP, making integrating image generation and other media manipulation functionalities into your application/project effortless.

    To generate images or videos automatically, you need to create a design template which serve as blueprints for creating the images and videos in Bannerbear. A design template can consist of:

    • Static objects - These remain the same in every generated image (e.g. a company logo)
    • Dynamic objects - These change based on data you provide (e.g. text, images)

    Here’s an example of a Bannerbear design template:

    Bannerbear design template example.png

    By passing different data to the API, you can alter the values of the dynamic objects and automatically create unique content based on a single template. Now that you have a basic understanding of Bannerbear, let’s get started!

    Pre-requisites

    Before we begin, make sure you have the following:

    Creating a Bannerbear Design Template

    First, sign up for an account and create a new project in your account. Then, duplicate the template below to your project by clicking on it:

    Bannerbear Event Guest Social Media Post template

    The template contains dynamic objects like text_name, event_role, and image_container. The values of these objects can be changed when making an API call to Bannerbear to generate social media posts for different guests automatically:

    Bannerbear Template - Event Guest Social Media Post.png

    Next, get the project API key and template ID. We will need them in our code to access the project and template later.

    Bannerbear Template - Event Guest Social Media Post - API key and template ID.png

    Setting Up Google Sheets and Google Drive

    We will retrieve the guests' names, roles, and images from a Google Sheets and a Google Drive folder to automatically generate social media posts for the business conference.

    Google Sheet

    Open Google Sheets and create a new spreadsheet with the following columns: Name and Role. Populate the sheet with the guest details:

    Business conference Google Sheet screenshot.png

    We will need the sheet ID to access it in the code. You can find your sheet ID from the URL, located between d/ and /edit:

    how to find a Google Sheet ID.png

    🐻 Bear Tip: Change the access to “Anyone with the link” to ensure that it is accessible.

    Google Drive

    Create a folder in Google Drive and upload the guests' photos to it. Make sure the filenames match the names listed in the Name column of the Google Sheet:

    Business conference Google Drive folder screenshot.png

    Similarly, we need the folder ID, which can be found in the URL after folders/:

    how to find a Google Drive folder ID.png

    Save the IDs in a secure location, as we will need them in the code later.

    Enabling Google Sheets and Google Drive APIs

    To retrieve data from Google Sheets and photos from Google Drive using Node.js, we need to enable the Google Sheets and Google Drive APIs on the Google Cloud Platform.

    Step 1. Create a New Google Cloud Project

    Go to the Google Cloud Console and create a new project:

    Google Cloud console - create a new project.png

    Enter a name for your project and click “Create” to continue:

    Google Cloud console - enter the project name.png

    Then, selected the project as your working project:

    Google Cloud console - select the new project.png

    Step 2. Enable Google Sheets and Google Drive APIs

    Search for "Google Sheets API" and "Google Drive API" in the search bar, and enable both of them:

    Google Cloud console - search API.png Google Cloud console - enable Google Drive API.png Google Cloud console - enable Google Sheets API.png

    Step 3. Create an API Credential

    To use the APIs in our Node.js code, we need to create credentials. The available options include API keys, OAuth 2.0, and Service Accounts. For this tutorial, we'll use an API key.

    Go to the “Credentials” tab and click “Create Credentials > API key” to generate a new API key:

    Google Cloud console - create credentials.png Google Cloud console - create an API key.png

    Once the API key is created, copy and keep it somewhere safe:

    Google Cloud console - copy API Key.png

    Setting Up the Node.js Project

    Step 1. Initialize the Project

    Create a new directory for your project and navigate to the directory. Then, run npm init in the teminal/command line to initialize a new Node.js project. Then,  install the necessary libraries:

    npm install googleapis bannerbear
    

    Step 2. Import the Libraries

    Create a new file named index.js in the same directory and add the following code to import the libraries:

    const { google } = require('googleapis');
    const { Bannerbear } = require('bannerbear');
    

    Step 3. Declare the Constants

    Next, declare your Google and Bannerbear API keys and relevant IDs as constants:

    const GOOGLE_API = 'your_google_api_key';
    const SHEET_ID = 'your_google_sheet_id';
    const SHEET_RANGE = 'Sheet1!1:1000';
    const FOLDER_ID = 'your_google_drive_folder_id';
    
    const BANNERBEAR_API = 'your_bannerbear_api_key';
    const TEMPLATE_ID = 'your_bannerbear_template_id';
    

    Step 4. Access Google Sheets and Drive Data

    Create a function named getSheetData() and add the following code to read data from your Google Sheet:

    async function getSheetData() {
      try {
        const sheets = google.sheets({ version: 'v4', auth: GOOGLE_API });
        const response = await sheets.spreadsheets.values.get({
          spreadsheetId: SHEET_ID,
          range: SHEET_RANGE,
        });
        const rows = response.data.values;
        return rows.slice(1);
      } catch (err) {
        console.error('Error:', err);
      }
    }
    

    The data from the Google Sheet, including the table header, should be returned as an array:

    [
      ['Name', 'Role'],
      ['Isabella Garcia', 'Panelist'],
      ['David Kim', 'Panelist'],
      ['Lisa Chen', 'Panelist'],
      ['Dr. Emma Thompson', 'Panelist'],
      ['John Williams', 'Panel Moderator'],
      ['Geoffrey Lee', 'Panel Moderator']
    ]
    

    🐻 Bear Tips: Since the table header is not needed for generating the social media posts, the function returns rows.slice(1), which excludes the header.

    Create another function called getImageFiles() to retrieve the images from the Google Drive folder:

    async function getImageFiles() {
      try {
        const drive = google.drive({ version: 'v3', auth: GOOGLE_API });
        const response = await drive.files.list({
          q: `'${FOLDER_ID}' in parents and mimeType contains 'image/'`,
          fields: 'files(id, name)',
        });
        return response.data.files;
      } catch (err) {
        console.error('Error:', err);
      }
    }
    

    The function should return an array of objects, with id and name properties for each image found in the folder:

    [
      {
        id: '1UXsohu04aZtyPlmX99HlfKzBQX0SzNIS',
        name: 'Emma Thompson.jpg'
      },
      {
        id: '1ix3WXzeyKkZSkal4NxfvbzD-rILnE9Ap',
        name: 'Michael Johnson.jpg'
      },
      ...
    ]
    

    Step 5. Create Images with Bannerbear API

    Add the following code to read data from Google Sheets, retrieve photos from Google Drive, and generate images with Bannerbear:

    (async () => {
      const bb = new Bannerbear(BANNERBEAR_API);
      
      const guestList = await getSheetData();
      const imageFiles = await getImageFiles();
      const imagesObj = {};
      imageFiles.forEach((image) => {
        imagesObj[image.name.split('.')[0]] = `https://drive.google.com/uc?id=${image.id}`;
        fetch(imagesObj[image.name.split('.')[0]]);
      });
    
      guestList.forEach(async (guest) => {
        const images = await bb.create_image(
          TEMPLATE_ID,
          {
            modifications: [
              {
                name: 'text_name',
                text: guest[0],
              },
              {
                name: 'event_role',
                text: guest[1],
              },
              {
                name: 'image_container',
                image_url: imagesObj[guest[0]],
              }
            ],
          },
          true
        );
    
        const imageUrl = images.image_url;
        console.log(imageUrl);
      });
    })();
    

    Bannerbear will generate images for each guest using the design template created earlier. Here are some examples of the results:

    business conference result 1.jpg business conference result 2.jpg business conference result 3.jpeg

    🐻 Bear Tips: View the full code on GitHub.

    What's Next

    Throughout this tutorial, we’ve covered the essential steps for integrating Google Sheets, Google Drive, and Bannerbear to automate the creation of visuals for social media posts for a business conference. You can further enhance the automation by creating different templates for the event, like:

    • Speaker quotes - Share notable quotes or insights from the speakers to build excitement.
    • Session spotlights - Highlight individual sessions or workshops with details about the topics and speakers.
    • Speaker insights - Post quick takeaways or insights from the sessions.
    • Personalized event ID cards - Allow attendees to easily share networking information using QR codes.

    By automating the process, you can focus more on strategic aspects of the conference and less on the repetitive tasks of content creation. If you haven’t done so yet, sign up for a Bannerbear account and start automating today!

    About the authorJosephine Loo
    Josephine is an automation enthusiast. She loves automating stuff and helping people to increase productivity with automation.

    How to Generate Wedding Invites for Your Entire Guest List

    Wedding invites set the tone for the event, but they don't need to be created one by one. In this article, you'll learn three easy ways to streamline the process with Bannerbear.

    How to Instantly Create and Send Pet Adoption Certificates by Email (Free Template!)

    Pet shelters and rescues often have limited means, so automating adoption certificate creation can reduce the load on staff and free up resources for other tasks. Here's how to set up a simple nocode automation that generates and sends certificates out in one go!

    How to Automatically Create Multi-Time Zone Event Posters with Node.js and Bannerbear

    Hosting online events, workshops, or webinars for a global audience? Use Bannerbear in Node.js to automatically generate event posters with the correct time zones for different regions!

    Automate & Scale
    Your Marketing

    Bannerbear helps you auto-generate social media visuals, banners and more with our API and nocode integrations

    How to Auto-Generate Social Media Posts For a Business Conference Using Bannerbear (Node.js)
    How to Auto-Generate Social Media Posts For a Business Conference Using Bannerbear (Node.js)