For a long time, researchers in artificial intelligence (AI) have been intrigued by the idea of developing a conversational agent that is capable of having a coherent conversation with humans[16, 5, 13]. Recent breakthroughs in semantics and speech recognition have given rise to hopes for robust solutions to the problem [10, 1]. Major information technology companies have released digital assistants and chatbot frameworks to facilitate the building of conversational agents [9, 7].
However, research studies on the user perception and expectations from users of chatbots indicate that the systems still require significant improvements in order to provide a meaningful experience . Also, demand analysis identified a need for specialized digital assistants in customer facing processes, in particular in the insurance sector . A promising approach to advance in this field are comprehensive knowledge engineering methodologies which back the chatbot and upgrade its conversational capabilities from small talk to domain expert .
In our case, we are interested in the domain of contract statements of insurance policies. In order to narrow down the problem, we focus on the kind of questions that can be answered based on linear rules which take a finite set of parameter-value pairs as input. We assume that most customer support inquiries fall in the domain of our interest, i.e. questions around coverage and pricing in real-world insurance policies.
Modeling contracts bottom-up as self-executing contracts, also known as “smart contracts”, is appealing due to its large potential of automation and its resilience to tampering . However, it is extremely hard to apply this concept on real-world contracts based on existing contract law provisions because smart contracts are “indifferent to the fundamental legal principles, such as lawfulness, fairness, and protection of the weaker party” .
Matching inquiries around a contract using a conventional FAQ bot would be an option, in particular when using a deep learning neural model for answer selection. However, the use of static answers can quickly become complex and hard to maintain due to the arbitrary number of combinations.
In this paper, we propose a knowledge engineering methodology to model contract statements which support the automated handling of such questions. We choose a top-down approach, manually selecting the most relevant statements of a contract and modeling their underlying rules in a straightforward and accessible manner. The rules are based on combinations of different parameter spaces. This allows for the modelling of complex statements while facilitating easy maintainability. Conversational agents can query the rules via API which allows for seamless integration with any chatbot framework. We also assess the theoretical statement expressivity of our approach and demonstrate that it holds a significant potential of complexity reduction compared with conventional FAQ bots.
The remainder of this paper proceeds as follows. We begin with an overview of the overall architecture we propose and introduce a toy scenario. Next, in Section III, we define the expected input to the system, describe the theory behind our concept of contract statement modeling, and outline the different possible query scenarios. Then, Section IV studies the theoretical complexity reduction of our approach with respect to the maximum and the actual number of questions covered. Further, we provide the technical specification of our prototype which realises the present concept in Section V. Finally, we conclude by providing insights in possible future fields of research.
Ii General architecture
The proposed architecture to respond to customer support inquiries consists of a chatbot client, a chatbot framework and several knowledge services. The conversation flow between those components has been illustrated in a sequence diagram in Figure 1.
Ii-a Chatbot client
The chatbot client is the messaging interface provided to interact with the customer support. It allows to send and receive short messages and preserves the conversation in a local message log.
Ii-B Chatbot framework
The chatbot framework manages the conversation flow and preprocesses the inquiries. In this paper, we focus on designing the knowledge service, the operations of the chatbot framework are not in the scope of this paper. Thus, we only briefly describe them as follows. Every inquiry sent to the chatbot framework is preprocessed using Natural Language Processing (NLP) methods. First, a text classifier is used for intent classification. By understanding the matter of the inquiry, the framework can identify the corresponding knowledge service. Then, named-entity recognition is run on the user message to retrieve the parameter-value pairs. Finally, the parameter-value pairs are dispatched to the knowledge service as query parameters.
Ii-C Knowledge service
Every knowledge service represents an endpoint for one specific type of question. It contains expert knowledge formalized as rules of a contract statement. The properties of the knowledge service are described in full length in Section III.
Ii-D Toy scenario
Throughout this paper we will illustrate all aspects of our proposal with a simple toy scenario. Its model is shown in Figure 2. The subject is a fictional accident insurance which covers sports accidents in different geographical regions. Prices vary depending on the kind of sport and the country. We would like to automate responses to price requests based on the customer’s parameters.
Iii Knowledge service
The knowledge service plays the role of the domain expert. It processes the query, identifies the matching rule and delivers the appropriate answer. In the following, we describe the expected input to the service, the modeling of a contract statement, and the different query scenarios.
Iii-a Input query
The knowledge service expects a structured request containing a set of query parameters as input. As previously described, this request is prepared by the chatbot framework.
In the context of our toy scenario, the customer could for example enter the question “How much is an accident insurance for scuba diving in Turkey?” in the chatbot client. The chatbot framework classifies the intent of the message and match the corresponding knowledge service which handles pricing questions. Further, it identifies the required parameters for this service, here sport and country. Using named-entity recognition, the relevant parameter values, in this example “scuba diving” and “Turkey”, are extracted and dispatched as query parameters to the knowledge service.
Iii-B Contract statement
We first propose to select relevant statements from a contract, that is, specific rules which are frequently subject of customer inquiries. We suggest to model such statements as hypergraphs. The vertices of a hypergraph represent the different parameter values and also the possible responses of each statement. Rules are defined by edges which connect several vertices.
In our toy scenario, the statement is about pricing. The vertices represent the possible parameter values, here groups of sports and countries. They also stand for the responses, in this example the different prices. The rules define the prices for each available combination of parameter values.
We choose a hypergraph to model a statement because, unlike a simple graph, a hypergraph has edges which can join any number of vertices. Let = be a finite, undirected hypergraph with vertices . is a set of hyperedges , such that each hyperedge contains an arbitrary set of vertices, . More precisely, is a subset of , where is the power set of .
The vertices are split in 2 different types: the ones that represent the parameter values, and the ones that stand for the available responses.
Let vertices be the first subset of . They are each labeled with a string denoted as parameters where . is the set of strings which consist of at least 2 characters. In our toy scenario, the parameters are sport and country.
The labels are unique, , and the maximum number of parameters is the total number of vertices, thus . Each vertex of represents a set of possible values for the given parameter. We describe those values as set of keywords which consist of at least one string, thus where . The keywords are required to be unique per parameter, thus for each where Otherwise, several rules could apply simultaneously, and there would be no unambiguous result. In our continuous example, the keywords are , , etc.
Let vertices be the second subset of , labeled with responses where . Responses are to be unique in our model, thus . In the toy scenario, the responses are .
Edges represent the statement’s rules. We require the rules to take at most one value per parameter, which is why we only allow edges to connect vertices of different parameters. Formally, this means that each hyperedge must contain vertices and so that . Also, it must include a minimum of 2 vertices, including 1 vertex of , so that .
For example, in our toy scenario displayed in Figure 2, the rules show that the prime for in would be cheaper than for in . On the other hand, insurance for in is not offered.
Iii-C Query scenarios
The necessary steps to find the right response to an inquiry have been outlined in the form of pseudo code in Algorithm 1. First, we identify all vertices of which match the parameter-value pairs provided in the query. Then, we search for a hyperedge that connects those vertices. For this purpose, we consider the following scenarios.
Iii-C1 Complete input query (default)
If parameter values were provided for all parameters, and a fully connected hyperedge exists, we single out the vertex which belongs to the subset . Notice that by definition each hyperedge must include exactly one such vertex. As response we send the label of this vertex to the chatbot framework.
If the matched vertices are not fully connected by a hyperedge, it means that none of the defined rules in the statement apply. Thus, the response is the boolean value . Depending on the use case, this response may be interpreted as “no”, or as “undefined” – impossible to make a valid statement.
Iii-C2 Incomplete input query
If the query is incomplete, a fully connected hyperedge may still exist, since we do not require hyperedges to include vertices of every single parameter. In this case, we send the label of the vertex which belongs to the subset , just as described above.
However, if the matched vertices are not represented by a fully connected hyperedge, the knowledge service prompts the user for the missing parameter values until either a hyperedge is found or the query is complete and contains values for all parameters. More specifically, the label of the first parameter without value is sent to the chatbot framework with HTTP status code 422 (“Unprocessable Entity”). The framework requests the parameter value from the user, and finally resubmits the updated parameter query. This approach enhances the knowledge service with a very basic capacity to manage part of the conversational flow.
For example, if the question “How much is an accident insurance for scuba diving?” was asked in the toy scenario, the knowledge service would respond with “country” and HTTP code 422, prior to providing a final response. The chatbot framework could rephrase the request to “In which country would you like to exercise the sport?”, include the answer of the user to the query and pass the completed parameter-value pair to the knowledge service.
Iii-C3 Invalid input query
A parameter query may include unexpected input, i.e. multiple values for the same parameter. For the sake of simplicity, the knowledge service currently only detects such exceptions and leaves it to the chatbot framework to handle them appropriately. More concretely, the knowledge service responds with the boolean value and the HTTP status code 400 (“Bad Request”).
Iv Complexity reduction
In theory, the previously presented type of questions could be answered by conventional FAQ bots, too. However, such frameworks would require to write one explicit answer for every single question. This would result in a very large set of question-answer pairs, which is time-consuming to achieve and difficult to maintain. On the contrary, the contract model presented in this paper induces that each statement represented by a hypergraph factorizes all possible answers into rules and as such serves as dynamic answer to multiple questions.
Iv-a Statement expressivity
To estimate the maximum number of different questions that could be covered by a hypergraph, we need to add up all possible parameter-value pair combinations for any possible hyperedge. To achieve this, we first count the keywords represented by each vertex oflabeled with the same parameter and assign those numbers to a set . Then, we can compute with the following formula the value of which represents the maximum number of conventional, static question-answer pairs the present statement replaces:
where is the power set of , and is the element of each subset of .
We observe that the size of , which corresponds to the number of values accepted for one parameter vertex , as well as the total number of parameter layers , have a strong influence on the overall complexity.
For the toy scenario, the value of is calculated as follows:
As result, up to 34 conventional question-answer pairs can be mapped to this single hypergraph with 3 levels and 9 nodes.
Iv-B Total questions covered by a specific statement
In order to calculate the number of standard FAQ bot questions covered by a single given hypergraph, we sum up all possible parameter-value pair combinations for each hyperedge present in the graph. To achieve this, we first identify all vertices included in a hyperedge. Then, we count the keywords represented by each of those vertices and multiply the results. In order to compute , the total number of questions covered by the hypergraph, we repeat this procedure for all remaining hyperedges, and add up the sums. The resulting formula is:
where is the set of hyperedges, and .
For example, in the case of the toy scenario illustrated in Figure 2, the value of is computed as follows:
Hence, the statement modelled in the toy scenario substitutes 13 conventional FAQ bot questions.
Iv-C Impact of large number of keywords
It is worth to note that with we only estimate the upper bound, and , the number of actual total questions covered, may be considerably lower. However, in real-world scenarios the number of keywords (#k) can easily reach much higher values than illustrated in the toy scenario, for example when the keywords represent enumerations of cities or countries.
In Figure 4, we display varying statement expressivity scenarios. Concretely, we plot the maximum number of questions that could be covered for 3 different configurations. This value, , is computed as defined in Equation 1, with respect to the number of keywords per vertex (#k). In order to investigate the impact of one variable on , we keep the number of parameters fixed to 2, and the number of response vertices fixed to 3. In the 3 different scenarios, we set the number of vertices per parameter (#v) to 2, 3 and 4.
In general, we observe that the potential number of questions which can be covered by one statement grows exponentially over the number of keywords per vertex (#k) at high rates. Even for the very low values of #v, and chosen for the scenarios, rapidly reaches the four-digit range. Further, we see that a higher number of vertices per parameter (#v) increases the growth rate significantly.
Our prototype111Source code available at
https://github.com/axa-rev/reasoning-api-framework is a multi-tenant web application implemented in Ruby on Rails, a web framework built on top of the object-oriented scripting language Ruby .
Implementing the quality engineering principle of poka-yoke, the edge validation built into the user interface guarantees hypergraph validity by design . When drawing the edges, visual feedback helps the user to avoid logical errors and enforces the connection rules as defined in Section III-B. The different cases considered are displayed in Figure 12.
We presented a top-down knowledge engineering approach which helps improve the capabilities of conversational agents. As opposed to the static answers of conventional FAQ bots, our approach enables smarter, dynamic responses. The user-friendly graphical user interface allows for rapid contract statement creation and updating with no technical skills required. The significant reduction of complexity cuts the cost to manage the contract statements, which represent the essential knowledge necessary to provide meaningful responses.
A further plus of the presented architecture is that the statement rules are exposed through a generic API. This renders the system framework-agnostic and makes it possible to integrate with any chatbot framework. Also, updates of the statement come into effect instantly. Finally, isolating the knowledge and the input validation from the chatbot framework keeps the latter light and lean.
In the future, we want to extend the keyword matching to more sophisticated methods: Fuzzy matching could render the matching process more robust towards typos. Making use of word embeddings could match synonyms which are not explicitly included in the keyword sets. Further, the data types of the keyword sets should be expanded to ranges of numbers and dates. Also, we see potential to refine the conversational flow by ranking the missing parameter values by probability and plausibility. Eventually, a language-agnostic architecture will be investigated.
-  (2015) Deep speech 2: end-to-end speech recognition in english and mandarin. CoRR abs/1512.02595. External Links: Cited by: §I.
-  (2017) An Empirical Analysis of Smart Contracts: Platforms, Applications, and Design Patterns BT - Financial Cryptography and Data Security. In Financial Cryptography and Data Security, M. Brenner, K. Rohloff, J. Bonneau, A. Miller, P. Y. A. Ryan, V. Teague, A. Bracciali, M. Sala, F. Pintore, and M. Jakobsson (Eds.), Cham, pp. 494–509. External Links: Cited by: §I.
-  Bootstrap UI Framework. External Links: Cited by: §V.
-  (2018) Back to the Future : Lessons from Knowledge Engineering Methodologies for Chatbot Design and Development. Proceedings of British HCI 2018, pp. 1–5. Cited by: §I.
-  (1971) Artificial Paranoia. Artificial Intelligence 2 (1), pp. 1–25. External Links: Cited by: §I.
-  (2018-10) Using deep learning and an external knowledge base to develop human-robot dialogues. In Proceedings of IEEE International Conference on Systems, Man, and Cybernetics, pp. 3709–3714. External Links: Cited by: §I.
-  (2017) Hands-On Chatbots and Conversational UI Development: Build Chatbots and Voice User Interfaces with Chatfuel, Dialogflow, Microsoft Bot Framework, Twilio, and Alexa Skills. Packt Publishing. External Links: Cited by: §I.
-  (2018) Motivations, classification and model trial of conversational agents for insurance companies. CoRR abs/1812.07339. External Links: Cited by: §I.
-  (2018) Alexa vs. siri vs. cortana vs. google assistant: a comparison of speech-based natural user interfaces bt - advances in human factors and systems interaction. In Alexa vs. Siri vs. Cortana vs. Google Assistant: A Comparison of Speech-Based Natural User Interfaces BT - Advances in Human Factors and Systems Interaction, I. L. Nunes (Ed.), Cham, pp. 241–250. External Links: Cited by: §I.
Using Recurrent Neural Networks for Slot Filling in Spoken Language Understanding. IEEE/ACM Transactions on Audio, Speech, and Language Processing 23 (3), pp. 530–539. External Links: Cited by: §I.
-  mxGraph Diagramming Library. External Links: Cited by: §V.
-  Ruby on Rails Web Framework. External Links: Cited by: §V.
-  (2009-01) The anatomy of a.l.i.c.e. In Parsing the Turing Test, pp. 181–210. External Links: Cited by: §I.
-  (2017-05) Contract law 2.0: ‘Smart’ contracts as the beginning of the end of classic contract law. Information & Communications Technology Law 26 (2), pp. 116–134. Note: doi: 10.1080/13600834.2017.1301036 External Links: Cited by: §I.
-  (1986) Zero quality control: source inspection and the poka-yoke system. CRC Press. Cited by: §V.
-  (1966) ELIZA. Commun. ACM 9 (1). External Links: Cited by: §I.
-  (2017) I’m sorry, dave, i’m afraid i can’t do that: chatbot perception and expectations. In Proceedings of the 5th International Conference on Human Agent Interaction, HAI ’17, New York, NY, USA, pp. 253–260. External Links: Cited by: §I.