Use ChatGPT to create automated text quickly and easily. With Google Spreadsheets you can use it to generate product texts, meta titles and meta descriptions based on product data, but also for data from WebCrawlers and other analysis tools. Use the template in the article to quickly and easily create product texts based on your product feed.

How does chatGPT for Google Spreadsheets work?

The formula

CHATGPT(prompt, max_tokens, temperature, api_key)

generates texts based on product data that are available in tabular form in Google Spreadsheets. The prompt can be linked with text operators.

The parameters (are entered on the “Setup” worksheet):
prompt : The command line, formulated in natural language.
max_tokens : How many tokens can be used by the API. In English, approximately four tokens are used per word.
temperature : The number of iterations used in text generation. The fewer iterations, the more “simple” the text becomes.
api_key : API key from openAI

In the example of the table, the relevant product data brand, product type, size, color and target group exist. These are transformed in cell G to a “prompt”, i.e. a command to ChatGPT. Cell H then generates the response using the ChatGPT formula. The application goals are shown here using product data as an example, but it is also conceivable with data from WebCrawlers and other analysis tools.

Chatgpt formula 1200x322.png

Work quickly with ChatGPT & Google Spreadsheets? Here is the template to copy.

For nerds: The formula for use in Google Apps Scripts

/**
  * Returns a text Choice from Chat GPT.
  *
  * @param  {string}  instruction of what to do.
  * @param  {url}  url for what page.
  * @param  {max_tokens}  max_tokens how many API tokens to use max.
  * @param  {temperature}  temperature set the temperature.
  * @return Returns a text Choice from Chat GPT
  * @customfunction
  */
function CHATGPT(prompt,max_tokens,temperature,apikey) {
  // add your apiKey from OpenAi here. Found at: https://beta.openai.com/account/api-keys 
  // increase temperature for more randomness, and variations of the output. Max tokens set at 240 characters (could be lower). 
  // using Keyword: as a stop sequence so that it only generates one result.

  const parameters = {
  'prompt': prompt,
  'max_tokens': max_tokens,
  'temperature': temperature,
  'stop': '["Keyword:"]',
  'model':'text-davinci-003'
  };
  Logger.log(parameters)
  const options = {
  'method': 'post',
  'contentType': 'application/json',
  'payload': JSON.stringify(parameters),
  'headers': {
  Authorization: 'Bearer ' + apikey,
  },
  };

  // fetch from GPT-3 - Engines can be changed. eg.  https://api.openai.com/v1/engines/curie/completions
  // worth exploring each individual Engine in more detail here:https://beta.openai.com/docs/engines

  const response = UrlFetchApp.fetch('https://api.openai.com/v1/completions', options,);
  Logger.log(response)
    
  var responseText = JSON.parse(response.getContentText())['choices'][0]['text']
  responseText = responseText.replace("$.*\n","").replace("$\n","")
  Logger.log(responseText)
  return responseText;
}

chatgpt_google_spreadsheets.js hosted with ❤ by GitHub

With ChatGPT you can automate text quickly and easily. We have shown you how to use it using Google Spreadsheets as an example. For example, you can use it to generate product texts, meta titles and meta descriptions based on product data. But you can also use it for data from WebCrawlers and other analytics tools.

Bernhard prange webmeisterei

SEA-Experte: Bernhard Prange

Bernhard Prange ist Google Ads Freelancer und Tracking-Spezialist mit über 10 Jahren Erfahrung im Performance-Marketing. Sein Fokus liegt auf datengetriebenem Arbeiten: von Google Shopping über Conversion-Tracking bis hin zu serverseitigen Lösungen mit Matomo und BigQuery.

Als Ansprechpartner für Agenturen, E-Commerce-Unternehmen und B2B-Dienstleister verbindet er technisches Know-how mit strategischem Blick auf Marketing und Geschäftsmodelle.

Beiträge, die dich auch interessieren könnten…

  • Better data, better decisions: Data enrichment in Server-Side Tracking

    Lesen
  • Google Ads DemandGen: The Complete Practical Guide

    Lesen
  • Claude MCP: 30+ Integrations for WordPress, Google Ads & SEO

    Lesen
  • Track User Reading Behavior with Google Tag Manager

    Lesen