How We Used Contentful to Build a Chatbot That Helps With Everyday Legal Problems
Have you been laid off? Are you behind on your bills? Need to renegotiate a contract?
In any of these situations, you may need legal information. And if you live in British Columbia, Canada, you can chat with Beagle to get it. (Try it—click the Messenger chat icon on the bottom-right of this page.)
Tangowork is the technical partner and chatbot consultant to People’s Law School on the Beagle project, with Agentic Digital Media providing design expertise. People’s Law School is a non-profit society in British Columbia dedicated to making the law accessible to everyone.
For our chatbot technical stack, we chose Contentful to manage the content and Rasa to power the chatbot AI. In this post, we discuss the reasons we chose Contentful for content management and the way we approached integration.
Contentful: One system to manage content across channels
A good chatbot requires a tremendous amount of content. Beagle’s team of lawyers spent several months writing and editing over 3000 replies across 71 topics.
We realized that the new chatbot content was so approachable and easy to read that it would be a shame if we didn’t use it on the website as well. But no one liked the idea of managing content in two places. So we started to explore the concept of “headless” content management systems — systems that manage just the content, leaving you to decide where that content is used.
We examined Ghost, headless Drupal, headless WordPress, and a handful of others. Nothing seemed to be as mature and purpose-built as Contentful. We ran some experiments with it, liked what we saw, and decided to move forward.
Using Contentful for the chatbot
We use Rasa, an open source chatbot engine, to analyze input and decide how to respond. Rasa doesn’t generate language — all possible responses have been written in advance. Rasa simply returns the name of a template to use. Then we retrieve that template from Contentful.
For example, in response to “i got laid off”, Rasa returns laidOff. Then a piece of middleware, built by our development team, calls the Contentful API and requests the content associated with laidOff. Contentful responds with the content, and then we format the text and send it to the chatbot:
Content is delivered from Contentful straight to the chatbot
Using Contentful for the website
The chatbot response to “i got laid off” works perfectly as the introductory paragraph to a webpage. The chatbot buttons, such as “What to know”, show as website headings. Individual chatbot speech bubbles show as website subheadings and paragraphs. (Read more about the website project in How you can grow your website traffic 51%—overnight—by radically increasing speed.)
Content is identical in both the chatbot and the website — it’s just reformatted
Certain pieces of text aren’t appropriate for both the chatbot and the website. For example, we use emoji more liberally in chat. For those instances, we surround the text in question with a span tag like this: <span class="chatOnly">Cool, eh? 😎</span>. The text is then suppressed in the channel where it doesn’t apply.
The Contentful editing interface is easy for content authors to understand
Changing text in Contentful instantly updates both the chatbot and the website
Unified content management in Contentful makes high-quality content easier
People’s Law School has a very high standard for content. After multiple drafts by their legal content developers, content passes to a plain language reviewer, who performs another check to ensure it’s as clear and easy to read as possible. Finally, it’s reviewed for accuracy by one of a host of external lawyers.
If this legal review process had to happen twice — once for website content, and once for chatbot content — it would be unsustainable. Instead, Contentful allows us to manage a single set of content, and publish it in two places: on a website and on a chatbot.
And it doesn’t need to stop there. We can theoretically produce PDFs or other printed collateral via Contentful. Indeed, we’re using maximum-resolution images in Contentful’s media library in case we go down that path. (Contentful resizes and downsamples images on the fly for delivery to the website and chatbot.)
The lawyers at People’s Law School are thrilled with Contentful as their unified content management solution. “Contentful is fast, easy to use and flexible,” says Drew Jackson, lawyer and project lead. “There’s nothing we’ve tried to do with it that it couldn’t handle. And I’m relieved that when the law changes, we don’t have to update both the website and the chatbot. We change the content once, and it updates everywhere.”
Chris loves working on elegant software solutions to difficult problems. He often speaks on topics related to websites, intranets and chatbots. He co-founded ThoughtFarmer, an intranet platform used worldwide. He has a terrible poker face, a mediocre golf swing and a penchant for hasty decisions. On the plus side, he pulls a mean espresso, speaks two obscure languages (Serbo-Croatian and St. Lucian Creole), and never says no to an invitation to go kiteboarding.