hi friends I'm Paris and welcome to my another video on building chat Bots using result open source and also python but before that now this video will be a tourist training course but if you're interested on a complete course on building chat bot with python address or open source then you can join my complete course on udemy I've added the link in the video description and you can join this course and there are different topics about result open source and python like uh introduction to a song conversational AI understanding Russia I know you building videos
chatbot and API calls Advanced any leave techniques rsr forums fallback on human hands of rasan mySQL database deploy a search chatbot on different platforms like Facebook Messenger slack telegram WhatsApp and rasan flask integration now this core course will be regularly updated so if you want to join this course then you can I have added the link in the videos description and you can join this course so now let's start our video welcome to the first video of the course onward saw open source on python in this video we will explore the fascinating world of conversational
Ai and understand the rule of Russell and building conversational applications now let's get started so first off all what is conversational AI conversational AI refers to the technology that enables machines to understand and respond to human language in a natural and interactive manner it allows users to have conversations with machines such as chat Bots or virtual assistants as if they were communicating with another human being so let's talk about the key components of the conversation of AI now to build the effective conversational AI systems we need two key components the first one is a natural
language understanding or nlu and also dialogue management now nlu focuses on interpreting and extracting meaning from user input including intents it means the user goals or purpose and entities it means relevant pieces of information on the other hand dialog management is responsible for managing the conversation flow deciding the appropriate responses and maintaining context throughout the introduction so you will know that we're going to use resolve now let's talk about the result so what is Russell so rasa is an open source framework specifically designed for building conversational AI applications it provides a comprehensive setup set of
tools libraries and development resources to create chat Bots and virtual assistants with result developers have the flexibility to design and customize conversational flow according to specific requirements so now we have two types of Russell the first one is Russell open source so Russell open source is an open source conversational AI platform that enables users to build chat Bots and virtual assistants capable of understanding and holding conversation with users it provides tools for natural language understanding or nlu and also dialogue management and it allows developers to create contextual assistants on different matching channels and third-party system
through a set of apis now there are some key features of rasa open source the first one is natural language understanding or nlu so rasa nlu helps the platform understand user messages and extract relevant information to determine user intents and entities another one is dialogue management or soccer is responsible for holding conversations with users and make decisions based on previous interactions and guiding the flow of the network conversation another one is connect messaging channels now result open source allows you to deploy chat both and virtual assistants on popular message messaging platforms such as Facebook Messenger
slack telegram to let you and many more and also custom conversation conversational channels now developers can also connect Russell based assistant to their own custom conversation channels our voice assistance and it enables flexibility and deployment now result open source is free to use and it is open source nature enables developers to have full control a control over their machine learning models and the flexibility to customize the pipeline for nlu and dialog management now on the other hand we have rasa Pro so now grasshopper is commercial Pro could offering of Russell that is specifically designed to
cater to Enterprise needs related to security observability and scalability it's an extension of the resource platform and is tailored for organizations and businesses that require Advanced features and support in their conversational AI projects rasa rasa Pro provides additional functionalities and tools by on the capabilities of the open sources of framework and this makes it suitable for larger scale operations and Enterprise grade conversational AI projects now let's talk about some of the key features and benefits of Russell Pro so the first one is enhanced security so Russell Pro offers robust security measures to protect sensitive data
and ensure compliance with Enterprise level security standards another one is Advanced observability so resopro provides improved monitoring and Analytics tool to gain insights into the performance and behavior of chat Bots and virtual assistants another one is scalability so russopro is optimized to handle High volumes of interactions and seamlessly skill to meet the demands of large organizations and the last one is Enterprise grade support So users of Russell Pro receive dedicated and proactive support from the rasa team and ensuring smooth deployment and ongoing maintenance of their conversational AI applications so now let's talk about some benefits
of using Russo so there are several advantages to using resolver conversational AI development Russ offers flexibility and it allows developers to Define their own nlu models dialogue policies and custom actions it's also scalable capable of handling both small scale and Enterprise level applications additionally results open source nature allows for Community contributions and this makes it a vibrant and constantly evolving framework now let's talk about the Russell architecture it will be bravely so as we already have talked about this oras architecture consists of two main components or assignee Liu and Russell core so rasanelio handles the
natural language understanding tasks such as intent classification and entity extractions so right now we haven't learned about intents and entities we will talk about that but it learns from annotated training data to accurately interpret user inputs rasa core takes care of dialogue management using a machine learning based approach to decide the next based action based on the conversation story so now Russell has been successfully employed in different Industries so let's talk about some real world cases so for example and customer support resource chat Bots can handle frequently asked questions Provide support documentation and even solve
complex issues to human agents and Healthcare Russell uh can assist with appointment scheduling symptom analysis and general medical information and in financial institutions can use yourself for banking inquiries uh account plans checks and transaction uh history retrieval so now to begin your journey with Russell you can access the offshore result documentation which provides detail guides tutorials and examples Russell also has an active Community Forum where you can ask questions seek assistance and connect with other developers by leveraging these resources you can quickly dive into the world of conversational AI with rasa so now you have
a solid understanding of a conversational Ai and the rule of rasa and building conversational applications and upcoming videos will dive deeper into different aspects of rasa and explore how to leverage its power to create intelligent chat Bots in this video we're going to provide a comprehensive overview of our saw an open source framework for building conversational AI applications we will explore the key components of rasan and error functionalities and giving you a solid understanding of how Russell works and how it can be utilized to develop powerful chat Bots and virtual assistants now we already have
talked about some of them but let's recap that in more details so the first one the first key component is Rasa nlu or we can say natural language understanding now rasanally is responsible for understanding and extracting structured data from user messages it involves two primary tasks intent classification and entity documentation and then classification aims to determine the intention or propose behind a user's message while entity recognition involves identifying important pieces of information such as names dates or locations within the message now for example let's say you're building a customer of support chatbot for a travel
agency now a user might send a message like I need to book a flight from New York to London on July 15th now in this case rasanilu would classify the intent as book flight and also extract the entities like New York this will be the source London will be the destination and July 15th will be the date so another one is Russell core now rasakur is responsible for managing the dialog flow and making the chatbot context aware it enables the chatbot to hold the meaningful conversations with users by tracking the conversation history and deciding which
actions to take based on the current state and user input for example let's consider a food ordering chatbot after user expresses the intent to order food rasakur keeps track of the dialogue and respond accordingly if the user provides a specific for preference later in the conversation rasakor ensures the chat that the chatbot understands and responds appropriately offering relevant mini options and checking for the availability so here let's check that how these Concepts work together and afford ordering chatbot for example rasanally will process the user message like I want to order a large pepperoni pizza with
extract cheese now we're assignedly extract uh extracts the intent like order pizza and entities like size large type of Peroni extra toppings or extra cheese now Russell core tracks the dialogue history and identifies the uh the current state of the conversation so another key component is Russell action server now the resurrection server is a component that handles custom actions and generates Dynamic responses based on the chatbots logic now custom actions can perform tasks such as calling external apis during databases or performing calculations the action server connects the chat bot to these external services and provides
the necessary data for generating responses for example let's say You're Building A weather chatbot when a user asks for the weather forecast a custom action and action server can be triggered the action can make an API call to a Weather Service retrieve the forecast for the requested location and provide the information back to the user as part of the chatbot response now let's make all together in a reader chatbot for example laurissa nlu Russell core and Russell action server okay so for example in here you can see the users say what's the reader like in
New York City now the user sends the message to the chatbot what will be the message so what is the reader in New York City now in here the user sends the message to the chatbot and Russell annually you process the input so when the for example Russell analia processed the input there will be intent like inquiry reader and the entities will be location navier received the processed message from the rasa nlu and identifies the appropriate action to take based on the intent and conversation history a custom Brussel action called action good reader so after
the first steps or a soccer and the Second Step a custom proso action called action git reader is triggered this action is responsible for making an API call to a Wither service to retrieve the weather forecast for the specified location for example Newburgh City and the action get reader action calls The Weather Service API with a provided location like help New York City now the way your service API Returns the weather forecast so after calling it will for example return the weather forecast for New York City like today it will be partly cloudy for example
with a high of 75 uh and a low of 60. okay and then the action get reader action formats the weather forecast after returning that it will format that information into a response message message and then rasa course sends the response message to the user what will be the message the chatbot will say for example today it will be partly cloudy with a high of 75 and low of 60 and New York City now the user might respond with additional questions or comments and the conversation continues with Russell you rasa core and custom actions handling
the dialog flow and providing accurate with information based on the user's request now this way the weather chat bot is can text aware as it tracks the conversation history and can handle different user queries related to the reader forecast for different locations the custom action enables the chatbot to interact with external services like the weather API and provide real time and relevant information to the users so another component is resize DK so now there's a SDK or we can say resource software development kit allows developers to extend the functionality of the result by creating custom
components and implementing complex business logic SDK provides a set of tools and utilities for building custom actions creating domain specific chatbot behavior and integrating external system for example imagine you're building a chatbot for an e-commerce platform you can use the result SDK to create a custom component that handles Payment Processing the custom component can interact with a payment Gateway API validate payment details and return the payment confirmation stitches to the status to their chatbot for a seamless transaction experience and another one is Russell X so Russell X is a tool even will not work on
rasa X in this course so Rosa X is a tool designed for collaborative board development and Model Management it provides a user-friendly interface for training testing and iterating on chatbot models brassix also allows you to collect user feedback and integrate it into the training pipeline today continuously improve your chatbots performance for example when deploying a chatbot using resix you can invite team members or stockholders to review and annotate conversations they can provide feedback uh correct misclassified intents or entities and suggest improvements now this collaborative feedback loop helps refine the chatbots training data and then show
and enhance it is accuracy over time so now we can say that these Concepts form the core components of Russell and enable developers to build sophisticated and context over chatbot applications each component plays a crucial and important role in understanding user inputs managing dialog executing custom actions extending functionality and iteratively improving the chatbots performance until now we know about some core concept of rasa now in this video we will learn how to set up the development environment for Sr so you're going to start building powerful conversational AI applications before we dive into creating chat Bots
with rasa it's important to ensure that we have the necessary tools and dependencies installed on our system this video will guide you through the step-by-step process of setting up your development environment for rsr using python now first we will discuss the prerequisites for working with rasa now you will need to have python installed on your machine so preferably version 3.6 or higher so it should be higher I'm using python 3.9 so we will also explore the importance of using a virtual environment to isolate our project dependencies also we're going to use pycharm ID for our
project so if you have not downloaded you can just download that from jetbrain.com so next we will walk through the installation of rasa now Russell provides a simple command line tool called pep that allows us to install the necessary result components and dependencies with easy we will cover how to install Russell open source which includes bot Russo nlu and Russell core once rasa is installed we will create a new virtual environment specifically for our soft project this virtual environment will help us to keep our project dependencies separate from other python projects on our system and
whenever when you're using file charm IDE when you create a project it will automatically create a virtual environment for you also it ensures a clean and controlled environment so for example when you're using virtual environment now to ensure that our development environment is properly configured we will run a quick a quick test to verify that Russia is installed quickly and working as expected we will use a simple command comment to launch the resource shell where you can interact with a chatbot and test its basic functionalities by the end of this video you will have a
fully setup development environment for a saw ready to start building chat Bots and exploring the exciting world of conversational AI now remember that having a properly configured development is important for smooth and efficient development uh so follow along with the step-by-step instructions in this video to ensure you're all set set up and ready to go so now let's do it practically so I already have mentioned that you should have a pycharm ID so you can just go to the jetprints.com and you can download it so there are two versions We are using the community and
free version okay so I already have created a project at Nemo frassar core course with the virtual environment now how you can create this you can just go to the file after that you can just go to the new project and in here so you can see that we have previously configured interpreter if you choose this then you will not have any virtual environment if you choose this so new environment then you will have a virtual EnV okay so you can choose one of them so I have used this you can just give the name
of the project choose a virtual environment after that choose the location of the project click on create the project will be created so I'm using python 3.9 but you can use any version it should be above 3.6 so after creating of the project so you can just give these informations so make sure that you choose this new environment using and you can just click on create then the project will be created so you can see that we have our virtual AVN that's created so after that what we want to do we want to install Russell
okay so and here at the bottom we can see that we have something that's called terminal so you can just click on this the terminal will be open so there's the virtual environment now it is automatically activated you do need to activate that in pie chart now in here we can just use pep okay and after that hit enter and it will take a little bit we need to just wait for the complete installation of Russell alright now all packages has been installed so now if I say result version and you will see that we
have the Russell Virginia and you can see that this is the result version this is the result SDK version we're using 3.6.4 the latest version and we have information about the Russell creating a new result project as the first step toward building powerful conversational AI applications in this video we will walk you through the process of setting up an eraser project from scratch and allowing you to unleash the potential of chat Bots and explore the exciting world of conversational AI now there are two comments that you can use for creating resolve project now we ever
assigned it and we have rasa and it dash dash no prompt now the assign it command as used to initialize a new result project it sets up the directory structures and creates the necessary files for your chatbot now when you run a rasa and net without any additional Flags it will prompt you with a series of questions to configure your project it will ask you for the project name whether to include example trainings data watch nlu pipeline to use and other configuration options this attractive prompt allows you to customize the setup of your project based
on your specific requirements on the other hand rasa initial prompt is a comment that skips the interactive prompt and uses default settings for the project initialization it sets up the project with predefined configuration including example training data and pre-selected in Lu pipeline this option is useful if you want to Quick up if you want a quick way to get started without going through the Antarctic interactive configuration process by using rasa init dash dash no prompt you can get a basic chatbot project app and running more quickly but you will have to modify the generated files
and configurations manually if you want to customize them later on so right now we are using this dash dash no prompt because we want to just test the chatbot and after that in the next videos we will use the resign it so now let's do it practically so right now we can see that we already have installed raso and we have our project so in here I can just uh first I need to just create a directory in here so let me uh just create a new directory let me just say uh first project for
example we can just name it CDE first project and inside this first project we want to create our chatbot files so I can just say rasa in it Dash Dash no prompt okay after that hit enter so now it will create our project and let's just wait so you can see that it's it's not asking me anything so for example give your project name or and which directory you want to create up do you want to train your model or not it's directly training the model so training an initial model and it's just creating a
a project for us a chatbot for us that we can just uh start asking the chat one so let's just wait for the uh now it will train the model automatically there's nothing you can just say rasa in it no prompt then it will do the job it will create the project it will create the chatbot files it will print the chatbot with some basic training examples and let's just wait so we should wait for the first time so because that's training the model so you can see finished training components okay so your assault model
is trained and saved in here so right now if you see in here uh the projects created and we have some files don't worry about these files we will talk about these files but right now let's check that uh we want to just open our resource shell to just uh and track with this chatbot so right now you can see it's starting server on this and you will see that we have some files but right now you will not know about these files we will talk about this so just let me open nlu.com yml so
you can see that we have some training examples like for example if I say hello or hi in the chatbot will respond for that or for example see you goodbye okay so these are built in and don't worry about this we will talk about this but right now let's just test our chat bot that it's working or not all right now you can see that the bot is loaded and okay so now if I say hello for example this is something in my grid intent and you can see Hi how are you now this is
the respond from the chatbot so for example we can just say uh let me just say are you a bot so are you bought okay so this is something that will be in our bot challenge so are you a bot so you can see that I'm about powered by a result and for example if I say I'm sad so I'm sad so you can see that here is something that cheer up there's a link you can just check this link did that help you so you can see that this is a basic chatbot that's created
in Russell don't worry about these files and training examples we'll talk about these in the later videos when you create a new result project using the rasanet no prompt comment it generates a default project structure with several files and folders now let's go through them one by one so now if you see this is my simple Russ Hall project and at the top you can see that we have an actions folder now this folder contains the custom actions for your chatbot it includes an action dot Pi actions.pi file where you can Define the logic and
behavior of your custom actions you can add more files for additional actions as your project grows so after that we have another folder that's called Data now this folder stores the training data for your chatbot it includes some main files now the first one is nlu.yml so now this is the important file and if I just go at the top so now this nlu.yml this file contains the training examples for the nlu or we can say natural language understanding model so we will talk more about these files but right now take a note that nlu
this file contains the training examples for the natural language understanding model so now you can see that uh now up at the top you can see that we have version so version 3.1 after that we have nlu and in here we have intent grid now in the rasa an intent represents the and intention or meaning behind a user message it's a way to categorize and label the different types of user inputs or requests that your chatbot needs to understand and respond uh to appropriately now within the nlu.yml file you Define intense uh by providing training
examples like this that represents different variations of user message for each and then now these training examples should cover the range of ways up user may Express a particular and then for example let's say you're building a chatbot for a Pisa argument service you may have an intent called order pizza which represents the user's intention to place an order now in your nlu.yml file you would Define this intent along with several training examples now right now if you see in here we have different training examples for example we have intentic read we have the examples
like hey hello hi now this is the for example the words that the user will ask from the chatbot so for example if a user say hello then the chatbot will respond something okay so for example if I say hello so it will call this intent grid okay because this is our uh training example in our nlu.yml and you can see that we're receiving hey how are you okay now what's this response comes from now there is something that's called domain.yml so let me just open right now we haven't talked about that so and the
domain.yml you can see that we have something that's called user grid okay so it means that when a user says hey hello hi or for example good evening good morning uh or for example good afternoon then the this user grid will be called okay so now for example if I say good morning now let me just copy this if I say good morning and you can see that we're receiving how are you if I say good afternoon okay good afternoon so we have the same response okay so because this intent is our great intent and
we have some training examples like hello hi and when a user for example asks from the bot or tell for the bot that hello then it will give this response okay so if I come down you can see we have goodbye and for example this goodbye is related to fic we have uter goodbye so for example every if we say these keywords like goodbye or buy so for example good or buy then we will see buy okay so for example if I say have a nice day have a nice day then it will say goodbye
or bye okay and you can see that we have intent affirm and we have deny so these are some pre-built or predefined training examples you can change this okay so there's no problem you can change these intents you can add your own intent or even you can change these response okay so we will talk about this but right now uh now we need to focus on the files that we have in here so for example we have goodbye we have a firm we have deny we have mood grid okay so if I say for example
uh great or amazing then it will say a great carrier okay if I say my domain.yml if I see so in here you can see that we have something like uh this one user happy okay or for example if I say are you a bot so if I come down we have a bot challenge if I say are you a bot then up it will say that I'm a bot powered by rasa okay so if you see my domain.yml and the domain.yml we have uh so uh yeah uterine about so it's telling that I'm about
powered by Russell okay so now this was the of the nlu.yml and also domain.while we will talk about this more so after that so we have something that's called rules.ymen okay so let me just open this now the uh rules.yml this file includes a rule-based conversation uh so rules define specific conditions and actions to be executed when those conditions are meet you can use either the for example the wipe.winel and here we are using.yml and if you see in here at the top we have version so version 3.1 and we have the rules so when
you're creating the rule so first you should have the version after that the rules inside the rules you can Define the rule Okay so now you can see that uh the Brule is created using the rule key now the steps field you can see we have a steps in here the steps field specifies the sequence of steps to be followed in this case the rule states that if the user sends up a message with the intent goodbye so with the intent goodbye in this case the rule estate in this case the action uter goodbye should
be executed okay so for example if the users say buy or goodbye then the user goodbye will be executed now if you see the action so this is the intent and the nlu.yml we have that intent uh uh so this is the intent goodbye and for example if the users say goodbye or for example buy or some training examples that are inside the goodbye intent then the user goodbye action will be triggered so this is the uter goodbye if I show you so it will say bye okay and also the same we have another rule
so for example if anyone say that I am a bot okay so this is the rule and there are seven steps okay so we have n10 so the intent is bought challenge now if you see the nlu.yml for the bot challenge so if the user for example says are you a bot are you a human am I uh talking to a boat am I talking to a human then the rule what rule will be what action will be so that the future I am about okay so if you come down so this is that I'm
about powered by Russia don't worry you will know about these Concepts more practically when you have created more projects uh right now we are going to just give some description about this so you can add more rules to the rules.while file to cover different conversational scenarios and Define up how your chatbot should respond in each cases now the rules.yml file is important but not much important okay so uh another thing that is more important alongside with the nlu.ymail and domain.ymel that is stories okay so this is the important file now this tourist.yml file in your
default project contains a three examples that represents different conversational parts or scenarios between the user and the chatbot these stories are used to train the dialogue management model and result okay so right now you can see that in the stories.yml we have some stories okay so we have the version at the top after that we need to write the story okay so the first one is the story path and what will be the steps now it's like rules if you see rules and also storage.yml but we will use stories a lot okay we will talk
about the difference between the rules and storage that weible and the later part but right now you can see that in here we have the steps okay so for example we have intent to create it means that when the user asks from the bot or say to the bot for example hello hi or and if you see an nlu.yml or for example hello there then what will be happened okay so this is the place that stories.yml will configure okay so stories that what stories.yml tells the chat bot for example when the user says hello hi
then an action will be triggered that's called util crit action now the user grid action is defined in domain.ymel okay so what will be that that will be hey how are you so this is the case for example and here if I am saying uh let me just use another one like for example hey dude okay so for example if I say hey dude okay so let me just swap it so this is the intent grid means that we are let's head UT is related to the grid if I hit enter in here now in
here you can see the action uter grid will be triggered and the user grid is that hey how are you okay also we have intent mode grid okay so this is another one so if I open the nlu.yml if I come down we have something that's smooth crit okay so for example if I say perfect okay so perfect then what will be happen the user happy action will be triggered okay so now let's check the user happy and that is uh let me just come down user happy grid cardion okay and also if you see
we have another you can just Define uh more stories so for example we have another three this is set part one okay so for example the user will say hello okay so this is another story after that the uter grid will be triggered that is hey how are you and after that we want to say that for example mood unhappy so if you see nlu.yml we have for them more unhappy we have something like I'm set okay I am set now when we are saying that I'm sad then this more unhappy intent will be triggered
and this will be the response okay so if you've seen source.yml and the mode unhappy if user says for example I am a unhappy or I'm sad or for example my day was horrible I'm disappointed then this uter tier app will be triggered and this is the place in the domain.yml we have so this is the text here is something to cheer up and we have an image in here and also uh so like this we have user that that help or affirm now this is the same okay so we'll talk more about the stories.yml
but this was the basic of of the stories that yml now uh we can say that these stories uh so for example that we have in here or we can create so serve as training example for results dialog management model so it's a dialogue management and it helps to learn how to respond appropriately based on different user inputs and context okay so this is the important point in here so we will talk about this more after that so we have something that's called models now this is the trained model that we have up this folder
stores the trade models of your chat bot after training Russell will save the trade model including nlu and dialogue management models in this folder okay so it is a this is the folder okay our model so we have another folder that's called test folders so this is the folder uh now this folder is used for testing your chatbot it includes a test so teststories.yml that you can use that okay so it's just for testing we will not use this match and uh so this was the test folder after that we have a config.yml okay so
this is the contact.ymet now this file contains the configuration setting for your result project it specifies the pipeline for nlu the policies for dialog management and other training settings okay so we'll talk about this more but right now we're going to just close this we have the credentials.yml this file is used to configure the credentials for external service or apis that your chatbot may need to interact with such as databases apis or channels like for example a slack or for example you want to integer integrate your chatbot with Facebook Messenger or for example WhatsApp then
you can define those inside this credentials.yml and this was the domain.yml we already have talked about this this is also an important file this file defines the domain of your chatbot it includes the intents so if you see at the top so these are the intents the registered intents that we have so if you see that in the nlu.yml when you create an intent and here you need to register that intent in this section so create code wireframe so these are the intents that we already have so in the nlu.yml when you create another one
in here then you need to just register that in here okay also we have entities actions inside this domain templates for responses slots and other configuration settings you define the structure of the conversation in this file we will talk about this more but uh right now this is the intense and these are the responses that we have for intent so these are the responses that we already have saw and we will talk about this more okay and the last one is the endpoints.yml so this file defines the endpoints for your chatbot including the webhock URL
so for the custom actions and any external services that your chatbot needs to connect to so we will talk about these files more but right now we have just a basic overview on our on our Brasa project and this section we will talk more about the structure project structure of the Russell so and also we're going to create our project using rasa init so now let's first create our hello world project so now in here I'm going to create another directory let me just call it second project or whatever you want and let's change directory
to the second project now if you remember that we have used rasa init prompt for the project and that's that we're going to use resign it and we already talked about the difference between their assign it and also Russell and it prompt so I can just see result in it so now using this it will asks me for some for example the first one is please enter a path where the project will be created so we want to create that in the default directory let me hit enter and after that it's telling me that do
you want to train an initial model so we don't want to train an initial model for right now and we can just say no okay so now the project is created and it's telling that no problem you can also train a model later by going to the project directory and running Russell train okay so right now we are we don't have any training model and if you see so so in the second project you can see we have the same uh folders but right now we don't have any models folder in here because we have
not trained the model so we have the same actions.pi file we have our data we have our test and these are the files okay so we are going to just open our nlu.yml so we already have talked about the aw.yml let me just uh briefly mention that it's a yml file used in the result to Define training data for the nlu also it contains examples of user messages labeled with their correspondent intents and entities so right now you can see that we have we have the version now we are going to remove uh for example
uh we can just remove uh so as I've already mentioned that you can bring changes to this so you can change the name so for example we want to leave the intent grid and the intend goodbye so you can just for example add some uh training data in here and we're going to remove this firm and also we're going to remove this deny and also for example mode grid so okay so I'm going to remove these files because I will show you that even we are going to just remove this unhappy on even board challenge
okay so right now what we have we have the intent grid we have the good one so now we want to create another intent in here okay so I can just say uh intent and I need to give the name of the intent for example I can just enter tank s okay and or I can just make it like this tank okay so now we need to give the examples in here so examples and in the examples now we need to give our examples so now in here we need to give the training examples like
for example tanks and for example thank you and for example I appreciate it or like this okay so now we have our training examples after that we can just come to the domain.wival and that's because because we have removed a lot of intents and we already have mentioned that the domain.win file in resize an important configuration file that defines the the domain of your chatbot it provides a high level overview of the chatbots capabilities including the intense entities actions responses and other configuration settings okay so we have the version and you need to specify the
intents but we have the intent grid goodbye we have removed these affirm deny mode or mode unhappy okay so if you've seen here we have just grid we have goodbye and we have tank so this is the new one that we have created so what you want to do we want to just remove this and we want to just add the newest one that we have created like this okay and also for the responses we have the response grid but we don't we don't need this response because we have removed that we're going to remove
this response the happy response and for the goodbye we have that and also for the IMO bot and also we're going to move this okay like this uh so now in here you can see that we have something that's called session config okay and then there we have session expiration time and also carry over slots to new session so now what are these so let's talk about the first one now the this parameter determines the duration of a session in seconds and give an example it sets to 30 seconds UH 60 seconds which means that
if there is no user activity within the 60 seconds the session will expire and the chatbot will start a new session when the user interacts again and also we have carry our slots to new session now this parameter determines whether the slot values from the previous session should be carried over to a new session or not F set to true the slot values will be retained when a new session begins an example it is set to True indicating that the slot values will be carried over to new sessions so right now we haven't learned about
the slot we will talk about that okay so now we have our nlu.yml we have uh brought some changes and also we have our domain.win okay so there's no problem but right now we need another thing that's called the source.ymet we already have talked about the stories.yml that the stories.yml file in Russia is used to define the conversational flow of your project it's an important file because it represents example conversations or dialogue between the user and the chatbot by specifying a sequence of user inputs or intents and the corresponding both actions okay so now the
main purpose of the source.yml file resides to define the conversion conversational flow so now what we need to do in here uh so we need to Define this tools so by defining these stories you provide examples of how users May interact with the chatbot and expected responses from the chatbot this helps result dialogue management model learn and generalize from the provided training data to handle similar user inputs and generate appropriate responses so right now you can see we have version we have stories in the step now if you see up we have the grid there
is no problem so if you see we have the intent grid if I users say hello then there will be something like uter grid this will be the action and then the user grid we have hey how are you okay but we don't have the mood Grid or mood unhappy I'm more happy because we have removed those so we can just remove this okay and we don't need that so and here so we can just remove this one so we don't need that uh like this even uh we can just remove this also okay you
can Define the goodbye uh story in here as I've already mentioned we have something that's rules.yml but the goodbyes are defined in here there is no problem we uh we are going to leave it like this okay but we need to remove this board challenge because we don't have that rule okay we have just specified the one rule like this you can bring this for example this intent in here there is no problem but right now that's in here we can just leave it let me just bring that in here we are going to remove
the rules.yml you can just remove it or you can just leave it in here there is no problem okay so now the important file is the storage.ymnl so now we have if the user say create then there will be a uter credit okay so now let's create another story we want to create another student here so we can just say story and I can just say Express for example thanks and let's define the steps and in the steps so we can just Define the intent so intent so for example a user for example say tank
okay so for example the user will say uh like this uh thanks thank you appreciate it many thanks now what will be the action so we need to create a response for this now we need to create a response and the domain.wheimer so we can just open this we want to create a response in here so for example you can just say we can give the text for example uh you can just give it whatever you want for example I can just say you are welcome it was my uh pleasure to assist you okay so
we can just give it like this now uh now okay so now for example if a user says tank what we want to do we want to just say this one so you're welcome it was my pleasure to assist you so we can just add that in here so you can just say action like this so you can just make it like this let me remove this okay so now this is the stories.yml that we have in here now what we need to do we need to just train our model right now we don't have
any model so and here I can just say it as cell 3. so let's wait so now you can see that we have an error okay so on the training model now we can just go back that check that where is the problem okay so let's just go back and we will see because we have removed some okay so you can see that it is not in the list okay so now if I just go to the domain.yml so you can see that's thanks okay so what we have another thing inside this okay so it's
like this so let's just copy this and paste it in here or we can change this to uh like this one thanks okay and Also let's just change this to this thanks and the stories.yml we can just make it this okay so now we can just train our model again Russell train so you can see no story structure conflicts found so again you can see that we have an error and if we just go back so we want to track the error okay so it's telling that tank is not in the list again okay so
now we you can check this so we have the storage.yml we have the nlu so like this and then the domain.yml we have uter tanks and this is the tanks uh but why we are seeing this uh Okay so there there's an indentation problem okay so make sure that there shouldn't be any indentation problem okay so now I think we are done so let's just run it again 3 in the model again now it's good when you receive an error you can just check that and you will see that what is the problem okay again
we have the problem tank as not okay that's problem okay the intent tank is used in your stories but it is not listed in the domain file you should add it to your domain file so stories.yml okay so this is the intent tanks okay so this is the intent tanks and now we can just train it again okay so we have created the aw.while that's thanks now this was the problem it was first tank I forgot I have changed to tanks so we have some examples after that you need to Define that in the domain
dot ymail in the intense section and after that we need to create response like you're welcome and in the stories.yml for example this hour intent and this is our action okay thank you so let's finish the training component and now you can see your saw model is trained and that's saved in here okay so if you see in here now we have our models and this is the trained model okay so now let's just check that this is working or not so I can just hit us on shell so these are some warnings there is
no problem so it's not related it's related to us so there's no problem uh it's duplication warning so now the bot is loaded and now let's just say hello so now for example if I say hello and if you see my stories.yml if I say hello then there will be you to create okay so that you will create what we have that is hey how are you okay so you can see hey how are you now for example if I say uh tanks okay so if I say tanks then there will be user tanks so
if I say thanks and if you see the domain.yml and in the domain.yml we have this so you are welcome it was my pleasure to assist you and if I say buy okay so we have a buy intent in here a good buy intent and we have that's defined in the rules.yml uh and here there's no problem you can Define it in the storage.yml or rules.yml so it is up the rules as for the rule based okay and we will talk about this rules more and right now you can see that that's working and if
I say buy so in the nlu.yml so for example we have see you later if I write it like this see you later then it's we'll say buy because and here we have buy and also in the rules.yml if we say for example uh something from the good boy intent then there will be user goodbye and uter goodbye is this is the text why now let's talk about the rules.yml file now we already have talked about this but now let's talk about this concept in depth so now in the rest of the rules dot yml
file is used to define conversational rules and control the flow of the conversation based on specific conditions now rules provide a way to handle dialogue management by mapping user inputs to specific actions or responses now the rules.yml file and resize not always necessary for every chatbot project its proposes to provide a more explicit way to control the conversation flow based on specific conditions or events now there are some benefits of rules.yml so the first one is explicit control over conversation flow now with rules you can define specific conditions or intents that should trigger certain actions
or responses this allows you to have more fine-grained control over the dialog management of your chatbot another one is fallback and clarification handling rules can be used to handle fallback scenarios when the user input doesn't match any defined intents you can define a rule to capture such cases and provide an appropriate response or take necessary reactions to handle the situation another one is overriding default Behavior now by using rules you can override the default behavior of resource conversation flow for example you can enforce a specific action to be triggered for a particular intent a even
if results default policies suggests a different action and the last one is simplifying complex dialog management now rules can be useful when you have complex conversation flows that involve multiple intents slots or contexts they provide a structured way to handle such complexity and ensure the desired behavior of the chatbot now if you remember that we already have talked that we have another file that's called the stories.yml and it's the same like rules.yml now let's talk about the difference between the rules.yml and also storage.yml rules.yml and storage.yml is used to define the conversational flow and behavior
of the chatbot but they have some difference in their structure and proposes now first let's talk about the storage that yml even though we will talk in more in depth in the later videos but the storys.yml is primarily used for defining example conversations or user interaction scenarios it captures the difference the different paths that a conversation can take including user inputs or we can say intense and Bot responses or actions and then in a series that yml conversations are structured as a sequence of steps we already have saw this now where each step represents a
user intent or a bot action stories can have multiple steps and can include different actions and intents in a specific order on the other hand rules.yml is used to Define explicit rules or conditions that should be followed by the chatbot to handle specific user inputs or trigger certain actions rules provide a way to define a specific control flows and Logic for the chatbots behavior in rules.yml each rule consists of conditions and actions the conditions can be based on user intents entities or slots and actions define what the bot should do in response to the Matched
conditions now let's talk that which one is important now both faults are important for building a will functioning chatbot but they serve different purposes we already have talked that stories.win is typically used for training the dialogue management model and capturing example conversations and it allows the model to learn from the data and generalize Its Behavior it helps in model and modeling the natural flow of conversations and handling different scenarios on the other hand rules.while is useful for defining explicit conditions and actions that should be followed by the chatbot it provides more control over the chatbots
behavior and can be helpful in implementing a specific business rules or handling certain age cases now the importance of each file depends on the specific requirements of your chatbot and general storage.yml is more commonly used as it captures the natural conversation flow while rules.yml allows for more explicit control and customization it's recommended to use a combination of both files to the file the behavior of your chat bot effectively so now you can see that this is the rules.yml we already have talked practically about this and we have our rules.yml and you can see that we
have just one rule so when you're defining rules you can just Define the version after that the rules and inside that you can just just Define your rule for example you will have multiple rule you can just create those rules in here so for example in here why we have one rule say goodbye anytime when the user says goodbye and this is the steps when the user says for for example the goodbye now there are some training examples in our goodbye intent and if I check my aw.yml so in the grid intent I was in
the goodbye not create so now you can see that CEO goodbye see you later good night bye if the user says this or asks these keywords from the chatbot then the user goodbye will be triggered okay so this is the action and if we see the domain.yml and the user goodbye we have the buy okay so like this you can just Define your rules and by the rules dot ymail file and that's lesson we want to talk about nlio.yml file and also about entities so now the energy that ymail we already have talked briefly about
this so it's a part of your result Project's data directory and stands for natural language understanding it's used to define the training data for the nlu model which is responsible for understanding user inputs and extracting relevant information now how does it work uh the new.yml file consists of intense examples entities synonyms and rejects patterns intense represents the user's intentional purpose behind their message while examples provide training data to teach the nlu model how to recognize and classify different intents now what are entities so entities represents a specific piece of information within user inputs such as
dates locations or product names or we can say entities represent important information that the chat bot needs to extract to understand the user's request accurately for example we have an example in here in a restaurant chat bot entities might include location for example date a number of people when a user makes a reservation request uh now for example uh in the user message and here we have a book a table for two people at an Italian restaurant and maybe on Friday would recognize the intents as uh for restaurant reservation and extract the following entities we
have for example a number of people uh two uh because in Italian location New York and date Friday so now watch entity extraction and how we can do that so entity extraction enables the chatbot together important details from the user's request which can then be used to generate appropriate response says or trigger actions such as making a reservation providing relevant information or crying out any other tasks to enable entity extraction in rasava you need to Define entity labels in your training data you can annotate the entities in user message using resource markdown format or Json
format and provide examples for each entity type to train the nlu model effectively so for example in here we have I want to order a pizza and if you see we have food entity now the food is entered in here and we are annotating that with the pizza okay so for example can I get a pizza food in here again food is entity and we are annotating with the piece of food now what are synonyms uh so in rasa synonyms are used to improve the natural language understanding or in lieu of the chatbot by allowing
it to recognize different variations of the same entity value synonyms are relevant we can say alternative words to or phrases that have the same meaning as the main entity value but are written differently for example consider a chatbot for a wider application one of the entities it needs to extract a city so it can determine the location for which the user wants to know the weather however up users May refer to the same city using different names or for example abbreviations to handle such variations you can Define synonyms for the entity Value City so for
example in here we have what is the reader in New York city so in here we have the city this is our entity and the New York we have we are annotating with the new year and for example another user may ask that tell me the forecast for NYC City so abbreviation of the New Year okay so this is the place that we can add synonyms so now we can say that by defining synonyms and the training data at the racino you model learns to recognize these Alternatives phrases as synonyms with the main entity value
this improves the chatbot's ability to correctly extract entities from user messages even if they use different ways to express the same information now another thing is regex pattern that we can use the in our nlu.yml file and and Russell regex patterns or we can say a regular expression patterns are used as a powerful tool for defining rules that can match and extract entities from user input based on specific patterns of defined using regular regular Expressions so regular expressions are a sequence of characters that Define a search pattern and helping to identify specific text patterns and
user messages parasol uses a projects pattern as a part of its natural language understanding or nlu pipeline to extract entities that may not be easily captured using the machine learning based approach along rejects pattern patterns can be particularly useful when dealing with fixed format entities or when you want to extract entities based on the specific patterns or constraints so for example in here we have a you can just Define it like this in your in in inside the nlu.yml so for example regex we can give a name for example zip code and then we can
give the training example so now you can see that in the above above example the rejects pattern 0 9 and 5 match any sequence of five digits which represents a standard U.S zip code by defining this pattern Rosa can identify and extract zip codes from user messages that match this specific pattern now let's talk about the main purpose of nlu.ymet so the main purpose of the nlu.com file is to Define and provide training data to the nlu model it helps the model understand the user's intent and extract relevant information accurately by providing different examples entities
synonyms and regex patterns you can train the model to handle a wide range of user inputs and improve its accuracy and performance now let's talk about the structure of the nlu.ymail we already have talked about this so now the nlu.yml file follows up y or yaml syntax structure it starts with the version field which specifies specifies the version of the rasa nlia format being used for example uh and our case it's 3.1 and the main content of the file is organized enter into a list of intents each containing the intent name and also a block
of examples examples are represented as a list of phrases that represents user inputs corresponding to a specific intent entity intent and entities can be also added to examples using markup like for example we can give the entity name and also entity values we already have saw an example and also synonyms are defined using the synonym keyword followed by a list of Alternatives variations for the same concept and the same for the regex patterns or also defined using the regex keyword followed by the definition of that so this was the nlu.yml so now let me talk
about some additional tips so it's important to provide a lot of training examples so for example when you are adding an intent it is very important to provide a lot of training examples that cover different variations variations context and potential user inputs for each intent entities should be annotated within the training examples we already have talked using their for example entity name and also entity value format to help the nlu model to recognize and extract the relevant information and also regular Explorations in projects patterns can be used to match a specific pattern and user inputs
such as phone numbers email addresses or any other consistent format now we can see that the quality and quantity of the training data in the nlu.yml file uh greatly and follow against the performance and accuracy of the new model therefore it's important to always trade and improve the training data based on real user interactions by properly defining and structuring your nlu.yml file you can train your nlu model to understand the user input securely extract entities and provide appropriate responses or actions in your result chatbot so now in here you can see that we have our
simple chat bot now you can find a new.yml inside the data folder so this is our analyu.yml for example we are going to create another intent so let me just say intent and this should be for example order Pisa so order pizza and after that we need to provide the training examples Okay so now a user may be asked that I want to order a pizza so like this and the entity is food for example or for example can I get a Pizza and the entity is food and for example I can just say uh
I'd like I'd like to have a Pizza and then did you use food and for example let's let's order uh Pizza and food and we can say for example how about how about a pizza and also food okay so like this you can just Define you can just give the intent name like for example order pizza and you need to define the examples okay so right now we are not going to train our model so for example after adding the uh some new training examples you need to train your model but right now we are
not going to do this because we will talk about some more files like stories and domain.yml and after that we'll train our model in this video we're going to talk about the domain.win so the domain.yml file and resize an important configuration file that defines the domain of your chat log it provides a high level overview of the chatbots capabilities including the intents entities actions responses and and some other configuration settings now these are some key components now the first one is intense it defines the different intents that your chatbot can understand intense represents the user's
intentional goals such as greeting asking for help or making a reservation we already have talked about the intents we have entities that we can Define inside the domain.yml at specifies the entities that your chatbot can extract from user input into this represent a specific piece of information that are relevant to the conversation such as for example dates locations of names also you need you can Define responses inside the domain.yml so responses contains the predefined responses that your chatbot can use during the conversation these responses can be associated with specific actions and can include text buttons
images or any other content you want the chatbot to display also we have actions uh it specifies the actions that the chatbot can take in response to user input actions to user input so actions for example can be sending a response making an API call running custom code or activating an external system also we have a slot so uh you can use a slot for defining of the slots and it stores the information and maintain the conversation State slots can hold values that are collected from user input or generated during the conversation they allow the
chat bot to remember information across different turns of the dialog so you can see that the slots are the memory of the chatbot we have forms it represents forms that guide the chatbot to collect specific information from the user forms help in gathering structured data by asking a series of questions and validating the user's message so don't worry we will practically do talk about these Concepts but right now you should know about these Concepts so and the last one is templates uh templates provides a reusable response templates that can be used in different parts of
the dialog templates make it easier to manage and reuse common responses throughout the conversation so we can see that we can say that the domain dot Wyman file serves as a central place to define the behavior and capabilities of your chatbot it's important to keep this file up to date with your chatbots domain to ensure accurate understanding and appropriate responses during the conversation so right now you can see that we have this is our domain.yml file and we already have talk that we have intents inside the domain.yml we have responses we have some configuration settings
uh right now we haven't added for example entities or any actions like this we will add those uh so right now for example if you see in our nlu.yml in the previous video we have created an intent at them of order pizza so for example if a user says for the chat bot that I want to order pizza or can I get a pizza we need to give a response for that so to do this we want to create a static response inside our domain.ymp okay so you can see that we have some responses uh
if the users say for example like uh hello or like like these conversations then for example this hey how are you will be triggered okay so also we have uterine tanks that we already have created now we want to create another one that is for the ordering pizza okay uh so uh we can just do that up in here so in this section and I can just say uter and for example you can just call it whatever you want you can just call it order for example okay or we can say order pizza and then
here we need to give the text so so let's just give the text for example uh sure so for example I will order visa for you or like this okay so you can just give it whatever you want or we can say for example sure uh for example what kind of pizza you want the right kind of Visa you want okay so now you can see that we have defined a response so for example if the user says uh I want to order a pizza or let's order pizza then this will be the response okay
so also uh it's important to when you create when you're creating new intents you need to add those intents inside the intent and the intense section okay so we have great goodbye thanks and also we need to add the order pizza in here okay so right now uh let's just train the data and let's check that what will happen okay so here I can just say it as a train so we need to train our model and let's just wait so let's wait and uh there will be a warning by this reason I want to
show you that warning so let's wait so now the first warning is this that uter order pizza is not used in any history or rule so there's no problem because we haven't created any rule or any story okay so because we haven't talked about that so now you can see the training model has been finished and there is no problem we have the training okay but now uh we have something that I want to just tell you okay so now up in here uh so this was the first one that the order pizza is not
used in history and rule or for example later order pizza is not used any in any story or rule okay so now what we want so right now we are not going to just talk about the stories.yml uh but also what we need to do if you see in our nlu.yml we have I want to order a pizza but also we have the entity so food entity now when you're creating an entity you need to Define that entity inside the domain.while okay so now in here we have an intense and the section we can just
say entities and then the entities we need to give the name of the entity okay so that is food okay so that is food and after that now we want to just train our model again so Russell train so let's wait okay so now again the model is trained and now let's just open the results show we want to check that our chatbots working or not so I can just see it as a shell because I want to check that for example if I say I want to order a pizza we have this response so
sure what kind of pizza you want or not okay so let's just wait okay so now the board is loaded so if I say hello now we have hello in here so for example you can see that hey how are you and we have our grid intent and if we check our storage.yml we have for example uh intent grid if a user say hello then there will be user grid that in the domain.yml we have this one hey how are you okay so but now if I say for example our new the sentence I want
to order a pizza so I want to order a Pizza so you can see that we are not receiving any response and it's telling us hey how are you and that's because because we have the training examples and we need to specify our stories.myman we need to create a story for that and then in the next video we will talk about that so now let's talk about the stories that yml5 now the stores that we will find under assault is used to define the conversational flow of your chatbot it represents example conversations or dialogues between
the user and the chatbot by specifying a sequences of user inputs or intents and the corresponding both actions now let's talk about the key components of stories.yml so the first one is the stories a story represents a single conversation or dialog flow it consists of a sequence of steps where each step defines an interaction between the user and the chatbot steps can include user intents both actions or bought uterances another one is user intents so user intents represent the user's intention or goals at each step of the conversation these are defined based on the expected
user input such as greeting asking a question or providing feedback another one is both actions so both actions represent the actions taken by the chat bot and response to user input I actions can include sending a response making an API call running custom code or activating external systems and the last one is about uterances so both uterine says Define the chatbots responses to user inputs these are predefined responses specified in the domain.yml file that the chatbot can use to generate a response during the conversation so we can say that the stories.yml file helps you to
find the different paths or flow that your chatbot can follow based on the user's input and the chatbots action by creating different stories you can cover different use cases and scenarios to train your chatbot to respond appropriately in a real conversation it's important to note that the stories defined in the stories.yml file serve as training data for the dialog management model rasa uses this data to learn and predict the next best action or response based on the conversational story overall we can say the storage.yml file plays an important role in training your chatbots dialog model
and shaping the conversational behavior of your chatbot now let's check it practically so right now you can see that this is our chatbot if I say I want to order pizza then it's not working even though we have the training data like I want to order a pizza or can I get a pizza also in the domain.yml we have some responses like for example sure what kind of Visa you want but right now it's not working because we need to specify the story so if I open a storage.yml you can see that we have some
stories for for example for the grid for the express tanks now in here we want to create another one for the order pizza so I can just say story uh you can just write uh write it like this and I can just say order my pizza for example okay and after doing that we need to specify the steps okay so what steps now for example we need to give the intent and I can just say intent so content and for example if a user says the phrases from this order pizza so I can just paste
it in here so order pizza then what will be the action the action the bolt action will be this one so user order pizza okay so now in here we can just add the action so it should be in here and in here I can just say the action and the action should be this one order piece okay so now we have this so make sure that you have the correct indentation like this now after doing that we want to just train our model and let me just train that so you can just see a
result train and now let's just wait for the training no okay so we have an error because it's not actions it's action so it should be action now let's do it again Russell train so now you can see that the model is trained now we can just say result shell we want to just open the shell and interact with our chatbot okay so now the bot is loaded and now if I say hello for example right now uh it will for example trigger the this user grid and now if I say for example I want
to order a pizza so I want to order a Visa and now so you can see sure what kind of pizza you want okay so now this is the domain dot ymail we have the response from there so sure what kind of Visa you want you can change it whatever you want but now you can see that our chatbot is working and if I say bye and it will say me that bye and that's also I want to learn about the entity extraction so entity extraction and Russia is an important aspect of natural language understanding
or nlu within the result framework it's the process of identifying and extracting specific pieces of information or entities from user messages during a conversation with a chatbot or virtual assistant so we already have mentioned that entities represent important information that the chatbot needs to extract to understand the user's request accurately rasa uses a two-step process for entity extraction so the first one is intentional combination now the first step is intent recognition where Russ auditor mines the primary intention or purpose behind the user's message now this is achieved using the nlu component of rasa which Maps
user input to predefined intents and another one is entity extraction so one is the intent is recognized result then focuses on entity extraction it identifies and extracts the specific pieces of information from the user's match message that are relevant to the recognized intent now rasa uses machine learning models like for example CRF or Diet to perform entity extraction and this makes it capable of handling complex entity recognition tasks now we already have saw an example so for example and the user message like book a table for two people at an Italian restaurant in New York
on Friday rasa would recognize the intent as for example restaurant reservation and extract uh different entities like for example a number of people location and also date so uh so now we can say that the entity extraction enables the chatbot to gather important details from the user's request which can then be used to generate appropriate responses or trigger actions such as making a reservation providing relevant information or carrying out any other tasks so now this is our simple chatbot that we already have created now to enable entity extraction in rasa you need to Define entity
labels in your training data so we already have done this so you can see that we have the labels in our training data and you can annotate the entities and user in user messages using their assault markdown format or Json format and provide examples for each entity type to Trend in a new model so you can see that we already have done this process we have the food entity and we have annotated with the VISA pulse in the domain.yml we have added our entities okay so now we want to extract the food entity to extract
the food entity from user input and Russell we can utilize the result entity extraction capabilities so first of all now right now we have saw a lot of files in here I think all files uh but we haven't saw the actions.pi file for right now okay so let's just open the actions.wifi so and here you can see that let's just remove these comments from here I can use to move that and let me just uncomment this okay so now uh the actions.pi file so that we have in here it's a python file used in the
result projects to Define custom actions actions in Russia are used to implement logic and perform actions based on user inputs intents and entities now the actions.pi file typically contains a class that extends the action class so you can see that we have it's a class that extends from the uh from the action class from the raw size Dickey also this class represents a custom action that can be executed by the research chatbot now inside actions. inside this actions.by file you define a custom actions by implementing the necessary methods and there are two methods so the
first one is the name uh so this method Returns the name of the custom action the name should be unique and match the name used in the domain.ymer so in here for example it's returning the action hello world uh action hello world okay so we will change this but right now it's this method Returns the name of the custom action so for example this will be uh action hello world and also we have run now this method contains the logic for the custom action it takes uh and parameters like dispatcher tracker and domain to access
and manipulate the conversation flow extract entities send responses and perform other tasks okay so now what we need to do the first thing is that we are going to change this name so for example we can change you can remove this so for example uh we can just change this name first it should be for example extraction or extract food entity and this should be for example action underscore extract food entity okay so this is the name of the custom action that we want to give now in here so we are going to just remove
this so let me just remove this so we need to run and here what we want to do we want to just uh first we need to just extract the food entity okay so in here I can just say food entity and we can just use next in here so next and in the next uh so this should be here or in this section there's no problem okay so now in the next we want to get the entity value okay so we can just use the tracker and we can just hit dot get latest entity
values and that is so the first parameter is food and also uh for the this we can leave it now okay so it needs to parameter the food and also none okay so this is optional so now we have the food entity after that we want to check that if we have the food entity so if we have the food entity then what we want to do we want to just dispatch a message okay so you can just set this patch user message and we can give a text in here so for example I can
just say you have selected and we can just give the food entity in here so food entity as your food Choice okay so as your food choice for example and in the office case we can just say so dispatcher dot user message and we can give the text for example I'm sorry I could not so I could not detect the food Choice okay and then what we want to do we want to just return okay so we can just say return something or we can just return in between less than here so now we are
done with this and we have this so after doing that what we need to do we need to just add our this action inside the domain.winel okay so now in domain.ymil we alongside with the entities responses and here we want to create our we can just say actions and we need to specify the action okay and the action is so this action okay we can add it in here and also we need to include the custom action in our stores.win okay so now we don't need to use this static response so in the domain.yml so
this one and instead of that we want to just use this action extract food entity and in the source.yml for example if a user says order piso okay instead of this order pizza that we have the static one we can use our this extract food entity so let's just paste that in here okay so also for example when you're using custom actions we need to enable something in the config.yml okay so not config.final but and uh okay uh yeah in the credentials so right now we haven't learned about the config.win so we need to just
enable uh so let me just check it okay not a credential sorry and the endpoints.yml we need to enable the action endpoint okay so when you're using the custom actions then you need to enable this okay so now uh I think we are done let's just train our model so and here I can just say Russell train and then there is an error then we will see that error in here so now it's training the model let's wait okay so finish training component okay so you can see that your saw model is trained and that's
saved and now we need to just open resource shell so also because we are using custom action we need to also run that okay so in another terminal you can just say resolve run actions okay so now the action is running and now let's just wait for the shell okay so now let's just say for example hello okay so it's telling that hey how are you now if I just open nlu.yml so for example now if I say uh I want to order a pizza so let me just say I want to order uh Pizza
so you can see that you have selected Pizza as your food choice now this is the response that we are receiving from our actions okay so from here now this is not the static response that we have either earlier Piezo now we can just remove this and we don't need this okay because now we have uh the response in here okay so you have selected for example as your food Choice okay and uh you can see that it's working and we have implemented our actions.pi file like this so now let's add some more functionality to
our uh chatbot so this is our simple chatbot that we have implemented the action custom actions now we're going to open our nlu.yml and we are going to just Define some more uh and tension here so for example I can just create one for the order for example are there food for example I can just give it like this and we can just add examples in here so I want to order a food uh so can I get some food please and uh let's order some food okay and for example like this I can just
give it three trading data and also we want to create another intendent here so let me create another one and for example I can just say inform foot and form foot and for the example for example I can just add some examples like uh we can just say stick and the entity is food and let me just copy this and paste it so we have for example Burger and entities food for example we have a sushi we can add some training data like this okay and pasta okay so now we need to bring some changes
to our actions.pi file so let's just open that so we have extract food entity in here now we want to create another one so let me just create another class Google so I can just say class order food action and we can just extend from the action and then here we need to give the name and for the name we can just return the name of the action so that is action order food so order food and we can just copy this run from here and paste it in here okay so this is our run
and in here we want to just dispatch a message so dispatcher dot user message and we can just give the text so for example sure which kind of food uh what you like to order okay and we can just return we are going to create another class and I can just say confirm order action we can give the name so we can just return for example action underscore confirm uh underscore order okay and also we can just copy this in here so now we need to we can extract the food entity in here also so
for example we can just copy this uh or even we can just copy all of them and like this let's just paste it in here so we can extract that and Robin here we can just say for example uh I have ordered now I have ordered food entity for example for you and then the else case we can just say I am sorry I could not for example detect the food choice we can just leave it like this okay so now we have created some more actions custom actions now we need to bring some changes
to our stories.yml so we can just open this now we want to bring some changes to order my pizza so for example in here when the when we say for for example or when we ask from the chatbot that uh so order pizza so for example if we say for example I want to order a pizza or that's why we are going to use order food because we have created this in here and even we can remove this or uh okay so we don't need this intent we are going to just use this intent okay
and uh now in the storage.yml we can just give this so for example if we say I want to order a food or can I get some food or let's order some food now in that case what we want to do we want to just call the action order food okay so this action so this action okay so this what will be the message that's sure which kind of food you would like to order okay so we want to just call this and also we need to add this in the domain DOT oml first let
me just add that in here like this even though we don't need this one but we will leave it and also uh this one so let's just open the main.yml okay and also we have forgot to add these two intents in here so this is our intent and we have another one that's okay so we have the order pizza we have ordered food so other food and also and form food okay so now let's just create our storage dot yml okay so for example if we say I want to order food we want to just
uh call this action extract food entity that uh that will be like this so action order food sorry this should be order food and then here we have the sure which kind of food would you like to order okay and after that we will specify the food okay so and the nlu.yml we will say for example a steak or Burger okay so now we can just create another step in here or and that's a step we're going to create our intent and we need to call this intent and form food the user will say uh
their food and after that what action will be we want to call the action confirm order okay so for example we will say that I have ordered that food for you so action confirm order so let's just add the action and here okay so it's simple okay so we have created two intents so we are not using this one because uh this is annotated with the Pisa uh so I have ordered food and informed food okay so in the order food I have I want to order food and and then form food we have the
type of the foods like steak or burger or sushi or Salad okay and we have created two two new actions now the first one is the order food action and also confirm order action now for example uh in the source.wival we have like this story if the user says for example I want to order a food then what action will be triggered the custom action that will be triggered that is action order food the bot will say that sure which kind of food would you like to order after that the user will say for example
these foods like steak burger or salad and then what will be this action confirmed will be called okay so this will be the text I have ordered this food for you okay so this is our story.win uh now uh I think let's just train our model so Russell train so now the training has been completed finished training and you are so model is trained and saved in here so let's just so now let's just say Russell shell also we need to run our action so let's uh run actions let's just wait okay so now let's
just uh check our chatbot so for example I want to just say I want to so I want to order a food okay so you can see sure which kind of food would you like to order okay so there is a misspelling there is no problem so this is the response that we're we are receiving from the action order food okay sure which kind of food would you like and then the source.yml we have defined this so if we say I want to order a food then this action order food that the messages show which
kind of food would you like to order will be triggered so now we have the inform food okay so if you see for example we can say uh stick or for example Burger okay so let me just say Burger so now you can see I have ordered I have ordered burger for you okay and this is the uh message from the action confirm order okay and for example if I say again hello so and it's telling that hey how are you and for example I can just say can I get some food can I get
some food so sure which kind of food would you like to order so for example I can just say it's a lot like this and you can see I have ordered salad for you and this is working in this lesson we want to create our flask project and also we are going to create our resource chatbot so first of all what is flask now flask is a microwave framework for Python and it's designed to make it easy for building web applications and apis it's known for its Simplicity flexibility and minimalistic Design and it allows developers
to quickly create web applications without imposing too many restrictions or dependencies now there are some key features for the flask the first one is lightweight flask is a lightweight framework that does not impose a specific directory structure or require the use of particular libraries this flexibility allows developers to structure their projects as they see they see fit uh the second one is extensible so flask follows the pluggable architecture which means that developers can add functionality through flask extensions there are different extensions that you can use in flask for example we have for database integration for
rendering for authentication and many more uh the third one is routing so flask provides a simple way to define URL routes and Associate them with python functions called view functions these view functions handle incoming requests and return responses another one is templating so flask supports template engines like ginger 2 and it enables developers to create Dynamic HTML templates with placeholders for data that will be filled at runtime and built-in development servers so flask comes with a built-in development server and this makes it easy to test in the back applications during development another one is restful
support So flask is commonly used to build restful apis due to its Simplicity and flexibility it can handle HTTP methods like git post put and delete another one is secure so flask provides utilities to protect against common web application vulnerable vulnerabilities like CRF or csrf or we can say cross-site request foregri and also X SS or we can say cross-site scripting and the last one is minimal boilerplate so flask keeps boilerplate code to a minimum and it allows developers to focus on writing applications logic instead of setting up and configuring the framework so now let's
create a practical simple project with flask and also we will create our resource chatbot also so now I already have created a resolve flask directory and I'm going to just say assign it so first we want to just create our simple project okay and okay so we want to just create it in the current directory and we don't want to train any or we can just train our model because we are not going to add any functionality for this let's just train the model and it's training our initial model so let's wait so now the
model is trained also I have opened the resource shell so you can see this our basic project and it's just a simple project for example if we say hello and it will say uh hey how are you so if I say are you uh bought which will say that I'm about powered by yourself so we're not going to add any functionality but you can just add that now the main focus is on integrating resource chatbot with flash cookie now we already have talked about the flask the first things that we need to install flask so
you can use a pip and install flask and also we are going to just add a python file let me just collect app.pi file so now the flask is installed and now what we want to do uh so in here in the app.pi file so we can just say from flask we are going to import flask and also render template okay so render template and now let's create our app in here so I can just say app flask now we need to create our route in here so this should be index route and I can
just hit div index and in here we want to just return our template okay so render template and that should be index.html okay so right now we haven't created this template but we will create that okay so now let's just create our development server so if underscore name and in here we can just say app dot run and the the back to true so debug to true and also we can just give a port so for example port 3000. okay so now we have this after that what we want to do we want to create
a directory at the name of templates in our distress of flask project we need to create this index.html so inside that we want to click an HTML file called index okay so now let's write our index.html so this should be the title so I can just say Russell and flask chatbot and we are going to just copy some codes so now the first one is that this uh we need to use these Imports we're going to use bootstrap and also uh the jQuery okay so you need to just add that in here and after that
we will use this custom scissors but right now we need to create a class container in here so in this section I can just say div so to this class container so container foreign class container we want to just create our H1 tag so that is welcome to my chatbot it will be and after that we need to just add our button for the chatbot okay so let's just add this in here so this will be a button so the this is the button ID that is chat widget button and the type is button and
we have the class that is between between primary we're using a bootstrap class and that's rounded Circle and we want it should be uh position should be fixed and also it should be at the bottom and we need to just give 20 pixel and it should be 20 pixel to the right bottom 20 pixel and write 20 pixel okay so right now if I just save this okay so let me save it and let's just run this so we can just right click we can just run over so you can see that it's running on
this port so let me just copy this and let's just open that okay so right now you can see that we have welcome to my chatbot and we have a button in here now we need to just add a style for this because it's a little uh not looking good and we have a style in here so let's chat widget button so we have that ID in here but let's just use that okay so I'm going to just copy this and uh I'm going to just paste it in here and the head section okay so
let's save it and now if I check it so you can see now the button is looking good right now uh it's not uh we don't have any functionality for this okay so this was for the button after that we need to create the chat box the chat box itself okay so I'm going to just copy this and paste it in this section so and here we have a chat ID that's chat widget and we have a class so we're using a bootstrap class the position is fixed we have Shadow D9 and also we have
a style of bottom 100 pixel right 20 pixel and this is the width okay uh so element div is not close I think we also need another dividend here okay okay so now uh after that we have a div class it is for the header uh that text is white and we are writing just chatbot and also we have a button uh on there this is the ID at the top we will have a button that should be for the closing for the closing of the chat box okay now the type is button and the
classes between close float and and this is the audio label okay so this will be the button and also so right now if I save this and if I check it it's not working because by clicking of that button we want this chat box and this is the place that the uh the chat message will be appeared in here so we are going to use this and we can just paste it in here so it's uh chat uh it's div class card body and this is the chat with message and this is the place that
the chat message will be appended in here okay and then we need to just create the card folder so our complete chat boxes inside the folder okay inside a cart okay inside a card so this is the card folder we have our input text and this should be the form control and this is the for example we're saying that type your message okay so this is the basic uh an HTML that we need so right now if I just run this nothing will happen and if I click on this uh we're not seeing anything okay
or we can see GQ record so now in here we want to create a script so we can just say script and inside the script first we want to just work uh create code for the chat widget button click even so for example if we click on that button on this rounded Circle button what we want to do we want to just open the the chat box okay so for that we can just say it all over document and I can just say dot really and we need to just create our function in here so
now up in here what we want to do for example if the chat widget button is clicked so we have that in here so if this button is clicked this chat widget button what you want to do okay so I can just say dollar if they uh chat widget button dot on save that's clicked we want to trigger this function and on on this function what we want to do we want to just toggle this uh the the chat box this chat widget that we have so this chat widget so in here I can just
say dollar and this chat widget okay so dot total class and we can just make it Dana okay okay so right now if I just save it and if I just check it so you can see that right now this button is not working when I click on this you can see that the chat box is in here right now we can just write but nothing happens by clicking of this you can see that the chat widget boxes appearing in here now let's work on this close button so in here we can just say if
we click on this on that close sign so this uh chat widget close button dot on if we click on that what we want to do we want to just use this one so let me just copy and paste that in here and we want to just say add class okay so add class okay so now if I just refresh it and if I go here so I can see that now I can close that and it's working and the previous lesson we have created our simple design and also we have used jQuery code now
in this lesson we want to handle our user input so right now you can see that this is our simple chatbot if I click on this we have the chat bot and we have a close button but if I write something in here if I hit enter nothing happens now we want to create this functionality for our chatbot so now in here what you want to do so I can just say dollar okay so if we for example we need to Target the this chat widget input so this chat widget input so I can just
say chat widget input okay so if we keep press on that so I can just say key press if we key press on that case we want to trigger a function so you can just say function and in that function we want to pass the event so you want to capture the event and in here what you want to do we want to check that if event dot which is 13 on that case what we want to do we want to just get the value from the chat widget input so I can just say let
up user message and I can just say chat widget chat widget input I want to get the value from that so dot val and after that we after getting that we need to just clear the input field and I can just say chat chat widget import and I want to just say dot val so dot val and make it MP3 okay or clear that so now we have that the value so in the user message now we can just append that uh to the uh so I've copied the code we need to we can append
that to the chat widget message okay to the this chat widget message that we have created in here okay so we are going to open to that so we can just say chat widget message dot append and you want to give just a strong tag in here and we can just say U for example the user message so now let's save it and let's check that it's working so if I refresh it and for example if I say hello hit enter okay nothing happens and let's check the towards the problem so we have the chat
widget input it is the same that we have in here so uh it should be in here chat widget input so let me just copy this um chat widget input okay so we are using chat with the button that's not button sorry that is input okay I think uh okay sorry this is the top one okay so we are working on this so chat widget input dot key press function event if event dot or it is dot which I think that was the problem chat widget input and let's save it and let's just run it
again so if I say hello you can see Hello if I say like this okay so hit enter now this is working okay and we have the message in here and just the the problem wasn't here it is event dot which so now it's working and there is no problem and let's start something in here for example handle user end port and chat box okay and that's also something you want to learn that how we can send user messages to the server so to do that we need to bring some changes the first thing is
this that we need to add a rasa API URL okay so I already have added the codes in here let me just copy this and paste it in this section so we have rasa API URL and it's typically used to store the URL of the resource servers rest API endpoint when you run a resource server it exposes different API endpoints that can be used to interact with the chatbot and send messages for processing and receive responses so you can see that in here we have web hooks rest webhook now this is the specific endpoint of
the resource servers rest API that is used to send user messages and receive responses in a restful manner now when the resource server is running your chatbot application can make HTTP post requests to this URL sending user messages as Json payloads and the data server under a soft server will process the messages and return the chatbots responses as a Json object okay so by this reason we need to add that in here after that what we want to do we need to add another route in here and that is for the web hook route so
I can paste it in here and first we need to just import the request and also j75 j75 from flask also we're going to import requests okay so now here you can see that it's the router's webhook and the method is post and you can see that and here we are getting the user message as a Json and also we are printing that and in here we are sending user message to Russell and get bots response okay so we can just use a post request to send the user message to the resource server okay and
after that we are receiving the response and we are going to convert that to the Json and we can just print that result response in here okay and then here we are just getting the text of the response if there is a response if there is not response we can just say that sorry I didn't understand that okay so for example if we have something that's not trained okay and at the end we want to just return the response as a jsonify as the both response okay so we have this after that what we want
to do we want to just uh create an Ajax request okay we need to create that so let me just copy that and paste it and let me just copy this and in here I can just open my index.html and in this section so in this section we can use that okay so let me paste it in here so now this is an Ajax request and send the user messages to the server and get both response okay so the type is posed the URL is webhog the content types application Json and then here this is
the data we are streaming we are doing we are still unifying them uh message to the user message and this is the success message and we are uh getting the uh response from the data and we are saving that in here and at the end we are appending that to the uh chat box okay so we are using dollar chat box uh chat widget message and we are appending that both response and there okay and also if there is an error we can just handle that in here so now let's just save it and now
if I just refresh this and if I say for example hello you can see that hey how are you okay so if I say for example are you bought I'm a bot powered by rasa so if I say I am sad you can see that here is something to show you okay so now these are the default training data now let's just add our own training data in here for example uh let me just oh this is the terminal and okay so now in here what we want to do we are going to just open
our uh uh nlu.yml and in the nlu.yml we are going to just add an intent in here okay so let me just copy the intent and let me paste it in here so this is ask name for example and we can just add that in the domain.win so let me just close this open the main.ymail and let's just add that in here and also we need to just create for example a static response so so for example in here I can just say and we need to just give the text for example uh welcome to
the course my name is Russell chatbot okay so now let's just train our model so so train so let's wait oh yeah I forgot to add the stories my stories so by this reason I have created that and in here I can create a story so story for example I can just say ask name and we need to add the steps so steps now the intent is uh ask name so ask name and the action is this one okay so in the domain.whelmer we have this one okay so now let's just train in the model
again so that's our train so now the model is trained let's say rasaran let's just run this so now we can see results server is up and running and if I just refresh it so for example if I say hello so hey how are you and for example if I say like please give me your name or what's your name so for example what is your name okay so welcome to the course my name is Russell Chapel now we have a problem in here we don't have any scrolling in here so if I add messages
like this or great carry on okay so you can see that we have the chat box the chat box is not looking good okay so we need to add a scrolling functionality for this to do that we need to open our index.html and we have a styling here we are going to add another style in here so we want to add one for the chat widget okay and also for this chat widget and also another one for the chat widget message okay so for this chat widget message so now let me just save it and
now if I just refresh it okay so if I say hello what is your name so so for example let's just add some data in here okay so now you can see that we have a scrolling functionality and we can just scroll that okay so you can see that now the chat it's scrolling and now it's working on our chatbot is working and we have integrated our chatbot with a flask project now you can use any project any complex project and the integration will be the same