The How and Why of AI: Drupal Modules for OpenAI/ChatGPT Integration

Jun 05 2023

Authored by: Nadiia Nykolaichuk

ChatGPT, one of the most well-known innovations by OpenAI, captivated the world’s attention from the first day of its release. It can have human-like conversations and assist people with various tasks from generating content ideas or drafting business plans to writing code. 

The speed and power of AI (artificial intelligence) in combination with the natural flow of human language is impressive, intriguing, and even a little scary. No wonder the arrival of ChatGPT has caused a mix of admiration, confusion, and fear among users worldwide. There have been many talks about it taking away jobs from humans, creating intellectual-property issues, and leading to risks of misinformation or bias, among other concerns.

When it comes to AI, we are aligned with Drupal’s creator Dries Buytaert, who described his personal strategy as “to proceed with caution.” “There is no stopping AI, so it's better to embrace change and focus on moving forward productively,” says Dries in his article called “Artificial Intelligence, the future of Content Management and the Web.” He also mentions that productivity and efficiency improvements almost always outweigh the risk, and the concerns should hopefully be addressed in time. Below, we explore how to boost productivity and efficiency for Drupal users by integrating ChatGPT and other OpenAI tools with websites. 

A glimpse at OpenAI/ChatGPT integration with a CMS like Drupal

A content management system (CMS) and an AI language model look like a perfect match. By integrating ChatGPT with a CMS like Drupal, it’s possible to get AI assistance in a wide array of everyday tasks. It can generate content ideas, create content, translate it, optimize its quality, analyze users’ search queries, or literally be a chatbot or virtual assistant, significantly saving time and effort for the customer support team. And it’s just the beginning — you’ll discover more options further in this article.

A screenshot of ChatGPT answering the question of whether it could be useful when integrated with a CMS
A screenshot of ChatGPT answering the question of whether it could be useful when integrated with a CMS.

ChatGPT integrations into CMSs are expected to be simple and numerous in the near term — as outlined in Dries Buytaert’s article. Emphasizing the great potential of generative AI for CMSs, Dries mentions the OpenAI module for Drupal, which is a complex suite of multiple modules for OpenAI/ChatGPT integration developed by Kevin Quillen:

“If you look at the source code of these modules, you can see that it is relatively easy to add AI capabilities to Drupal. ChatGPT's APIs make the integration process straightforward. Extrapolating from Drupal, I believe it is very likely that in the next year, every CMS will offer AI capabilities for creating and managing content.”

— Dries Buytaert

The API (Application Program Interface) provided by OpenAI enables other applications to interact with the foundational parts of their AI-powered software. Kevin Quillen mentions this in his article “The Rise of OpenAI and ChatGPT”, emphasizing that “integrating with a good API is easy in Drupal.” Indeed, we all know about Drupal’s outstanding third-party integration capabilities

Let’s take a closer look at the potential of generative AI for Drupal websites by exploring some useful Drupal modules for OpenAI/ChatGPT integration. This collection will include the above-mentioned OpenAI module, as well as a couple of other great integration tools.

Overview of Drupal Modules for OpenAI/ChatGPT Integration

  1. The OpenAI module
  2. The ChatGPT Content Assistance module
  3. The ChatGPT Augmentor module

1. The OpenAI module

The full name of the OpenAI module is “OpenAI / ChatGPT / AI Search Integration.” This project includes a large suite of submodules and an API foundation for integrating ChatGPT and other OpenAI services with Drupal websites. 

This suite is still in its alpha stage and its creators are full of ambitious goals for expanding its functionality even further. Some features covered by the suite are available in a ChatGPT Plus subscription option. The API for some of the features is still in development. In a vibrant environment like that, we expect to see lots of changes and hot add-ons for the OpenAI module in the near future.

Here are some examples of OpenAI/ChatGPT features that the currently included submodules can provide for Drupal websites:

  • Communication with OpenAI in the Drupal admin UI

