Uncategorised

Legal Systems Engineering 101: How to build a legal-advice bot

Sebastian Burgstaller
. 4 min read
- Bitmovin

Bitmovin was delighted to learn recently that its General Counsel, Ken Carter, was selected as Corporate Counsel’s Start-up Solo GC of the Year – 2021.  One aspect of Ken’s work the Award recognized was his and his student interns’ work to create legal advice giving Slackbots.
True to Bitmovin’s mantra that “all wins are team wins” (even if it is an award for a solo GC), Ken was insistent that we publish a blog post showcasing our engineering work to make the chatbot a reality.  The truth is that the engineering work is not particularly difficult, so we think with the pointers we provide below, an experienced engineering team will be able to create a similar solution quickly.

Aligning Your Legal Systems with Engineering 

The first step is that a given organization’s legal team should define the combined business and legal “logic” that would dispense required advice and instructions on a recurring basis. In our experience, the best way that our legal team is able to express this logic to the engineering team is to start with a spreadsheet that shows how certain questions can point to a variety of possible answers and instructions. 
Bitmovin has open-sourced this Google sheet as an example of contextual, on-demand video-based help for routine tasks in Ironclad. **Disclaimer** The linked spreadsheet is licensed under the uNDA License

Getting the Information into the Bot

Once the legal team has compiled a Q&A logic sheet, the engineering team takes over. The first engineering step is to decide how the spreadsheet data will transfer information to the application that services incoming bot requests. In Bitmovin’s case, we decided on a pragmatic approach of exporting the questions into a machine-readable structured data format (e.g. tab-separated values).
The current process means that one of our engineers will have to update the logic file manually whenever the legal team adds or changes questions. However, given that most of these processes are standard in our case, we don’t expect frequent changes. Step 1.5 would include confirming how flexible the document will be with your legal team, as a more automated approach might fit your process better. 
In the scenario that automation and frequent updates are likely, one could connect the Google Sheet API to access the questions directly, thus eliminating the need for manual updates. 

“As always in engineering, remember to not optimize prematurely.”

Further Technical Details

For the application servicing the bot requests (we will call it server from now on), we selected Spring Boot to run our Slackbot and paired it with the official Slack SDK for Java (see, Getting Started with Bolt). While we prefer Spring Boot, feel free to use a framework that fits your needs accordingly. Next, we prototyped the UI with Slack Block UI Kit Builder and when we were satisfied with the usability and looks, we translated the result to code. 
At startup, the server ingests the file containing the questions and answers and will feed them into a simple state machine. Each step is represented by a dialog showing the current question and its possible answers. Selecting an answer will send a specific value to our server, which identifies the next step and the history that led up to this step. 
For example, if the user clicks on the answers A1, B1, and C1 then the history will be marked as “A1 B1 C1” and enables the server to correctly navigate to the previous step if the user clicks the “Back” button. The history would then be “A1 B1”. For each interaction with the bot, the server sends back a new dialog and replaces the previous one (this is a flag in the response message that needs to be set, otherwise the new dialog is displayed under the previous dialog).

Final Setup

Finally, you will need to register a new Slack app in your workspace via the Slack applications page and configure its permissions according to your needs. 

Legal Systems Engineer_Building the Slackbot App_Screenshot
Let’s build an app!

You will also need to get the bot credentials for use in the server, so it can verify the digital signature of each request. Once that’s verified and prepared you should test the server locally to ensure it works as expected. To do so you will need a service that can redirect Slack communications to your development machine where the server is running. We recommend ngrok for that purpose. 
First start ngrok, note the generated address and enter it in the “Event Subscriptions” / “Interactivity & Shortcuts” pages of the Slack bot. Once you save your changes and install the app to your Slack workspace, you will be able to send requests to your local server.
The final step requires that the server is deployed permanently so that you don’t need to run ngrok and your development machine at all times. The easiest way to make this happen is to use one of the many simple and inexpensive hosting options or cloud providers (e.g. Google App Engine, Azure App Service, or AWS Elastic Beanstalk).

Conclusion

While it takes a few legal resources to lay out and document routine legal advice and to do the engineering work, it can save tons of time in the long run for legal teams and their business users.  We look forward to hearing your feedback on how you’ve built you’re very own automated legal systems and further questions on how to build one in your company. 

Video technology guides and articles

 

Sebastian Burgstaller

Sebastian Burgstaller


Related Posts

- Bitmovin
Uncategorised

Faith-Based Video Streaming: 4 Major Challenges (and Solutions) for Religious Organizations    

- Bitmovin
Uncategorised

An Engineer’s POV on Developing the Bitmovin Player for PlayStation 5

Join the conversation