The Role of AI in WordPress

In this article, I’d like to give a high-level overview of AI, WordPress applied to AI, the experimentation with both, and how you too can get involved.

We now know that WordPress powers more than 40% of all the sites on the Internet. Since the WordPress REST API was added to Core, I’ve wondered about the potential of these vast mini-APIs deployed all over the Internet. These new personal APIs gave us a stable and convenient way to browse our content, catalog it, categorize it, and interact with it programmatically. These APIs are not how we humans prefer to consume content, but it’s ideal for machines. At its core (pun intended), WordPress is about the content. When paired with a technology that thrives on content, opportunities emerge.

A high-level overview of AI

AI introduces a new toolkit and user interface for industries, developers, business owners, and makers. While exploring and learning about AI, the syntax was the most surprising. Instructing AI is like tutoring a peer, where typing out the task is the written instruction for context. It’s no different than sharing the knowledge of a particular task in a wiki with some examples or writing concise documentation. Developing with AI feels like teaching, and this type of instruction is called prompt engineering.

With a short prompt and the settings tuned, you’ll start to get compelling results. Sure, the results are not always perfect, but you can begin to see the effect. Examples are not always required either, such as being asked to complete a task for the first time, using your best guess is always an option. Human brains can do that, and so can AI.

The technology that powers these AI engines isn’t something you would run on your local machine. The processes are intense, and running these systems for web developers might be outside the realm of familiar tools. Instead, these services are making their way to market as SaaS products and APIs, a very friendly format for web developers. OpenAI is one of the first companies to offer these robust AI services with a simple HTTP call.

WordPress and AI

I hope to explore the intersection between AI, the WordPress ecosystem, and our products. I’ve started experimenting, and I’m thrilled with the results. Since WordPress powers so much of the web, connecting OpenAI to users’ content opens up many possibilities for training, task augmentation, and new product development.

For example, you can engineer your prompt for a specific task you’d normally do as a part of your job. Let’s say you have a back catalog of blog content, but you never added excerpts to your posts. Incomplete post content can harm SEO and leave out a lot of context for your readers. Using AI to write post excerpts for your back catalog could give you a nice boost in search if that was something you were missing.

Writing post excerpts is a well-defined task and is small enough for AI to do effectively, but really it’s a building block for something grander. AI doesn’t just lift content from your articles; it can learn the context and craft something entirely new. Imagine writing hundreds of short summaries; that would be exhausting at scale for us to do, but an enjoyable task for some AI because machines don’t complain or get bored. While we can dream big when it comes to AI, practical applications may not be all that glorious, at least not yet.

Thinking about the future of Shifter Headless, as a platform designed to be API-first WordPress, there are many connections and services you can build upon. OpenAI is one, but there seem to be endless options these days. Making these APIs easier to consume, interact with, and mesh together opens up more possibilities to create. In a way, it could reverse how we develop “Plugins” for WordPress. Instead of developing functions within WordPress, we’re developing them using content from the REST API as a layer above WordPress itself.

Experimenting with AI

When deciding to experiment with OpenAI, I created a function closely resembling a reasonably trusted prompt from the official examples on their site. It was designed to summarize text, and it seemed to work great. Using this prompt as inspiration, I was quickly able to create something using the OpenAI API and the WordPress REST API. I tested the idea of writing post excerpts using a simple function written in Node, called generated-excerpt.

https://github.com/getshifter/generate-excerpt

This function can read and understand the context of the post and can summarize it into a post excerpt. It automates or augments a task, but it doesn’t make it fully autonomous. Something that writes content should have a human in the loop. OpenAI recommends this as a part of their best practices.

This demo glues two essentially glues services together, but how far could this go? If AI can now write code, is it only a matter of time before AI is helping us write Gutenberg blocks and patterns? 

Getting Involved

Using Node and OpenAI isn’t the only way to use AI in WordPress. While these tools are thrilling for developers to experiment with, companies like bertha.ai offer access to AI as a product, with no coding required. I do believe that WordPress will have an effect on AI and vice versa. The technology and tools are just a few API calls away, whether tapping into your content as training data or augmenting a task.

Links

Generate Excerpt: Generate Post Excerpt using Post Content and OpenAI. Built using the OpenAI API, Shifter Headless, and the WordPress REST API.

Bertha: Bertha is an AI-based writing assistant that will help you write content on your WordPress website.

OpenAI Charter: The principles guiding OpenAI’s mission.

Prompt Engineering: With the No-Code revolution around the corner and the coming of new-age technologies like GPT-3, we may see a stark difference between the career of today and the careers of tomorrow.

Meta Descriptions and Excerpts by Yoast: Both meta descriptions and excerpts use a brief passage to summarize the content of a web page.