The OpenAI Prompt submodule creates an area in the Drupal admin UI where users can prompt OpenAI and get answers back from it. “Prompting” means interacting with the artificial intelligence in order to get its response just like many of us have done with ChatGPT. However, it’s not literally ChatGPT in this case, though it’s the same underlying foundation, explains Kevin Quillen

In addition to the field for a user’s prompt and the field for AI’s answer, the interface includes more settings for doing some configuration tweaks. For example, it’s possible to choose the specific data model (e.g. text-davinci-003), change the “temperature” (for getting a more focused or a more random answer), and so on.

Prompting OpenAI and getting answers in the Drupal admin panel
Prompting OpenAI and getting answers in the Drupal admin panel.
  • Communication with ChatGPT in the Drupal admin UI 

The OpenAI ChatGPT submodule enables interaction with the Chat endpoint via the ChatGPT API. You can ask ChatGPT anything and get an answer thanks to the “Message for ChatGPT” and the “Response from ChatGPT” fields. The “Profile” field is meant for giving some directions to ChatGPT on how it needs to be responding. Similarly to the previous module, this one enables you to customize the data model, the “temperature,” the maximum number of tokens, and more. 

Prompting ChatGPT and getting answers in the Drupal admin panel
Prompting ChatGPT and getting answers in the Drupal admin panel.
  • OpenAI/ChatGPT integration with Drupal’s CKEditor

The OpenAI CKEditor submodule could be a nice addition to the list of useful modules to extend CKEditor 5 in Drupal 10. It adds a list of actions to choose from directly in the text editor’s interface. The actions are meant for running specific OpenAI/ChatGPT commands such as completing a text, adjusting its tone and voice, summarizing it, translating it, and more. The module’s creators plan on expanding the AI features for CKEditor even further. 

Choosing specific OpenAI/ChatGPT actions in CKEditor.
Choosing specific OpenAI/ChatGPT actions in CKEditor.
Adjusting the tone of content and translating it with AI in CKEditor
Adjusting the tone of content and translating it with AI in CKEditor
  • Various AI enhancements on the content editing page

The OpenAI Content submodule enhances content editing workflows by integrating various AI-powered features. Among the currently available ones are summarizing the body text, suggesting taxonomy terms for nodes, adjusting the tone of voice, and checking content for compliance with OpenAI’s moderation policies.

Summarizing the body text with AI in Drupal’s content editing interface.
Summarizing the body text with AI in Drupal’s content editing interface.
Summarizing the body text with AI in Drupal’s content editing interface.
Suggesting taxonomy terms for nodes with AI in Drupal’s content editing interface.
  • Generating realistic sample text and images

Unfinished web pages often include “Lorem ipsum” typesetting text — the gibberish pseudo-Latin placeholder text. Drupal developers, designers, and QA testers often use “Lorem ipsum” to see how a page will look or how a feature will work. Drupal has a powerful Devel module, which can generate this type of text in endless amounts.

AI makes it possible to generate realistic sample text instead of just “Lorem ipsum.” This might look much more attractive, for example, in a demo shown to a customer. So the OpenAI Devel submodule adds the GPT content generate capability to Devel, enabling you to generate content titles, body text, and even images using either Drupal admin UI or the Drush command-line tool.

Generating realistic sample text with AI and Drupal’s Devel.
Generating realistic sample text with AI and Drupal’s Devel.
  • Explaining database errors

Most Drupal developers, site builders, and website administrators know that the Database Logging (dblog) module in the Drupal core is great at logging and recording all system events to the database, which often helps them find out what causes an error. 

However, it’s not always easy to understand what an error message really means, especially for beginner developers or non-technical users. Artificial intelligence to the rescue! Thanks to the OpenAI DBLog submodule, OpenAI will be explaining errors and other events in a Drupal website’s database logs.

  • Using OpenAI’s speech-to-text features

