paint-brush
Building a Chatbot Framework Using Camunda—An Open-Source BPMN Engine by@vinod-biradar
826 reads
826 reads

Building a Chatbot Framework Using Camunda—An Open-Source BPMN Engine

by Vinod BiradarOctober 6th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The text outlines building a chatbot using Camunda to orchestrate business processes. By utilizing BPMN for conversation blueprints, Camunda's suite facilitates seamless chatbot conversation flows, including its Modeler, Workflow Engine, and Cockpit. The illustrative example provided is a ride-booking chatbot, showcasing how various BPMN components manage conversation logic, error handling, and user interactions, all while promoting a structured, user-friendly experience.
featured image - Building a Chatbot Framework Using Camunda—An Open-Source BPMN Engine
Vinod Biradar HackerNoon profile picture


NOTE: This article is not about a ready-to-use chatbot. Instead, it is about an approach to building your very own chatbot platform inspired by a BPMN engine.


Chatbots address the modern-day demand for instant, on-demand customer service.


They provide:


  • Around-the-clock assistance.
  • Capability to handle numerous inquiries simultaneously.


And much more without human intervention, saving time and resourcesfor businesses.
With the ability to understand conversations, chatbots can provide personalized experiences, helping users do business over conversations.


Why opt for a chatbot framework?

If not chatbots, individuals in business roles, such as sales or support executives, would engage in conversations with customers to gather the necessary information. They possess the intellect and training required to handle these business discussions effectively.


However, in the context of text or audio-based conversations, chatbots are employed to facilitate these business interactions. The chatbot framework serves as the platform, supplying the essential intelligence to manage such conversations.


Chatbot Conversations as Business Flows

Consider business flows as a flow diagram resembling a conversation blueprint where each activity requests and gets data from the user and completes a business use case. This enhances the user experience by guiding interactions in a structured, logical manner.


A systematic approach ensures essential information is collected efficiently and the user is led to a satisfactory resolution without going off tangents.


Let’s consider the business use case of booking a ride for a daily commute, with the chatbot. A simple conversation flow would look like the below image.


A conversation flow for ride booking.



Requisites we can expect from the chatbot framework

  • State Management - Manage the state of each conversation.

  • Conversation Isolation - Handle multiple conversations without cross-interference.

  • Conversation Builder UI - Support CRUD of business flows with a good user interface.

  • Parallel Conversations - Make conversations about different business use cases at a time with end users.

  • Multi Chat Interface - Support for multiple messaging platform interfaces like WhatsApp for user interaction with chatbot.


Requisites in terms of handling conversation needs

  • Error handling for unexpected failures
  • Auto closure of conversation after a specific idle time
  • Wait and resume mechanism during extensive computation
  • Ability to close a conversation at any time and start from the beginning
  • Driving conversation seamlessly with different user inputs like text, list option, etc.
  • Making decisions based on user input and choosing the latter conversation path



BPMN (Business Process Model and Notation) and BPMN Engine

is like a universal language designed for businesses to clearly and visually represent their processes. Imagine you're drawing out a roadmap of how a particular task or process is completed within your organization, from start to finish, with all the steps in between; that's what BPMN helps you do—a good fit for our conversation blueprint.


Now, onto the BPMN engine. Think of it like the director of a play. It follows the script and the BPMN diagram and tells everyone (or every part of the system) what to do and when to do it to ensure the process runs smoothly from start to finish. The BPMN engine, like, reads the BPMN diagram, which, in our case, will be the conversation blueprint, and executes each step, helping the chatbot to pursue the conversation.


In simple terms, BPMN helps draw out the conversation blueprint, and the BPMN engine brings that conversation to life!



Building blocks of chatbot conversation blueprint - BPMN Components


BPMN and its components will be used extensively in further reads. Please check out the  If you are not familiar with it.


Now that we know how booking a ride will be executed, let’s see what BPMN components can be used to model the same as a BPMN diagram. Refer to the table below to understand the specific use case of some of the significant BPMN components that can be used for modeling conversations.


BPMN Component Description Conversation Use-Case for Chatbot

Start Event

Indicates the start of the process and execution. To start the conversation.

Service Task

Service APIs process executables. To execute the business logic and decide the following message.

User Task

Executables are processed manually by users. Capture the data and complete the task by the end-user or the system.

