Certains contenus de cette application ne sont pas disponibles pour le moment.
Si cette situation persiste, veuillez nous contacter àObservations et contact
1. (WO2019042738) PRODUCTION D'AGENTS CONVERSATIONNELS À PARTIR DE SPÉCIFICATION D'API WEB
Note: Texte fondé sur des processus automatiques de reconnaissance optique de caractères. Seule la version PDF a une valeur juridique

GENERATING CHAT BOTS FROM WEB API SPECIFICATIONS

FIELD

[0001] The present application relates generally to computers and computer applications, and more particularly to chat bots or robots, natural language processing, and generating of chat bots.

BACKGROUND

[0002] Chat bots, or conversational agents, communicate with users via natural-language dialogue and may operate through a web page, a phone, or a messaging system. For example, they are programmed to answer commonly asked question, help navigate a web page more effectively, or fill out online forms. Companies are increasingly relying on chat bots to offer support and services to users, for example, their customers and employees.

[0003] Like graphical applications, chat bots may accomplish their work by calling web Application Programming Interfaces (APIs). These APIs offer users access to the resources stored in a company's databases and the actions implemented in the company's systems. An approach for providing web APIs is REST (REpresentational State Transfer). In REST, the service provider hosts resources, and the service provider and consumer interact by transferring representations (typically JSON: JavaScript Object Notation) of the state of the resources.

[0004] Chat bots are difficult to build and it takes time to get them right. Unlike other software, chat bots depend upon NLU (natural language understanding), which may not be perfect. Since it is hard to anticipate what the common NLU mistakes will be, it pays to deploy an initial bot quickly and gather experience with it in the field to improve it. Chat bot development is further complicated by requiring both software development and machine learning skills. Also, since companies have only recently started to broadly embrace chat bots, there is a lack of programming models for non-experts to develop chat bots.

BRIEF SUMMARY

[0005] A method, system and computer program for automatically generating a conversational bot for an application programming interface (API) are provided.

[0006] Further features as well as the structure and operation of various embodiments are described in detail below with reference to the accompanying drawings. In the drawings, like reference numbers indicate identical or functionally similar elements.

BRIEF DESCRIPTION OF THE DRAWINGS

[0007] Fig. 1 shows an overall approach of a bot that includes an example in one embodiment.

[0008] Fig. 2 shows runtime architecture of a bot in one embodiment.

[0009] Fig. 3 illustrates in one embodiment an excerpt of a finite state machine that a bot compiler generates from an example translator application programming interface.

[0010] Figs. 4A-4D show an example dialogue with an example visual recognition web application programming interface (API) in one embodiment.

[0011] Fig. 5 is a diagram illustrating a method of automatically generating a conversational bot for an application programming interface (API) in one embodiment.

[0012] Fig. 6 illustrates a schematic of an example computer or processing system that may implement a chat bot generator/compiler system in one embodiment of the present disclosure.

DETAILED DESCRIPTION

[0013] A system, method and technique are presented for a compiler that takes a web API specification and automatically generates a chat bot to carry on a dialog with a user and make an API call or calls based on the dialogue, for instance, call a web API based on the dialogue and the API specification. In one embodiment, the generated bot is self-documenting, using descriptions from the API specification to answer help requests. The system, method and technique in one embodiment generate a chat bot from a web API specification.

[0014] An API specification defines a standard interface to APIs that invoke services. An example of an API specification includes a SWAGGER specification. In the below description, SWAGGER is used as an example API specification to describe an implementation of a compiler in one embodiment. However, the methodology of the present disclosure does not limit the API specification to SWAGGER only. SWAGGER is employed as a source language for generating a variety of artifacts including API documentation, client SDKs (software development kits), server stubs, and tests, but has not been previously used for generating chat bots. The methodology of the present disclosure in one embodiment may use an API specification such as Swagger as a source language for generating chat bots that enable end users to call a web API via natural-language dialogue.

[0015] Fig. 1 shows an overall approach that includes an example in one embodiment. The user ("H" for human) converses with the chat bot ("C" for conversational agent) by asking to translate a text. In this example, the user is already aware of the necessary parameters and knows to back-quote them. The chat bot fills in missing parameters via call-chaining and via defaults, then makes a REST call via the HTTP GET method to the translator service, and returns the result to the user. The generate chat bot allows end users to call web APIs without learning them first. Dialogues may use reflection to let the end user discover available actions and their parameters. The chat bot compiler in one embodiment allows developers to reuse existing API specifications to quickly boot-strap a full working bot.