The OpenAI Audio submodule enables your Drupal website to interact with OpenAI’s “speech-to-text” endpoints. Currently, there are two endpoints — transcriptions and translations. They are based on the Whisper model — a neural net that recognizes speech with near-human accuracy. The transcriptions and translations are used to transcribe audio into any language the audio is in, as well as translate and transcribe the audio into the English language.

  • Setting up a content recommendation service and more

With the OpenAI Embeddings submodule, OpenAI analyzes your content and generates vectors and text embeddings for it. This functionality integrates the Pinecone vector database that is designed to simplify the building of high-performance vector search applications. Among other things, the module helps your Drupal website return the most relevant search results and makes it easy to set up a content recommendation service without having to use additional search services like Solr, ElasticSearch, Algolia, Coveo, etc.

Getting relevant search results with AI
Getting relevant search results with AI.

2. The ChatGPT Content Assistance module

The next Drupal module in our collection boasts the title of the first-ever OpenAI/ChatGPT module to be created for Drupal. The ChatGPT Content Assistance module was released in early January 2023. It is a lightweight and simple module meant to make content editors’ workflows much easier by harnessing the power of AI. You can configure it to use GPT-3, GPT-3.5 or GPT-4 versions of the ChatGPT tool. 

The ChatGPT Content Assistance module is able to assist content creators in three key tasks:

  • Content generation

The module adds a link to Drupal’s content editing interface which you can click to get a popup with access to the ChatGPT content search. A content creator can copy the returned content from the popup and use it in their work.

Generating content with AI in Drupal.
Generating content with AI in Drupal.
  • Content translation

The next feature could be very useful for multilingual Drupal websites. It adds a “Translate using ChatGPT” option on the content “Translate” tab for each language that is enabled on a multilingual site (if the piece doesn’t have a translation yet). It’s very convenient with one exception — AI can only translate flat text without taking care of the HTML markup, so you will need to add the formatting tweaks manually.

Translating an article with AI in Drupal
Translating an article with AI in Drupal.
  • Content Assistance

This feature adds a new tab called “OpenAI Content Assistance Tool” to the Content page of your Drupal admin dashboard. It should assist you in various tasks such as creating images from text, extracting SEO keywords from text, and more. You can configure the feature’s settings on the Configuration page (specify the OpenAI model, the number of images to be generated, the image size, etc.).

Content Assistance  This feature adds a new tab called “OpenAI Content Assistance Tool” to the Content page of your Drupal admin dashboard. It should assist you in various tasks such as creating images from text, extracting SEO keywords from text, and more. You can configure the feature’s settings on the Configuration page (specify the OpenAI model, the number of images to be generated, the image size, etc.).
Configuring the Content Assistance Tool on Drupal’s Configuration page.

3. The ChatGPT Augmentor module

The ChatGPT Augmentor module is a submodule of a larger Drupal module — Augmentor. The Augmentor module is an AI framework designed for integrating various AI systems with Drupal websites. Augmentor provides a modular ecosystem for managing a wide array of AI services. Among them are ChatGPT, GPT3, NLP Cloud, Google Cloud Vision, and more. The module adds the “Augmentors” dropdown list to the CKEditor toolbar, as well as provides various field widgets.

The “Augmentors” dropdown list on the CKEditor toolbar
The “Augmentors” dropdown list on the CKEditor toolbar.

When it comes to the ChatGPT Augmentor submodule, it provides an Augmentor specifically for using the ChatGPT API. Its job is to return chat completion responses in conversations with ChatGPT.

Final thoughts

It’s clear that AI has made a big imprint on the tech landscape. When in good hands and used with a careful approach, it can definitely be a super-efficient assistant for humans. As you’ve read above, the idea of OpenAI/ChatGPT integration with your Drupal website could supercharge your team’s efficiency. Furthermore, we can expect the range of available features to be expanding in the near future. Want to discuss it in more detail? Contact our Drupal team and let’s chat about ChatGPT!

Learn from us
Sign up and receive our monthly insights directly in your inbox!

Subcribe to newsletter (no spam)

Fields