logo

NJP

Google DialogFlow | chatbots | part 4 | Google Assistant Integration with ServiceNow | chapter 8

Import · Jan 14, 2022 · video

hi everyone this is the fourth video in the series of google's dialog flow and in the previous sessions i think i have discussed all the basic building blocks that we need to build a chat bot so in this session i'm going to consider a use case where i'm going to create a custom intent to get the status of the ticket from xyz third party tool so in my case that tool name would be service now and i'm going to get the status of that ticket from the servicenow platform so let's see how we can do that i'm going to click on create intent and create a custom intent so on the intent form i have a couple of things over here a one is context so context is needed when i'm using several intents where one is giving an input to the second one and the second one is giving some output as an input to the third one so i am not going to use that in this very simple use case and we can also trigger some intent from non-verbal signals using events and i can add some training faces so i'm going to add some training faces and let some of them be uh please check the status of incident number zero zero one so in this case zero zero one is my action let's take this dot number so this would be considered as an action parameter and we can add more training faces as well uh and you can see that once i have uh marked it as some action parameter it is automatically populated over here so in this way i am telling my bot that in this intent whatever the text is there will be a number and it follows a user expression along with the number so so same way i can also do this i'm going to save it again and i will be adding couple more so these are just different ways how a particular sentence can be formulated by different people like check the status of incident number this and this please take the status of incident number or what is the status of incident number and so on so there can be more phases as well but for now i'm going to configure these three and i'll move ahead so this way when i'm going when a user is going to say any of these faces to the bot bot will understand okay i need to get the in status of this particular ticket number and so i think i already saved it i have some action parameters i don't want to configure any responses but i do want to enable the web calls so we will be configuring configuring that in a moment so i think whatever i wanted to do as part of this intent is done now to configure the web hook for the service now instance url i will have to create a user and i will also because i'm not using uh i'm just showcasing how it's done as an example i'm not using any token based authentications all though that can also be considered as a use case but as part of the simple demo i'm going to use username and password combination along with scripted list api so i'm going to hop to my servicenow instance and i'm going to create a user first so let's say my user is by log dot agents so i'm going to save this user now i'm going to configure a scripted rest api so so i did not configure any password for that user which i definitely need to know okay done and now let's go to a scriptor test api i'm going to create a new one um ticket response and here i need to configure all my code that i want to so i will be sending certain data over here i am not using it as a end point to get all the details so i i'm going to use post request because i can also modify my solution to create a ticket in the service now instance that's why i'm using post for now and this is my instinctual so i need to go to fulfillment i'm going to enable the web hook here is my web book url this is the remaining part and here i need to mention the username and passwords that were configured if required i can add certain headers as well for example content type application by json so that my data is sent in json format okay i think this is it for now and okay let's give it a genuine name ticket status check and save it if i say what is the status of 0 any random incident it won't make sense for now let's try this let's say it is four to four as i said as of now it doesn't make much sense because nothing has been configured and nothing was returned from the instance so let's configure our scripted api okay so first of all i am going to declare a variable for the spawn citer and it is going to be response dot gets to knight this will help me write the response which is going to be returned from the scriptures api next is this body so now i have my request body as well as request data and we can configure same scripted list api for multiple different intents and perform each and every function individually by giving if else conditions uh so on eight line i'm going to show how to do that so request data dot okay ctrl space doesn't work in this area dot intent display name if the display name is what i have given over there let me copy then [Applause] then this part of code will execute [Applause] status check is the name of the intent and for that all the processing i'm going to do over here whatever the incident number is and everything so let me get the number incident number equals to okay and here i get my incident number so now i am writing everything over here but the best way is to create separate functions so called script includes and with the number now what is the name okay ah then here i need to specify the whatever i'm planning to return from this incident number so if i'm asking for the status of this incident number then probably i would want what state currently it is in or to whom the ticket is assigned to so let me try to fetch the assign to form here if assigned to is not empty then only i want to fetch it so let me also declare another variable where i am going to capture sign to value [Music] encourage dot get display value all right if it is not nil than that if it is empty then no one it is assigned to no one the ticket is assigned to no one what can be done and i can configure the message right here so let me declare one more variable on top equals to okay i want to know the number as well i will see number one is no one or maybe somebody whatever it is current state of the second is okay display value of state field okay and what else i can add over here i can add let's say the last updated state oh so this person updated the ticket on so and so date on this particular date okay i think this should be it so here i have configured once the intent is called to return a response this particular message has to be sent back now how we need to send it back that part is yet to be configured okay so now we'll work on that over here this was the start of my if and so 90 percent of the work over here is done now i am going to configure some headers for the response message okay so this is going to be the response object so it's it has to be semicolon and i am going to okay i can declare it on top or towards the bottom that is completely fine so response headers and you have to mention the content application by json status i'm going to mention is 200 then i'm going to set all the headers now now the final piece to it is the response body that has to be configured did i declare a variable for that no i did not so let's do it body equals to this and then i need to specify fill okay control space won't work my band again [Music] what is the name it has to be this response message okay next is going to be reload so in the payload but i need to specify everything for example like i mean this is the generic stuff which is also available in the google dialog flow document so so that you don't have to go [Applause] my apologies for the background noise but what i was saying was so that you guys don't have to go through the entire dock that's why i'm writing everything over here so response so these are certain parameters for which the detailed explanation is obviously given in the docs but for me i am able to recall what i did last that's why i'm doing it on the basis of that so this is just a trial if it works out otherwise we'll do certain modifications to make it work um now we need to pass the response message [Music] so i think this is good but am done in the end i am going to use the writer what was the name i declared on top response right sponsored.right string and i am going to use json dot string file and here i'm going to pass the response button that's it let's save it and see if this works for us if not we'll debug it i'm going to navigate back to my dialog flow and i'm going to ask the same question which was asked over here what is the status of incident number this distance for some reason i am still receiving the same response let's check it out so let's check a couple of options over here i'm going to go to the training part and um no i don't want to upload anything you can go back to my so the part that i seem to be missing is probably something related to training so let's go to our agent settings and see if we have an option to train our agent not in languages but okay here it is let me click on train so it says done okay i'm going to navigate back to my intent and let's try again okay so some news is good news this time after training the agent i'm able to trigger my intent ticket statistic but for some reason things don't work out so we'll have to check that [Music] the number is passed and this is the display name that we are passing in okay so i think it is going in there so it responds receive this kind of empty and that's actually strange so let's verify if it is going in yeah let me add a couple of logs and then we will see if it is going in there let me also print this maybe it is not entering this if condition itself yes i hope i saved this so i added a couple of logs and it seems like issue is with this part so let me add a two string over here and see if it works twist again it works fine now so i'm able to successfully fetch the incident data that this incident is currently assigned to whom and current state is in progress and incident was last updated by system on 8th of january 2022 so let's see if this everything whatever is mentioned over here is correct or not a scientist should be problem manager current state should be in progress so this is the one state is in progress and assigned to is problem manager so all the information is correct so we were facing issue only with two things first of all we did not train our agent so that it finds that user expression and response back to it with the help of the intent that we created and secondly the number which i am passing over here i had to convert it into string to make it work there are a lot of ways to handle this particular scenario and i handle it in this way so because i'm simply fetching a number not the whole alphanumeric digit in series you xyz something like that so this is how we can make an interaction work from a dialog flow to service for instance and this is just a very simple one but there are a lot of things can be done we can create a follow back intent follow up intent where bot can do a lot of conversations with the user not just getting the ticket status it can be a two-way communication we bought ask a couple of questions user responds back to all of them one by one and in the end if there is a illusion is still not there but can ask the user if the user wants to create a ticket and if user gets the resolution then the chart can be closed there and then and we can also use this feature by speaking something what is the status of ticket number 10424 like this and it is still able to find that ticket and if i open the dialog flow in a new window then here is a dialog flow messenger and we can try it the agent snow agent is available over here and i can talk to this agent as well and ask for the ticket status so let's try a different teaser expression this time so this ticket is not assigned to anyone and the ticket status is new i hope you enjoyed the video thank you for watching

View original source

https://www.youtube.com/watch?v=SkNM5SF29Yo