logo

NJP

Flow Generation and Code Generation Best Practices (AI Academy)

Import · Jan 24, 2024 · video

all right let's get started good morning good afternoon good good evening everybody and welcome to AI Academy before we get started um we'll share the Safe Harbor notice that you probably have seen everything that we are going to cover today is part of our existing product but in case we mention items that are on the road map that are not available yet please follow the direction in the safe H and check with your accounting before making any purchasing decision as always before we get started I would like to share a few resources for you uh if you have any questions or if you want to look at our content regarding our generative Ai and intelligence product feel free to go to our generative Ai and intelligence Community forum for that there is a simple link snws a the recording today will be available on our now Community YouTube channel afterwards and it's also a great place to find a lot of other videos from other groups on the specific topic of today there are two one article that's super helpful it's called code generation tips and use cases that can be find found on the developer Advocate Community forum and there was a session last year on the uh analytics Academy regarding how to leverage gener generative AI for your analytics with Cod assist so those are great session to um look at if you're interested on the topic but if you are here with us today it's great um we can have the we're going to be able to share the content today and you can ask your question on the Q&A panel the session is recorded and will be posted posted on the YouTube channel afterwards and if you are new to AI Academy what's what's it in it for you today it's a session where we provide you fresh ideas so you have a better understanding and practical guidance on our product but as I mentioned if you live with us today use the Q&A panel to ask all your questions and we try to answer as many as possible today we're going to start with a quick overview then we jump on an exercise and we save time at the end for the Q&A and our speaker today is Adam Stout and we're going to talk about flow generation and code generation best practices so welcome Madam the floor is yours thank you very much the week um so let's get into it uh time time is short and again as we're going through feel free to put those questions in the Q&A um we're going to start out with a a walkthrough we're going to talk about what we have in flow designer for flow generation and flow recommendations as well we're going to talk about those a little bit we'll get into code generation and then we're going to go into that example um as as fast as we can and do some live live building and really show off what it can do um and as we're going if you have some comments some things you want to see we can try and pull those from the chat as well and then of course we'll answer questions so let's get to flow designer about where where our generative AI uh exists in flow designer um and it's good we start out with the Safe Harbor slide because we will be talking a little bit about what's coming out um what we are talking about now is what's available uh in Vancouver uh today this is this is there I believe this was all released in November um but you can get this and use this today it will continue to be improved uh through the release next month and and continuing to be approved for foreseeable future what we have today with flow generation is when I go to start a flow when I go to create a flow I have the traditional build from scratch which looks very similar to the default which is build with now assist and with now assist all I'm going to do is put in the flow name we still have to give it the name we get to generate that and the description what do you want it to do uh from the build from scratch this this exist existed for a long time and it used to be the description what am I building and now what we do is we just say this is what I'd like it to do I still have all the additional properties which scope do I want it in and a couple of those things to adjust but then I'm be able to press the build with now assist and that is going to create my default flow a couple really important points as we go through this for now assist for Creator which is what's enabling flow designer uh flow generation flow recommendations and code generation we need the now. assist. Creator role so we need to have the the now assist cre Creator analysis for Creator skew product and then each individual user you'll be able to control do I get these actions or do I not do I get these skills do I get this or not um if I do not have the now. Creator now. assist. Creator role I can still build flows if I have the right access but I do not see the build with now assist so I need to have that role I need to um to have now sis for Creator I need to enable the skill like we do with all of our our gen skill I need to enable that and I need to have the role because it is user by user that is saying you get to use the now assist features for Creator or you don't that's true for for code generation and it's uh true for flow generation and flow recommendations so right now with the screenshot you see one that I do have the skill activated and I have the rooll which gives me the build with now assist it is going to build the skeleton the skeleton it is looking at the trigger it's going to create the trigger and it's going to create the steps and the actions uh in the current version it does not fill out the data pills so we're going to walk through a couple of examples of what gets created when I use the build with now assist so in this case these are prompts that I that I typed in and these are the responses that I got these were these are all real screenshots um so every morning at 4 am at 4 AM every morning um I want to get all the open incidents and send a message to the assignes so it understands the trigger we do a really good job of picking up the trigger we'll see that coming through it understands Monday it understands 4: a.m. open incidents it's going to see lookup records because that's how you get open incidents but I will need to go into lookup records and to uh to specify the incident table and active is true or state is open whichever I want to do and then it gets the it understands with the get a list I'm GNA do something it understands there's a for each so it created my for each list of items and then it doesn't it didn't get uh send an email or send a message it didn't understand send a message in the current version these screenshots are real but they are actually a month old or so um we continue to improve the model so these will change if you do this right now you might get a different result uh because those models are improving all the time as as we continue to train uh but it did understand the right Trigger look up the records go in so now with a few clicks I can configure this flow very quickly couple more examples I want to walk through uh with the aify the CI owner it understands incident created and then it's going to put up uh again that structure for me and if it doesn't understand what you're trying to do it is you got to put that placeholder in there uh and and give it a name so add a user to a group it it didn't quite get what to do with a watch list it didn't understand that so I'd still go in and tweak it but it does get those triggers correctly and then as again as it picks up what's going through it will get some of those flows pretty pretty correct so when a problem's updated send an email it knows what we're doing more advanced phrases more France uh prompts in the descriptions give us give us the skeletons it's not always what you want it is not always the the best uh to come through because there are some things that are nuances where I actually don't explain what's coming through um this will continue to be improved uh and then be more iterative as it comes through but today it's only when I start do I am I able to create my prompt so we want to be quick we want to be succinct on what we want to ask for in this case I'm actually putting in more information than it's going to use today um because it knows when a case is uh when a case is updated escalated it know it's updated but I am GNA have to go in and put the configuration about uh to a P1 or a P2 or where did it come from um I didn't say you know if a P2 becomes a P1 do I want to have it that's still something I'm going to have to think about but it gives me that skeleton which I can quickly configure a feature that's really really important with this and the way that we recommend that you use flow generation today is you use a simple prompt to get started get your skeleton it's going to save you a few moments and then I'm going to use flow recommendations and flow recommendations come along with now assis for Creator uh it's a different skill that we want to activate but what that does is looking at what I've built along the way it's going to recommend the next action the next set of actions this is a huge huge timesaver so while flow generation is nice it gets me started gets that trigger picked for for me gives me the rough structure I find a lot more time savings realistically with the with the next best actions that are recommended the flow recommendations for flow designer these will change depending on the trigger these will change depending on what steps come before it's not alwayss um create record and create task but we're seeing the five top options it is rare for me that what I want to do is not one of those um if I do a lookup records I'm probably going to do a four each and that's what it's going to suggest it's going to suggest um actions it's going to suggest flow logic and very very commonly it's going to save me a few clicks and really save me time in my flow creation you still need to know what you want that flow to be um whether I'm using flow generation uh or I'm using recommendations you still need to know what you want it to look like but it's going to help you get there F now it's just for career let you do you still need to know what the end result me needs to be you still need to know what good looks like but it will help you get there get there faster um the recommendations will not recommend custom spokes that are on there this is trained on Central data it is not is not um trained on your specific instance so one exception will come through is if I wrote my own spoke uh it won't be able to recommend that uh yet some one of those areas that we're working on but again generally was it building flows I have a lot of lookup records list uh for each of the records and then update the records very very common design pattern but instead of just having a few design patterns it is learning from all the flows that we have and giving you great recommendations all right with that I'm going to take a quick look at the questions um uh the licensing cap question came in uh this is now assist for Creator is an additional license um it it is not included for free talk to your account teams about how that can get packaged for you but this is an additional uh offering is not bundled in into any of the existing SKS you need now assist for Creator to unlock this and these features are not included in the uh the now assist for for itsm or or now assist for CSM or HR this is a standalone skew you don't need those the other ones um but you need this skew to unlock this these features for for your developers and one more question uh so a question came in about does this need text or can I give it an image uh today it is text based um those are certainly areas that that we're looking into on how do we make it smarter and easier uh to come through but today it is text based um both for uh code generation and for um for flow generation we we use text to tell it what it wants I believe English is the only thing that's fully supported although in our testing we do see a lot of other languages work decently well um but but uh uh I believe it's English only text uh today this will continue to expand and I will specifically um talk to our our product management team about uh about about different flow maps and and process maps that come through um to see if there's something that can be that can come from there I think there are some other uh projects that are being worked on particularly if you're pulling it in from a process map from some existing tool and some other standards that come through I don't know that would be gen because that's more of a transition um but very text focused at this point in time all right uh moving on we're going to go to code generation and with code generation uh there's a few different modes that we're going to use for code generation to come through and that is comment to code where I give it to comment and it generates it the format that we see um the gray text is where there has been a a a prediction a recommendation which I can then accept by pressing tab or clicking on it or I can reject by pressing escape or clicking not on it and click outside it will it'll reject that that um uh that suggestion uh the first one we have is comment to code text to code where I give it a comment on what I want it to do we'll do some more Demos in this area um and then code complete is the other mode where I am just writing JavaScript and do it uh they're different modes because they think about them differently they the back end is exactly the same um that it is looking at what you give it and then completing completing that um they can be used in conjunction to I could uh write a comment start the code and it will complete it but we do think of them of those two different ways where do we use code generation so flow generation we use in flow designer it's easy code Generation Um is extremely powerful and it does understand the words you're giving it in flow generation it didn't fill out the pills it gets the trigger it gets the structure but the data pills are not completed yet code generation does understand what you're saying and it does give us a a lot of of Power with great power comes great responsibility we don't want to see writing code where we can use low code solutions that the load code message is still uh very true very powerful on how I support it how I understand what's going on how I test it just because we can write code doesn't mean we should write code but where we need to write code let's use code generation so my number one use case for for code generation is action designer I'm going to write code Snippets that I can use in flow designer extremely powerful extreme makes you extremely productive that I can write those those code Snippets very quickly very efficiently um script includes we still use script includes and code generation will help me there fix scripts fix scripts are are very quick to do I just need to fix some data I'm not going to build a flow um I oftentimes see fix scripts overlooked when I'm when I'm making a process change I'm not fixing my old data sometimes that's okay sometimes it's not we can use uh code generation to help us write those fix scripts again you still have to know what's correct you have to know what right is but it's going to be very very helpful um email scripts works well there when I need to write those and if I'm using instant scan I can use code generation if I'm doing a script at instant scan it will not tell me hey don't use a script here you should just use the condition the table query and instant scan um if I'm an action designer it's not going to tell me you know there's an outof the-box action that does this you still have to know what's available and use those things but again these are places we do write scripts and if I'm going to write a script I'm going to write it faster with code generation places I don't want to see code generation being used is in business rules um generally there there are certainly exceptions where we still use them but we don't want to take away from flows we want to use flows when we can um but so not just go to business rules we see a lot of people who just go oh no I can write thousands and thousands of business rules we still want to use flows when we can and then scheduled jobs I'm I'm almost always going to use a flow instead of instead of a scheduled job which is a script I might go in and write new actions an action designer so my flow can do everything but I still want to be using those flows scheduled flows rather than scheduled jobs so be conscious of where you're using these things and then the use cases uh that we see again we'll we'll go in into the uh the demo but basic code generation so with a switch statement all the time um and it it understands because it's been trained on our code these are really common things if I want category question request complaint those might not be right but they're reasonable to start w start out with and I can just go in and edit them so it's a very common design pattern that I will use code complete it will give me the syntax and then I will edit the code that was created um exercising apis huge Time Savings huge Time Savings for apis uh service now has has lots and lots of apis and in the past when I was writing something if I was going to make an Ajax call I would have to go uh I have to go to the documentation find the example there and then I'd have to go edit it I might uh I might go uh to a search engine and search for the code I'm looking for go through a few examples and go Ah that's pretty close to what I want copy and paste that into the block I'm looking for and then edit it I don't have to do that anymore I can just go I want to do this it's going to show me that that that API and once I have that API I can edit it again this does not is not trained on your instance's data so if you've written Custom apis Custom script includes it will not pick those up but you can well I'll show you you can put in placeholders if you know the name of it it will WR follow the right syntax um and then uh the other note was context matters so this has been trained on our data this is not a vanila code generator it understands the difference between I'm in a mail script or I'm in a business rule if I am doing a business rule or I'm in a script include or I'm in instance scan those all have different variables that are that are available to them as inputs and outputs and because we've trained on those it's going to be able to predict those for you all right with that we are going to jump over to to our our exercise and our demo and Excuse me while I switch my window all right I am on an instance that has the skill activated and my user has the role um an important question comment about this too is the now. assist. creator role does not is not by default inherited by admin so even as an admin I wouldn't see this um even as a an admin by default I won't see the the now assist for uh for Creator options the flow generation the code Generation Um it won't be there you'll go granted to decide who you're going to have that for um okay let me pull this up really quick so we're gonna go to flow designer and I'll launch flow designer like normal and now that loads a couple questions oh L's gonna that one and can I use this question came in can I use this in Virtual agent designer um and L may know the answer to that one I believe it's not been connected yet but it that's coming code gener flow generation is only in flow designer code generation is available any place we have the Monaco text editor the script editor so it's enabled almost everywhere in the platform in in the core UI um where you have the the script editor that has the preview on the side and I'll show you where you'll see how it's activated when we get into the code Generation Um demo uh but I am not the virtual agent designer I'm not positive if it has been hooked in there yet but I know that's been on the list so it might it might be out pretty soon um all right we're going to go to flows I'm going to create a new flow um so we're going to create a new flow if I didn't have the now if I didn't have the right role we're going to see just basically this build from scratch which is a flow name in a description since I have it the default is build with now assist and we're going to give it a flow name which is um uh see notify SBI owner of cases and what what we're going to do is uh when a case is open the uh pretty simple when a case is open notify the owner of the CI that the case was open for uh on their behalf they are not the build with now assist and this is now going to create my flow for me and the joy of live demos that we love to do here uh is that sometimes it does take a couple seconds to come through on my demo instance um so as this comes in a question came in about the analysis for Creator um this does help developers um if you're not developing then then you probably don't need this um but if I have a developers and I'm paying for app developments I'm configuring Beyond just configuring uh building new applications and app engine if I'm making adjustments I'm creating new flows this is going to make this is really going to juice up what my developers can do and help them be more much more productive but if you don't have dedicated developers this might not be a product you want to have um and it is priced per developer it's priced generally price per developer it's priced differently than um uh than the now is for CSM or HR okay so it created uh when Cas is created or updated it did get um doesn't want to I did get that this is case to come through uh so it's getting that the the the trigger pretty close to what's in there the lookup record because I need to look up who the CI is it doesn't fill out the pills here but it knows I'm going to need to do a lookup and then if it doesn't understand it didn't understand my if statement but it knows that there's going to be an if here um and then post a message that's a pretty reasonable choice that we want the teams message I may come in and change that to be send a notification but I get that that structure done pretty quickly and then I want to show off the recommendations so we come in here so after uh after this it's going to say well you're probably going to update it Creator update similar but different um or create a new record or put an if if inations uh after my if I'm gonna put a in and uh and then I again have different records that come through here I can still come in the normal path and click I want to add it uh I want to add my flow logic I want to add my elif you can still do that but with this is just a huge Time Savings because those common things I need are right there so it's up to you all right so that is uh flow generation and and flow recommendations let's get into to come through and please again F questions in Q&A and we'll get to those so I'm going to come in I'm going to go into fix scripts um while I prefer um the the screen's a little bit smaller it's not as easy to see but I can come into my actions and in my actions find one of these that I just worked on and we'll see my script step so inflow designer in my script step uh the key do you have is this activated for you or not you'll see it in flow designer because it will um give you the prompt for now assist the script block will have the the two stars here and powered by now assist for code generation if it's enabled if you don't have the role you won't see this um well and I have this code in here so I put some comments in here check the payload for Social Security social security number and then replace it this is not super hard but it's stuff I have to go do and how do I do the redx again what's that look like I'm going to come in and I I ask now assist to give me a recommendation based on what I've done so I am going to press uh control enter or I'm going to press uh control Ender on a Windows machine command enter on a Mac and it will give me a recommendation on what to have in here I'm going to click on the gray and it's now put in it's not put in what I've wanted what's important here to note this understands I'm an action designer and that I have inputs I said check payload so it assume my variable is payload if I change that it would it would change it um it's replacing a redx this is a pretty reasonable um Rex for for social security number and then I'm going to replace that with so for what I want to have in there it's creating um the the output payload a status an error message all common things that I'm going to do in in action designer and actually I'm G to same quote this one will be interesting as it comes through but let's go run this in a different context so again because I have this context it's generating what what comes through in this case it actually repeated the lines a little bit so I would delete some of these I'm going to clean it up uh but I'll come through so we're going to go uh back over here I'm going to go to like I said pick scripts because the text editor can get nice and big and I'm going to create a new fix script I'm gonna put that exact same quote in here the exact same comment um again we see the stars so that I know that this is powered by now assist which means at the end I can come in I'm going to press control enter and it's going to come up with a recommendation for me now what's important to not is recommend is different it's in action designer I wouldn't update the record I wouldn't I actually wouldn't get the record fix script I'm GNA do do that now I didn't give it any context about what table whether this was case or incident it picked one um but the rest of this is all pretty reasonable what comes through and again it it helps me with the Rex um syntax about what I want to do with the replace if it's there um I'm going to go edit it because in this case it actually wanted to put the text in for SS but syntax it comes through uh an important note in the text in the in the editors this purple line down here tells me that this was code that was created by now assist if I come in and edit it because I'm going to remove the SSN prefix I don't I don't need that I just want the 3 digits two digits four digits it's now going to show me that this has been edited and this data is stored as metadata in the system that helps me understand how much has been uh uh generated how much has been edited uh to come through uh so we've done that uh to come through I'm going to show one more example where we'll see case ma uh syntax matters as it comes through the context matters so I'm going to do um uh check for open incidents open cases uh that I can't type type andp type and talk at the same time that have not been um updated in three months I'll have it I'm requesting it for to predict what's going on a great again another great time savings and in this case it understands service now that this that up upd in three months is an easy query I don't have to get everything in Loop it it understands that has been trained on service now examples not vanilla not just vanilla JavaScript uh so we have that this is all pretty reasonable to me to come through and give me my numbers I didn't tell it what to do so it's gonna send it out as an info I'm G to get rid of this and if you ever forget that the syntax key when I press the help it is added down here for people with now the now assist greater role you'll see the trigger AI accepts trigger AI accept suggestions dis dismiss suggestions if I don't have this I don't get teased I won't see that I'll just see the normal help L we're going to put this in here well I didn't want CSM cases I wanted HR cases so I'm G to put in HR case and again I'm gonna suggest what's going on uh this is again trained on Central data not on your data so it will suggest it may suggest out of thebox tables that you don't have so just because uh this didn't check do I actually have the customer service table it didn't it's not checking do I have the HR or case um but so make sure but it does understand cases uh default the CSM cases I put HR I get the HR Core case I might come if I want it to be something else it's not always deterministic on what you're going to get so we saw the encoded query and the CSM one we see the opened at with a ad query here slight variations you can choose what you want both of them work the same so I'm just going to I'm not going to change that but it does come up um but again it understood out of the box tables you don't have to have it perfect you just have to have it close and you come can come in let's say that I didn't want HR cases I wanted um uh I created a potluck app and I have cases for my potluck um and I can say that it's going to generate the same thing oh it's gonna pick something random I actually wanted to do something else it didn't get what I was doing here but if I had a specific um X a12 three if I have a specific table I want to have and I put that table in it's going to understand I don't know what this is but I understand it's a tailor so this should now put in the a x A123 potluck case table right it'll it'll have that now it's not validating that table exists which is good in this case uh because it may not exist yet I'm going to go create it it doesn't know if active is true or not I check for open active or true is a very common design but I might have to go adjust this and the relative for three months CIS updated on that that is correct here um so again as you're going through the more information you put in the better your code will be um but you the the game is how can I write as little code as possible to get the right thing you may try a couple times um and it is important to practice to understand what it what it's learning and what it doesn't a question came in can I use Glide query let's find out real quick uh using live query so that didn't pick it up um in in this context open try one more so it didn't get it here but you code complete does work uh with this so if I did um I haven't I have intellisense but even from here should give me an example of by query yeah so from here I tell it what to do um but I was able to just do a code complete from Glide query and get this example really really useful for apis that's what I use it for a lot because I don't always have at the top of my mind the two array or is it Li it's set limit with glide record it's limit with with uh GL query it's going to give me what's going on all right I believe I'm over time and the week's goingon to start yelling at me um let's make sure we get through the last questions that we have so um uh so yes the apis you can tell it what to do and it may not get it all the time it may not understand everything but it'll help you get started it does work if I did get a count of open incidents this normally ises Glide record we continue to TW to tweak this so actually now this even uses Glide aggregate one of the things that we've that we've been improved is we get the feedback about what comes through originally this would have used a Glide record and looped now it knows when I say get a count of I want to use Glide Aggregate and I might be able to come in here um for some reason I wanted to use Glide record it might let me do that it's not it's it's not letting me be um silly um but uh but to come through if you know there's an API name you want to use tell the API name and it'll come through if you know there's a table name specific table [Music] name do that if you don't know it put in the default it's going to get you close it's probably right and if not it's still okay quick to edit um the okay so the question so we talk we talked about that one um uh so yes you can use this inside it is looking at what's before and after um with for code generation uh it's does designed to look to look after but it will get generate code inside of a block so um if it's see I'm not gonna have a good example here um but yeah where you are really matters the cursor absolutely matters and part of the prediction part of the input is what's before the cursor and what's after the cursor uh to generate what should go right after the cursor so you can use this uh in place uh I would not use this yet to refactor so one of the big questions that we get is can this look at my code and tell me what it's doing uh code to comment we talked about comment to code I want to do this and do it um we are looking at how do we make comment to code um refactoring is something that we'll continue to look at but today where we're at is comment to code code complete those are use cases that we look at that they're very successful with um again it will work on pretty much anything that has a script block like this you'll see the stars um there are a few tables um we continue to approve this so I don't want the restrictions that come through um it does work on client scripts it does work on um server s script that works great on there is an issue with uh UI actions that can be both client scripts and server side scripts it doesn't know which one you're looking at there um so be careful when you're looking at some of those things you do need to look at it um today it doesn't understand that I'm in Global versus scoped for the most part those apis work the same but there's a few nuances where in a scope you can't call a global and a global you can't call a scope where where it comes through um it doesn't get all those nuances yet but we continue to enhance it you do need to review your code it might get you 95% there which is great but that other 5 perent if you don't know what that other five% should be it could be a real struggle so you do need to be able to write the script yourself but it's going to be able to help you do it just way way faster and remove having to go find those examples um uh the plug-in name for this um so it is a store app which is now assist for Creator when you get now assist for Creator you get all of these things and then you'll go activate the skills that you want to have and the analysis for Creator is special because I have to activate the the or install the store app I need to activate the skills that I want to um activate and then I need to um give the role to the users that're going to have that this uh needs to be on um on your subr it's the same the licensing does apply to the subpro to because that's generally we're actually going to use it as on sub prods not on prod um it is not currently on pdis um if you need to evaluate it talk to your uh your account team on how do we do that um but uh and actually getting it you want to talk to your account team what the best simplest Avenue is for you but it is not on PDI is available to everybody and you do need a license even on subpods so while most things you can go to a subpro and activate whatever you want this is not one of those and I believe that's true for all of the nysis um or another one uh important one are all the nysis Creator skills using the now llm uh yes today they are today they're using the now llm um make sure you check the model cards for the skills to understand what the latest and greatest is and what's going on but today these are all using the now llm all right so I think I'm way over time um and if we don't have any more questions I'm going to hand it back over to L uh to wrap up if we have anything else to to comment on no that's it thank you very much Adam and I think everybody enjoyed the session so that's it for today and see you in two weeks

View original source

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