[0016] In one embodiment, a chat bot compiler from web API specifications generates self-documenting chat bots for calling APIs. An implementation for the compiler and a realization in a messaging system is also presented. The compiler in one embodiment may generate a variety of chat bots based on a variety of API specifications. Programming models for both web APIs and chat bots are disclosed.

[0017] A concrete example is described below, using transcripts of dialogues with a bot generated by the compiler in one embodiment. The example is based on a Language Translator web API, which can translate between different natural languages, but also supports additional features such as identifying a language.

Table 1

Translator web API

1 {swagger: "2.0",

2 info: { version: "2.0.0", title: "Language Translator" },

3 basePath: "/language-translator/api",

4 paths: {

5 v2/identify*: {

6 get: {

7 summary: Identifies the language of the input text*,

8 parameters: [

9 { name: *text*, in: *query*, required: true,

10 type: *string*,

11 description: Input text in UTF-8 format.* },

12 { name: *accept*, in: *header*, required: false,

13 type: *string*, default: *text/plain*,

14 enum: [*application/json*, *text/plain* ],

15 description: *Format of the return values.*}],

16 responses: {

17 200: {

18 description: *Success*,

19 schema: { $ref: *#/definitions/identifiedLanguages* }},

20 400: ..., 500: ... } },

21 post: ...},

22 v2/translate*:

23 v2/identifiable_languages*:

24 7v2/models*:

25 7v2/models/{model_id}*: ... },

26 definitions: {

27 identifiedLanguages: {

28 required: [ languages* ],

29 properties: {

30 languages: {

31 type: *array*, description:

32 items: { $ref: *#/definitions/identifiedLanguage* }}}},

33 identifiedLanguage: {

34 required: [ language*, Confidence* ],

35 properties: {

36 language: { type: *string*, description: ... },

37 confidence: { type: *number*, description: ... }}},

38

[0018] The input to the bot compiler is a web API specification, for example, in Swagger. Table 1 shows the Swagger for the Translator service. The generated bot (which is referred to as API-bot as an example) uses the Swagger as guidance both for talking to the user (in natural language) and for calling the web API (in HTTP). Lines 1-3 specify the Swagger version, API version and title, and base path. Lines 4-25 specify paths relative to the base path for resources (nouns, e.g., identifiable languages) and actions (verbs, e.g., identify). For brevity, Table 1 shows details for only one of the actions, addressed by the path v2/identify". This path supports two operations, get and post, corresponding to the HTTP methods of the same names. Each operation has a summary, parameters, and responses, which can have both human-readable descriptions and schemas. In the example, the schemas involve references ($ref) to type definitions provided in Lines 26-38.

Table 2

Example dialogue calling the Translator web API

C: Welcome to the 'Language Translator".

@API-bot is here to help you.

What would you like to do? To begin name an action or resource.

4 H: help me please

5 C: You may work with the following resources and actions:

6 - identifiablejanguages

7 - identify

8 - models

9 - models modeljd

10 - translate

11 What would you like to do? To begin name an action or resource.

12 H: identify please

13 C: You chose: identify. What operation would you like to perform?

14 H: I have no idea, please help

15 C: Available operations are:

16 (GET) Identifies the language of the input text,

17 (POST) Identifies the language of the input text

18 H: get then

19 C: What is the value of the parameter text?

20 H: La vie est belle

21 C: identify text 'La vie est belle'

22 OK, call now?

23 H: yes

24 C: OK, making call now.

25 identify text 'La vie est belle' accept 'text/plain'

26 "fr"

[0019] Table 2 shows a transcript of a dialogue between the generated API-bot conversational agent ("C") and a human end user ("H") for calling the Translator web API. The compiler in one embodiment generates the chat bot directly from the Swagger specification shown in Table 1. On Line 4, the end user asks for help; note that rather than having to learn a computer language to know how to ask for help, they can use natural language. API-bot is configured to understand the help intent via a machine learning classifier trained from examples; Lines 14 shows a different utterance that also gets classified into the help intent. Lines 5-11 show help text generated from the Swagger paths. On Line 12, the end user picks the action "identify". Subsequently, the chat bot collects additional information it needs to call "identify". After the human has provided the operation (get) and the text parameter (La vie est belle), the chat bot calls the web API and displays the result ("fr" for French). Along the way, the bot also displays the action and its parameters concisely using back-quotes. This has two effects. First, confirmation to establish common ground with the user; and second, educating the user how to make this call more easily.

[0020] The following description shows how an API-bot is generated in one embodiment and how it works in one embodiment.

[0021] A generated API-bot conversational agent enables the end user to call a web API. Fig. 2 shows a runtime architecture in one embodiment. One or more hardware processors may execute or run the components. A dialogue controller 202 guides the conversation for calling web APIs. The controller 202 receives inputs from the user 204 via an NLU (natural language understander) component 206, and sends outputs to the user 204 via an NLG (natural language generator) component 208. In one embodiment, API-bot agents are built on the Watson Conversation Service (WCS) platform for conversational agents. API chat bots of the present disclosure may be built on another conversation service platform.

[0022] In WCS, NLU includes an entity extractor 210 and an intent classifier 212, which an API-bot customizes for the Swagger at hand. In addition, an API-bot adds a direct call parser 214 as another NLU component not usually found in WCS or other platforms. In WCS, the controller 202 can be driven from an FSM (finite-state machine) 220 dialogue specification. In one embodiment, the output of the controller 202 includes natural-language prompts for the human and HTTP calls to service endpoints. Embodiments of the NLU component 206, the mapping from API specification (e.g., Swagger) to the controller FSM 202, additional state that the controller maintains 220, the NLG 208 and actuator 216 components that implement the outputs are described in more detail below.

Input NLU

[0023] The following describes the NLU component 206 in one embodiment in further detail. The NLU component 206 turns natural-language utterances from the user 204 into symbols for the dialogue controller 202. Most modern chat bot platforms recognize two kinds of symbols: entities and intents.

[0024] An entity represents a term or object in a user utterance, and WCS marks entities with the @-sigil. For example, in Table 2, Line 18, the word get belongs to the @get entity. The entity extractor 210 in the NLU 206 may return multiple entities for a single user utterance, one for each matching term it found. The entity extractor 210 is implemented by a pattern matching engine in one embodiment. There are some entities common to all API-bot agents independently of the concrete API (e.g., Swagger) specification at hand, for instance, @get and @post. In addition, there are entities generated from parameters found in the API (e.g., Swagger) specification, for instance, ©text, ©source, and ©target.

[0025] An intent represents a purpose or goal, something a user wants to do, and WCS marks intents with the #-sigil. For example, in Table 2, Line 4, 'help me please' belongs to the #help intent. The intent classifier 212 in the NLU 206 returns the intent with the highest confidence for a given utterance, or a special irrelevant intent if nothing has high confidence. The intent classifier 212 is implemented with supervised machine learning, where the training data includes <example, intent> pairs. The intent classifier 212 works best when there are many examples for each intent, examples for different intents are not similar, and the examples are representative of actual user utterances. For instance, training examples for the #help intent might include 'help', 'What are the options?', 'What can I do', and 'what is possible'. There are some intents common to all API-bot agents independently of the concrete API (e.g., Swagger) specification at hand, for instance, #help, #yes, and #no. In addition, there are intents generated from paths found in the API (e.g., Swagger) specification, for instance, identify and translate.

[0026] While the basic NLU functionality of entities and intents suffices for many chat bots, it may be too limiting for obtaining good conversations for calling a web API. One problem is that some parameters have free-flow values that cannot be easily matched or classified against a pre-defined entity or intent. Furthermore, some inputs should be hidden from the entity extractor and the intent classifier altogether. For example, the text parameter to the identify action can contain arbitrary words that should not trigger their own entities or intent. Therefore, when API-bot prompts for such a parameter, it treats the entire next human utterance as one value, as shown in Table 2, Line 20.

[0027] While this solves the problem, unfortunately, requiring a separate turn for each piece of information leads to a prolonged dialogue. Therefore, the present disclosure introduces a quoting feature. In one embodiment, the quoting feature is represented by backquotes ('...'), because they are familiar to users of a messaging platform for rendering verbatim text. API-bots can be deployed on a messaging platform such as the Slack, and also use quotes to signal verbatim text. In addition, the present disclosure introduces a convention by which a parameter name entity in the utterance followed by quoted text sets the parameter to the quoted value. This convention makes it possible to render an API call in a single utterance, and is implemented by the direct call parser 214. For example, 'identify the text 'La vie est belle"' calls the identify action, setting the text to 'La vie est belle', and defaults to using the HTTP GET method.

Controller and State

[0028] The following describes in one embodiment the mapping from an API specification (e.g., Swagger) to the controller finite state machine (FSM) 202, and on additional state that the controller maintains 220. The controller component 202 in Fig. 2 maintains state and turns symbols from the NLU 206 into instructions to the NLG 208 and the actuator216. A low-level formalism for specifying dialogue flow in chat bots is FSMs. The WCS programming model supports FSMs, among other features. An implementation of the API-bot compiler in one embodiment uses FSMs as its code-generation target (the source being an API specification (e.g., Swagger)). Fig. 3 illustrates in one embodiment an excerpt of the FSM that the API-bot compiler generates from the Translator API (e.g., in Swagger) shown in Table 1. The following text first explains the notation and then discusses the dialogue flow it specifies.

[0029] Each rounded rectangle in Fig. 3 represents a state. There is one special start state marked with an incoming arrow that does not originate from any other state. There are several final states, marked with double borders. There is an implicit top-level loop from final states back to the start state. Directed edges between states are transitions and their labels are predicates. State labels have the form stateName / action, but most state names are omitted for brevity. Since actions reside on states, not on transitions, the FSM in one embodiment is a Moore machine (e.g., not a Mealy machine). In one embodiment of an implementation, Moore machines are implemented as the formalism because the WCS programming model supports Moore machines. Other state machine implementations may be employed.

[0030] Transition predicates are based on symbols from the NLU, in other words, entities and intents, marked with @ and #, respectively. Some transitions are marked with the empty-word symbol ε or epsilon, indicating that the chat bot does not wait for user input before taking the transition. Finally, some transitions are marked with the true predicate, indicating that the chat bot collects a user input, but treats the entire utterance as one value, without making the transition depend on what that value was. Actions in FSM states are instructions to the NLG and the actuator. For instance, the print help text action is an instruction to the NLG, and the call API action is an instruction to the actuator. For brevity, Fig. 3 does not spell out the details of the actions, but they are context specific. The context for help text is the current FSM state, and context for an API call includes the current FSM state as well as the operation and parameters collected in states leading up to it.

[0031] The dialogue flow in Fig. 3 shows five transitions from the start state.

[0032] Transition V. From start, if #help, the bot prints the list of known resources and actions, generated from the paths in Swagger. API-bot implements a heuristic to elide common path prefixes 7v2/" in the Translator Swagger because they provide no useful information and cause unnecessary confusion to end users. After displaying the help text, the chat bot returns to the start state without collecting a user input, indicated by the ε (e.g., epsilon)-transition.

[0033] Transition 2: From start, if identify Λ @text, the direct call parser has provided all the necessary information to call the v2/identify" path with the required text parameter. If no HTTP method is specified, the method defaults to GET if the path supports that. API-bot implements a heuristic to not ask for optional parameters that have a default value, such as the accept parameter in this case. Furthermore, the accept parameter implements content negotiation, a feature general to REST and not specific to the Translator API. Content negotiation is an implementation technicality better hidden from the non-technical end user.

[0034] Transition 3: From start, if identify but the previous transition did not fire, the chat bot has a chain of nodes collecting the operation and the parameters for calling the 7v2/identify" path. In this context, the help text lists operations for the given path. Fig. 3 only shows the FSM states for @get, eliding those for @post. This part of the FSM also contains an example of a true condition, because the text parameter can be any string and should thus not be subjected to NLU.

[0035] Transition 4: From start, if translate Λ ©source Λ ©target Λ ©text, the direct call parser has provided all the necessary information to call the 7v2/translate" path.

[0036] Transition 5: From start, if translate but the previous transition did not fire, the chat bot has a chain of nodes collecting the operation and the parameters for calling the 7v2/translate" path.

[0037] The state 220 in Fig. 2 includes the FSM state as well as partial information collected by the current part of the dialogue flow that drives towards the goal of making an API call.

Output: NLG and Actuator

[0038] The following describes in one embodiment the NLG 208 and actuator 216 components that implement the outputs. The NLG 208 and actuator 216 components in Fig. 2 turn instructions from the dialogue controller 202 into natural-language responses to the user 204 and HTTP calls to the REST service endpoint 218. To encapsulate the controller 202 with a clean interface, an implementation of API-bot in one embodiment reifies these instructions as JavaScript Object Notation (JSON) objects.

[0039] API-bot in one embodiment uses a simple NLG. For the most part, the API-bot NLG 208 includes literal hard-coded strings, some of which are generated from the API specification (e.g., Swagger) at compile time, for example, the list of paths in Table 2, Lines 6-10. In some cases, the NLG 208 also uses string interpolation at runtime, where string interpolation means inserting a dynamically computed substring into a constant string template at runtime.

[0040] The actuator 216 is in charge of making the HTTP calls to the web API. An example implementation of API-bot in one embodiment is written in JAVA and uses a simple HTTP client to execute a synchronous call to the service endpoint 218. In one embodiment, the actuator 216 is deployed as a local application on the end user's device. In one embodiment, the NLU 206 and most of the controller 202 are deployed as a cloud-hosted application in the Watson Conversation Service or like service. In another embodiment, the actuator 216 may be hosted on a public cloud or on the computer infrastructure of the organization offering the service endpoint.

[0041] The actuator 216 in one embodiment is also in charge of filling in default values for missing parameters, when possible. This comes in two flavors in one embodiment: (i) default values can be specified in the original API specification (e.g., Swagger) file, and (ii) the present disclosure allows API-bot annotations in the API specification (e.g., Swagger) file indicating a callback to other parts of the web API that may be used to fill in that default value. Table 3

"x-API-bot-callback": {

"params": [

{ "value": "text",

"in": "query",

"name": "text" }

L

"prefixjength": 0,

"method": "GET",

"path": 7v2/identify",

"base": language-translator/api"

}■■■

[0042] Table 3 shows the corresponding annotations for the source language parameter of the translate call in the Language Translator web API. It indicates that if the source parameter is not provided by the user, a default can be obtained by calling identify with the input text. The value of the appropriate parameter is obtained from the current context if it is present. The callback description is read along with the rest of the API specification (e.g., Swagger) file and passed through the controller to the actuator 216. It contains all the information necessary to make a sub-call to another part of the API and how to fill in the parameters for that sub-call (in this example, only the text parameter is required). The above described a compilation from an API specification to a dialogue specification.

[0043] Table 4 shows Swagger for Tone Analyzer web API.

Table 4

Tone Analyzer web API

1 {swagger: "2.0",

2 basePath: tone-analyzer/api",

3 info: {

4 version: "3.0.0", title: "Tone Analyzer API",

5 description: "Detect three types of tones from written text:

6 emotions, social tendencies, and style. ..." },

7 paths: {

8 7v3/tone": {

9 get: {

summary: "GET Analyze tone",

description: "Analyzes the tone of a piece of text.", parameters: [

{ name: "version", in: "query", required: true, type: "string", default: "2016-05-19",

description: "a date that identifies the API version" },

{ name: "text", in: "query", required: true, type: "string",

description: "Content to be analyzed." },

{ name: "tones", in: "query", required: false, type: "string",

description: "Filter the results by a specific tone." },

{ name: "sentences", in: "query", required: false, type: "boolean",

description: "Filter your response to remove the sentence level analysis." }],

responses: {

200: {

description: "successful operation",

schema: { "$ref": "#/definitions/ToneAnalysis" }},

400: ... }},

post: ... }},

definitions: {

ToneAnalysis: {

description: "The results of performing tone analysis.", required: [ "documentjone" ],

properties: {

documentjone: {

type: "array", description:

items: { "$ref": "#/definitions/ElementTone" }}, sentencesjone: {

type: "array", description:

items: { "$ref": "#/definitions/SentenceAnalysis" }}}},

ElementTone:

[0044] Table 5 shows an example dialogue with Tone Analyzer web API.

Table 5

A dialogue with Tone Analyzer web API

1 C: What would you like to do? To begin name an action or resource.

2 H: What's the tone of the text Ί am very happy"?

3 C: Calling now.

4 tone text Ί am very happy' version '2016-05-19'

5 [ { "score": 1.0,

6 "tonejd": "joy",

7 "tonejiame": "Joy" },

8 { "score": 0.97759,

9 "tonejd": "confident",

10 "tone_name": "Confident" },

11 { "score": 0.61522,

12 "tonejd": "agreeablenessj)ig5",

13 "tone_name": "Agreeableness" } ]

[0045] Table 6 shows Swagger for Visual Recognition web API.

Table 6

Visual Recognition web API

1 {swagger: "2.0",

2 info: {

3 title: "Visual Recognition", version: "3.0",

4 description: "Uses deep learning algorithms to identify scenes, objects, and faces." },

5 basePath: visual-recognition/api",

6 paths: {

7 7v3/detect_faces": {

8 get: {

9 summary: "Detect faces in an image",

10 parameters: [

11 { "$ref: "#/parameters/ApiKeyParam" },

12 { "$ref: "#/parameters/SingleURLParam" },

13 { "$ref: "#/parameters/DateVersionParam" }],

14 responses: {

200: {

description: "success",

schema: { "$ref": "#/definitions/Faces" }},

400: {

description: "Invalid request",

schema: { "$ref": "#/definitions/ErrorTopLevel" }}}},

post: ... },

... },

parameters: {

ApiKeyParam: {

name: "api_key", in: "query", required: false, type: "string",

description: "API Key used to authenticate." },

SingleURLParam: {

name: "url", in: "query", required: true, type: "string",

description: "URL of an image (.jpg, .png). Redirects are followed, so you can use shortened URLs. The resolved URL is returned in the response. Maximum image size is 2 MB." },

DateVersionParam: {

name: "version", in: "query", required: false, type: "string",

default: "2016-05-20", pattern: "A\\d{4}-\\d{2}-\\d{2}$",

description: "The release date of the version of the API you want to use.

Specify dates in YYYY-MM-DD format." },

... },

definitions: {

Faces: {

type: "object",

required: [ "images_processed", "images", "warnings" ],

properties: {

images_processed: { "$ref: "#/definitions/lmagesProcessedOutParam" }, images: {

type: "array",

items: { "$ref": "#/definitions/FacesTopLevelSingle" } },

warnings: {

type: "array",

description: "Omitted if there are no warnings.",

items: { "$ref: "#/definitions/Warninglnfo" }}}},

[0046] Figs. 4A-4D show an example dialogue with Visual Recognition web API shown in Table 6.

[0047] Tables 4-6 and Figs. 4A-4D illustrate example case studies for web APIs additional to the Translator API examples described above, demonstrating that the API bot of the present disclosure works for more than just one particular API. The API bot of the present disclosure in one embodiment may also be integrated with a messaging platform such as the Slack messaging platform, a real-time messaging system.

[0048] The Tone Analyzer analyzes text documents to detect three things: emotions (e.g., anger, joy, sadness), style (e.g., confidence, tentativeness), and social tendencies (e.g., extraversion, agreeableness). Table 4 shows an excerpt of the web API specification. It offers only a single path, 7v3/tone", with four parameters, version, text, tones, and sentences. Three of the four parameters are either optional or have a default value, leaving only the text parameter as mandatory information to be specified for each call. Table 5 shows the transcript of an API-bot dialogue for calling the Tone Analyzer. The human simply makes a direct call, setting the text to Ί am very happy". The result of the call matches what one would expect given the input text. The analyzer determined that the dominant emotion is joy, the style is confident, and the strongest social tendency found in this text is

agreeableness.

[0049] The Visual Recognition API shown in Table 6 analyzes image files to identify three things: scenes, objects, and faces. Table 6 shows an excerpt of the web API specification. The excerpts from the web API specification hones in on only one of the paths, 7v3/detect/faces". In one embodiment, the parameters are declared by reference instead of inline, because other paths share some of the same parameters. There are three parameters: api_key (a hard-to-guess string of digits and numbers used to authenticate); url (an address of an image file); and version (an API version given as a string). The version has a default value.

[0050] Figs. 4A-4D show the transcript of an API-bot dialogue for calling the Visual Recognition API. It is a screenshot of API-bot running integrated into the Slack messaging platform. Slack is often used for persistent multi-party chat by collaborating teams. In this case, there are two participants, API-bot and a human end user called louis. The dialogue showcases a step-by-step call, where the end user asks for help and the chat bot prompts for parameters one by one. The end user copy-and-pastes the API key, which they obtained separately. One Slack feature is that when a user pastes a Uniform Resource Locator (URL), it displays a preview of its destination. In this case, the URL is a picture of a historical personality, and Slack shows an excerpt of the surrounding Wikipedia article. API-bot does not prompt for the version parameter, because the Swagger specifies a default for it. The version parameter may be set explicitly via a direct call.

[0051] Before making the call, API-bot in one embodiment echoes the concise version for grounding and teaching. This illustrates how backquotes are rendered in Slack markdown. In one embodiment, the quoted text shows up in a typewriter font with a different color scheme than normal text. In the end, API-bot makes the call, and the Visual Recognition API reports back its guess for the age, gender, and identity of the historical personality. These guesses are accurate.

[0052] Besides the formatting advantages, there are other good reasons for integrating bots that call web APIs into Slack or a similar messaging platform. Since users at a company may often chat with each other via Slack, putting the chat bot there reduces the need to context-switch. In the calling case, it provides a persistent record of what happened for accountability. It is also an easy way to keep each other informed, for instance, when the web API returns a kind of status report. Also, it increases the learning opportunities, where one user's successful calls are there for other users to emulate.

[0053] As described, different API-bot chat bots may be generated from different API specifications. A chat bot in the present disclosure that is generated from an API specification enables a conversation to drive an action, e.g., a web API call. A chat bot of the present disclosure in one embodiment may be completely self-documenting. For instance, the user can learn everything they need to know about the chat bot, including how to make direct calls, by interacting with it.

[0054] VoiceXML is a standard that was designed to play the same role for conversations that HTML plays for visual content. The vision was that there would be a conversational web, where providers serve up VoiceXML; consumers interact with VoiceXML via voice browsers; and VoiceXML can be hyper-linked. A draw-back of VoiceXML is that it requires providers to write new chat bots in that language. In contrast, API-bot of the present disclosure in one embodiment uses pre-written API specifications such as Swagger to boot-strap a chat bot.

[0055] Swagger is designed as a source language from which to generate assorted different artifacts. Swagger user interface (Ul) visually renders documentation, and lets developers interact with a web API in a sandbox. However, that interaction differs from API-bot in that it does not use natural-language conversation, does not target end users, and is not intended for production use.

[0056] Natural language interfaces to databases (NLIDB) may generate NLIDB agents from database schemas. NLIDB work that employs multi-turn conversation has only emerged recently and is still an active research area.

[0057] If this then that (IFTTT) enables end users to call web APIs in a simple and convenient way. Participants in the IFTTT ecosystem must wrap their end-points into either triggers or actions. Once those are created, the end user can put them together into recipes. In contrast, with API-bot, participants need not wrap their end-points in actions; instead, the actions are compiled into the chat bot by using an API specification as the source language. Also, unlike API-bot, IFTTT does not offer a natural-language chat interface.

[0058] Programming with Natural Language

[0059] While works related to natural language programming may include generally transforming natural language sentences to formal languages, they do not generate chat bots from API specification or web API specifications, or a chat bot so generated that is self-documenting.

[0060] The system, method and technique in one embodiment presents a compiler from web API specifications (e.g., written in Swagger) to chat bots for calling those web APIs. In one aspect, the compiler allows an enterprise that has an API (e.g., Swagger) specification for the services it offers its customers or employees to immediately obtain an initial natural-language chat bot for them. Doing so enables the company to improve the chat bot, which tends to be a continuous feedback-driven process. The generated bot is self-documenting, so for example, that users who do not know how to use the bot or the web API can find out how to do that by interacting with the bot. The compiler, for example, can render sophisticated APIs easy to call via chat bots.

[0061] Fig. 5 is a diagram illustrating a method of automatically generating a conversational bot for an application programming interface (API) in one embodiment. The method is executed by one or more hardware processors, for examples, as described with reference to the components shown in Fig. 2. At 502, an API specification is received that includes information associated with invoking an API call. An example of such API specification is Swagger specification. At 504, the API specification is parsed. At 506, based on parsing the API specification, a conversational bot specification is constructed. For instance, a finite state machine may be constructed. The finite state machine includes a plurality of states and state transitions, and specifies a dialogue flow for the conversational bot. An example of a finite state machine is shown in Fig. 3. Referring to Fig. 5, at 508, a natural language expression such as a text expression or an utterance or audible speech is received from a user.

[0062] At 510, the natural language expression is transformed into instructions. For instance, the natural language expression is transformed into symbols, and the symbols are transformed into instructions for generating a natural language prompt to the user and/or executable computer code for invoking the API call. In one embodiment, the symbols may be transformed into instructions based on a finite state machine that is constructed, for example, as part of the conversational bot specification. In one embodiment, the symbols are transformed into instructions by being used to trigger a state transition, and using the action of the target state as instructions.

[0063] At 512, the natural language prompt or response is generated based on the instructions. The natural language prompt or response is generated, for instance, responsive to the instructions containing a prompt to be presented to a user, for example, for asking for confirmation or a question. An instruction may include or specify a string that literally contains the natural-language prompt to be displayed or uttered. In another embodiment, string interpolation may be performed to generate the natural language prompt.

[0064] At 514, the natural language prompt or response is presented, for example, displayed and/or uttered to the user, for example, as text or uttered by a voice synthesizer or like device coupled to the one or more hardware processors, for instance, responsive to generating the natural language prompt at 512.

[0065] At 516, it is determined whether the instructions contain a call to an API. At 518, if the instructions instruct to call the API, a computer code to invoke the API call is executed. The computer code may be generated, for instance, based on the instructions that contain a call to an API. The logic of method may return to 508 and iterate the processing, for example, according to the dialog flow specified in the conversational bot specification. If at 516, the instructions do not contain a call to an API, the processing may return to 508 and repeat the processing at 508-516, for example, based on the conversational bot specification, e.g., including a finite state machine, to carry on the dialogue flow for invoking the API call.

[0066] An example of the computer code to invoke the API call includes a hypertext transfer protocol (HTTP) call to a service endpoint providing a service associated with the API call. As an example, the API specification may be a web API specification and the API call may include a Representational State Transfer call.

[0067] In one embodiment, as described above with reference to the NLU component, the symbols may include at least entities representing objects in the natural language utterance and intent representing a purpose in the natural language utterance. In one aspect, the dialogue flow may include invoking multiple API calls, wherein the multiple API calls are invoked in a single dialogue.

[0068] The compiler in another embodiment may include authentication features. In addition, the compiler may allow results from one API call to feed into another. For instance, the list of identifiable languages helps determine allowable values for the source and target language in a translation. Thus, multiple calls may be strung together. Still yet, bots may be generated from a collection of API specifications.

[0069] Fig. 6 illustrates a schematic of an example computer or processing system that may implement a chat bot generation system in one embodiment of the present disclosure. The computer system is only one example of a suitable processing system and is not intended to suggest any limitation as to the scope of use or functionality of embodiments of the methodology described herein. The processing system shown may be operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well-known computing systems, environments, and/or configurations that may be suitable for use with the processing system shown in Fig. 6 may include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, multiprocessor systems, microprocessor-based

systems, set top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the above systems or devices, and the like.

[0070] The computer system may be described in the general context of computer system executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, and so on that perform particular tasks or implement particular abstract data types. The computer system may be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.

[0071] The components of computer system may include, but are not limited to, one or more processors or processing units 12, a system memory 16, and a bus 14 that couples various system components including system memory 16 to processor 12. The processor 12 may include a module 30 that performs the methods described herein. The module 30 may be programmed into the integrated circuits of the processor 12, or loaded from memory 16, storage device 18, or network 24 or combinations thereof.

[0072] Bus 14 may represent one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnects (PCI) bus.

[0073] Computer system may include a variety of computer system readable media. Such media may be any available media that is accessible by computer system, and it may include both volatile and non-volatile media, removable and non-removable media.

[0074] System memory 16 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) and/or cache memory or others. Computer system may further include other removable/non-removable, volatile/non-volatile computer system storage media. By way of example only, storage system 18 can be provided for reading from and writing to a non-removable, non-volatile magnetic media (e.g., a "hard drive"). Although not shown, a magnetic disk drive for reading from and writing to a removable, non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable, non-volatile optical disk such as a CD-ROM, DVD-ROM or other optical media can be provided. In such instances, each can be connected to bus 14 by one or more data media interfaces.

[0075] Computer system may also communicate with one or more external devices 26 such as a keyboard, a pointing device, a display 28, etc.; one or more devices that enable a user to interact with computer system; and/or any devices (e.g., network card, modem, etc.) that enable computer system to communicate with one or more other computing devices. Such communication can occur via Input/Output (I/O) interfaces 20.

[0076] Still yet, computer system can communicate with one or more networks 24 such as a local area network (LAN), a general wide area network (WAN), and/or a public network (e.g., the Internet) via network adapter 22. As depicted, network adapter 22 communicates with the other components of computer system via bus 14. It should be understood that although not shown, other hardware and/or software components could be used in conjunction with computer system. Examples include, but are not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.

[0077] The present invention may be a system, a method, and/or a computer program product. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.

[0078] The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.

[0079] Computer readable program instructions described herein can be downloaded to respective

computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and

forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.

[0080] Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.

[0081] Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.

[0082] These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.

[0083] The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer,

other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.

[0084] The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.

[0085] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.

[0086] The corresponding structures, materials, acts, and equivalents of all means or step plus function elements, if any, in the claims below are intended to include any structure, material, or act for performing the function in combination with other claimed elements as specifically claimed. The description of the present invention has been presented for purposes of illustration and description, but is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the invention. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.