Script Tasks

Scripts like JavaScript process executables. Any use case where scripts have to be executed without the load of a service task

Timer Boundary Event

Starts the timer flow if the execution waits for the time specified. To auto-close the conversation after a specific idle time

Error Boundary Event

To catch the unexpected error in task execution. Self explanatory.

Exclusive Gateway

It helps to model decision-based flow. One flow satisfying the condition will be executed. If the conversation proceeds with different paths based on some conditions.

Parallel Gateway

It helps to model decision-based flow. All the flows satisfying the condition will be executed. Parallel execution, like sending a notification to the system in the background.

Event Sub-process Interrupt-based

Process within the primary process. It can be executed with a start event like an escalation event. Common conversation flow where the user would like to close the conversation at any time in the main conversation.

Escalation Start Event

They are used for starting a sub-process by listening to specific escalations identified by their name. Start the event of the common conversation flow like starting a close conversation flow.

Escalation End Event

This event can end the primary process and trigger the sub-process listening to the escalation start identified by name. To trigger the start of the close conversation flows from the main conversation.

Send and Receive Tasks.

Executables present in the same process workflow or different workflows that can be used for inter-communication between them. Identified by similar names in both send and receive tasks. Use cases like the driver arrived webhook process informing the user conversation flow. Here, Driver-side and User-side processes are different.

End Event

Indicates the end of the process and execution. To end the conversation.


Many other BPMN components can make the conversations modular, robust, reliable, and feature-rich. A complete modeled BPMN diagram for booking flow with all the complexities covered can look like this - .


Camunda - The Process Orchestrator

Camunda is a robust open-source platform engineered for workflow and decision automation. It empowers organizations to effortlessly model, implement, and execute BPMN workflows, CMMN cases, and DMN decisions.


With a suite of tools, Camunda is a formidable asset in building our chatbot platform and running the book ride conversation flow.


Camunda Workflow Engine

Camunda workflow engine is the core service Camunda provides to manage and orchestrate the BPMN diagrams. One of the standout features of the Camunda Workflow Engine is its ability to handle high-throughput scenarios while maintaining a low-latency performance. It is built to be developer-friendly, offering REST and Java APIs for easy integration and a comprehensive set of tools for monitoring and maintaining deployed workflows.


  • Process Workflow - The conversations blueprint we modeled as a BPMN diagram will be deployed on the Camunda Workflow Engine as a process.
  • Process Instances - Process Instance is the working object of the process workflow. Every conversation with a different user will create one process instance. This way, multiple conversations of the same type can be handled without cross-interface.
  • Process Instance Variables - Any data related to the instance will be stored as process instance variables. We can keep the data associated with the state of each conversation here.


Camunda Modeler

Camunda Modeler is a powerful, desktop-based modeling tool that allows designing and configuring BPMN workflows, DMN decisions, and more. It provides a user-friendly interface to create precise process models. One of the noteworthy features of Camunda Modeler is its ability to integrate with the Camunda platform seamlessly.

With the help of this software, we can create different BPMN diagrams as conversations for the chatbot using drag-and-drop modeling. And quickly deploy all the conversation on the platform. Alternatively, a  can also be used.


Camunda Cockpit

Camunda Cockpit is an advanced web-based tool designed for monitoring and managing business process workflows and decisions in real-time. Its primary aim is to offer a clear view of the current state and performance of processes and decisions deployed on the Camunda platform.


Camunda Cockpit will help to visualize the deployed conversation workflows, actively running process instances and their variables. It can be used to troubleshoot and rectify issues, ensuring seamless operation of the chatbot.


Chatbot in Action

Using Camunda and the Spring Boot framework, my team and I have built a production-ready chatbot framework called Karna. The Whatsapp messaging platform has been used as the user interface for end-user interaction. And multiple business use cases, including booking a ride, have been used as services provided by the chatbot.


Please visit the GitHub repository for further learning, where you can explore how to build a chatbot framework using Camunda and understand more technical details of the chatbot with the help of the attached technical deep-dive document.



🏆 I am happy to inform you that Karna has won the Grand Prize at the “Bengaluru Open Mobility Challenge' 23“hackathon hosted by Namma Yatri.


바카라사이트 바카라사이트 온라인바카라