Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Chatbot Tutorial - Create your first bot with Xatkit

436 views

Published on

Xatkit is an open source bot framework that makes as easy as possible the creation of smart chatbots.

Published in: Software
  • Be the first to comment

Chatbot Tutorial - Create your first bot with Xatkit

  1. 1. Tutorial on Chatbot Development with Xatkit Easiest way to create advanced (chat)bots and digital assistants - #OSS #low-code @xatkit – xatkit.com
  2. 2. Why Chatbots
  3. 3. “Business Insider experts predict that by 2020, 80% of enterprises will use chatbots. … by 2022, banks can automate up to 90% of their customer interaction using chatbots … 40% of large companies employing more than 500 people plan to implement one or more intelligent assistant…” - https://chatbotsmagazine.com/chatbot-report- 2019-global-trends-and-analysis-a487afec05b Chatbot market to surpass 1B USD by 2021
  4. 4. But what is exactly a Chatbot? • Chatbot = Bot + Conversational Interface CI = Chat interface OR voice interface • Chatbot = Digital Assistant
  5. 5. Challenges in building Chatbots
  6. 6. Let’s create a chatbot to help newcomers to write issues on Github! Alright! It’s just a set of questions & answers, this will be pretty simple! Narrator It wasn’t. Once upon a time (when we were naïve enough to think that creating a chatbot would be easy)
  7. 7. Chatbot applications Our idea of the kind of rules we were hoping to write User Intent Action Parameters If the User Wants To Open Issue Reply « In which repository? » on Slack Platform
  8. 8. What went wrong? – Many pieces to put together Input/Output Messaging channels External Platforms NLU Engine
  9. 9. Chatbots are complex systems Conversation Logic Text Processing External Services Messaging Platforms Deployment Evolution Maintenance Tests
  10. 10. At the core: NLP/NLU component • NLP: Natural Language Processing. NLU: Natural Language Understanding. In theory, NLU is a more sophisticated version of NLP. In practice they are both used mostly indistinctintly • Two key missions • Classify the user utterance in one of the intents defined in the bot • Identify the parameters (called « entities ») from the utterance
  11. 11. NLU approaches • Regular expressions • Require an almost exact match. Not used • Grammar-based approaches • Useful for small domains with a very specific vocabulary and constructs • E.g. Stanford Parser • Neural Networks - Multiclass classifiers • You provide some training sentences for each intent (the "classes" ). The classifier learns from these sentences and tries to assign any new input text to one of the classes. • It’s most common approach nowadays
  12. 12. Common tricks in NLUs • Tokenizers split the sentences into words • Stemmers identify the lemma of the word (e.g. to focus on the verb, not on the tense of the verb for matching purposes) • Synonyms are an automatic way to expand the training sentences • Entity augmentation also generalize training sentences • E.g. What’s the weather in Barcelona -> What’s the weather in @city (the intent will match no matter what city the user asks for, no need to train the classifier with all the cities of the world as it will already know the list of cities itself). • Augmentation is possible for a large number of data types and common concepts (measures, countries, dates,…) https://medium.com/@jseijas/how-to-build-your-own-nlp-for-chatbots-9b4c08eb03a9
  13. 13. Chatbot Development Platforms
  14. 14. The AI ecosystem is huge
  15. 15. >100 chatbot platforms • Rasa, BotPress, Chatfuel, Inbenta, Botsify, Flow XO,… • And quite a few NLU providers: DialogFlow, Lex, LUIS, Watson, NLP.js
  16. 16. … but • Only around 15% are open source • Not flexible (i.e. difficult to integrate other platforms) • Not interoperable • Low-level (as soon as you need the bot to do some action you end up programming in JS)
  17. 17. • Grady Booch – history of softwre engineering The entire history of software engineering is that of the rise in levels of abstraction - Grady Booch Also true for AI/chatbots -> Chatbot Modeling to the rescue!
  18. 18. The Xatkit solution
  19. 19. Xatkit – Key Concepts
  20. 20. Xatkit Framework • Raise the level of abstraction at what chatbots are defined • Focus on the core logic of the chatbot • Conversation and user interactions • Action computations • Independent from specific implementation technologies • Automatize the deployment and execution of the modeled chatbot • Deploy over multiple platforms • Execute the chatbot logic
  21. 21. Xatkit is: • A model-based & low-code chatbot development platform • Where chatbots are defined using a couple of external DSLs • And with a runtime engine that deploys and executes the bots over the desired platforms
  22. 22. In Xatkit, platforms are • An abstraction of any input/output messaging tool and any external service. Platform interfaces are also defined with a DSL • Platforms offer actions (that the bot can execute) and events (whom the bot can subscribe to) • PIM/PSM : Bots can be defined using generic platforms that are then concretely instantiated during the deployment. No need to change the bot • Any new platform becomes immediately available to any existing bot
  23. 23. Voice support • Voice interfaces (like Alexa) are just another platform • Voice is translated into text (speech2text tools) and then processed as if the user had written it.
  24. 24. Xatkit Architecture
  25. 25. Xatkit Framework Chatbot Designer Intent Recognition NLU Providers (platform-specific) Platform Package Intent Package Xatkit Modeling Language Chatbot User Instant Messaging Platforms Xatkit Runtime Execution Package uses uses Platform-independent chatbot definition External Services Deployment Configuration Platform Designer
  26. 26. Intent Language (example bot to create new issues in a GH repo) intent OpenBug { inputs { "The plugin is not working" "I have a problem with the plugin" "I'd like to report an error" "I want to open a bug" "There is an error in the plugin" } } intent DescribeBug { inputs { "My error is Error" "The problem is Error" "I get this error: Error" "I get the error Error“ } creates context bug { sets parameter title from fragment Error (entity any) } } • Inputs defines the set of training sentences for the intent • A context records variables to be used later on in the execution model. Here we store the info about the error in the title attribute of the Repository context. • Entity defines the type of the value to be matched (any is anything, number would match numeric values,…). You can also define your own enumeration (e.g. cities) to be even more precise
  27. 27. Execution language • The execution model follows state machine-like semantics • Each state in the execution language contains 3 sections • Body (optional): the bot reaction, executed when entering the state. • Next (mandatory): the outgoing transitions defined as condition –> State. The conditions are evaluated when an event/intent is received. If a transition is navigable the execution engine moves to the specified state. Transition conditions can be as complex as you want. • Fallback (optional): Arbitrary code (as the Body section) that will be executed if the engine cannot find a navigable transition.
  28. 28. Execution language • An execution model also contains 2 special states: • Init: a regular state that is entered when the user session is created. It can contain a Body, Next, and Fallback section. • Default_Fallback: This state represents the default fallback code to execute when there is no local fallback defined in a state. It can be used to print a generic error message (“Sorry I didn’t get it“), while local fallback can print a custom message tailored to the current state (“Please reply by yes or no“). • States can define a single wildcard transition (using the reserved character _ as the condition) that will be automatically navigated when the state’s body has been computed.
  29. 29. Execution Language Example import platform "GithubPlatform" import platform "SlackPlatform" use provider SlackPlatform.SlackIntentProvider use provider GithubPlatform.GithubWebhookEventProvider Init { Next { event == Issue_Opened --> HandleIssueOpened intent == GetIssue --> HandleGetIssue intent == OpenBug --> HandleOpenBug } } • The import platform allows you to easily interact with any existing platform, e.g. replying on Slack or asking GH to create the issue • The init state checks whether the user wants to get information about an issue, open a new bug, or it is GitHub itself that sends us an event to notify of changes in the repo
  30. 30. Execution Language Example HandleOpenBug { Body { SlackPlatform.Reply("Can you please describe what is wrong in a few words?")} Next { intent == DescribeBug --> HandleDescribeBug } } Default_Fallback { Body { SlackPlatform.Reply("Sorry, I didn't get it") } } • If the user wants to open the new bug we start the process of collecting the required data • If we don’t manage to understand what the users says, the default fallback will be executed instead.
  31. 31. Platform definition • The execution model can directly refer to all predefined platforms in Xatkit. 10+ right now: Slack, Zapier, Alexa, UML, Giphy, GitHub, Neo4j,… • Chatbot designers only need to define a new platform if they have special needs. This implies: • Declaring the platform interface • Implementing the platform itself as a Java class in the proper place in the platform hierarchy • Plenty of auxiliary classes and boilerplate code facilitate this implementation
  32. 32. Platform Language Abstract platform Chat actions { PostMessage(message, channel) Reply(message) } } Platform Slack extends Chat Platform Discord extends Chat Platform Github actions { OpenIssue(repository, title, content) GetIssue(user, repository, issueNumber) … } event Issue_Opened event Issue_Edited … • Platforms are also declaratively defined • Platform hierarchy facilitates reusability and genericity • Platforms offer actions to be executed and events to subscribe to
  33. 33. The compute method shows how we implemented the PostMessage action in Slack
  34. 34. Xatkit Framework Intent Recognition Providers (platform-specific) Platform Package Intent Package Xatkit Modeling Language Instant Messaging Platforms Xatkit Runtime Execution Package uses uses Platform-independent chatbot definition External Services Deployment Configuration Chatbot Designer Chatbot User Platform Designer
  35. 35. Runtime Component • Generic event-based execution engine • Loads the platform-specific connectors referenced in the bot definition • Automatic deployment • Execution life-cycle • Inputs • Chatbot model (defined with the Xatkit modeling language) • Configuration file (Oauth tokens, API keys, platform-specific parameters,…)
  36. 36. Runtime configuration example // Intent Recognition Provider Configuration xatkit.intent.recognition = DialogFlow xatkit.dialogflow.project = dialogflow_project_id xatkit.dialogflow.credentials = key.json // Platform configuration xatkit.slack.credentials = slack_oauth_token xatkit.discord.credentials = discord_credentials xatkit.github.credentials = github_oauth_token
  37. 37. Xatkit Tool
  38. 38. Tool Support • Available on GitHub as an independent organization: https://github.com/xatkit-bot-platform/ to facilitate external contributions • Open source (EPL v2) • With tutorials and examples to help you get started building bots!
  39. 39. It comes with an Eclipse Editor – Xtext-based
  40. 40. Care to contribute? • With your own examples • Improving our platform support • Extensions to the current platforms with new actions or events • New platforms • Our own NLP connectors • Adding support for new providers • Or in any of the many other ways you can help an OSS project https://livablesoftware.com/5-ways-to-thank-open-source- maintainers/

×