How we used Contentful to build a chatbot that helps with everyday legal problems
by Chris McGrath | May 8, 2020
Have you been laid off? Are you behind on your bills? Need to renegotiate a contract?
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:
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.)
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.
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 McGrath has led mission-critical website and intranet projects for 25 years. He co-founded ThoughtFarmer, an intranet platform used by hundreds of organizations worldwide. Now, through Tangowork, Chris's team provides expert consulting on high-performance websites, intranets and chatbots.