hands-together ChatGPT Integration with Drupal websites

ChatGPT can generate useful and interesting text to help your users. Here are a few ways to integrate ChatGPT with websites hosted in Drupal.

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 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.

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.

Drupal can integrate with ChatGPT via a module to produce generative useful and interesting content on websites hosted in Drupal. 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. We expect to see lots of changes and hot add-ons for the OpenAI module in the near future. Here are a few features you can use now:

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.

Suggesting taxonomy terms for nodes 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

This article is adapted from The How and Why of AI: Drupal Modules for OpenAI/ChatGPT Integration and is republished with permission.