all right how's it going everybody welcome back to my channel we are going to be building an absolutely insane build today we are going to be building a slack AI chatbot and this is going to be pulling in from AWS Amazon Bedrock so we're going to be pulling from literally we could we could pull from like 30 plus different AI models um we can also automate this whole entire process super super easily with n8n and we're also going to be showing how to build in a knowledge base so that your AI model can actually pull from real-time data that you save in your data store or in your Cloud buckets or wherever you store your data so this chatbot is so cool and when I say so cool it's so cool because literally instead of needing to go to like chat GPT or needing to like go to like Claud or any of these other types of apps or make your own you could literally just use all of Slack's infrastructure to then be able to then make your own chatbot and we're pulling from the latest and greatest AI model so we're going to be able to use um we're going to use CLA for V3 for those models and it packs so much heat when we are asking it questions but what we're going to do is we're going to go through the whole entire process this going to be a complete master class on how to build your own chatbot you'll see too and I'll put this up on the screen if you needed you know so basically slack is free to use but it gets really expensive when you have users and one of their new features is creating this a AI slackbot but that's going to cost you about like $10,000 a year if you have a th000 users and let's say 100 of them are active that's going to be you know a lot of money because you're going to be basically paying let's say like and the pricing arounds is probably like $9 so you do like $9 for 900 users or basically $9 for 100 users that's th000 bucks a month 1,00 time 12 is you know it it gets up there right so so we're looking at like saving literally over 10K building this specific chatbot I am so excited to build this this took so long to construct and to build but I think this is one of the most comprehensive courses on how to build slack chatbots especially with Amazon bedrock and Adis and AI so I'm just so excited to finally have this ready for you all to check this out I think you're going to be learning so many cool things in this whole course so without further Ado let's video and see what we're going to build so what we're going to do is that I do want to also just throw up onto the screen a lot of the inspiration for this specific build and then we're going to walk through how to actually build it together so I'm going to get that up on the screen in one moment so let's get this all right cool so one of the really great aspects of n8n that I really appreciate is the ability to to explore what other people create so uh Angelo Menendez created this it Ops AI slackbot with knowledge base so basically like we're going to be building the same thing but instead of using open AI we're going to be using Amazon Bedrock for the model but what we're going to learn about is web hooks we're going to learn about how to work with nadn for bot responses receiving responses and then basically parsing out information and then receiving data so that was the inspiration for my bot and what we're going to do is we're going to go look at this so this is what we're going to be building together so we're going to basically take an input this input is going to be an event from slack so anytime that a user mentions our B we're going to be receiving that information that's then going to go to our execution data which is going to just do some pre-processing um and basically just collection of that data we're then going to do some more processing of that information to consolidate it into a prompt we're then going to basically use this llm chain node from n8n we're going to pull in our model of choice which you'll see here we're using Claud we're then going to take all this information formulate this into a message and then pass this back to slack and this is going to be completely from beginner you know this is completely beginner friendly we're going to go from like literally Ground Zero all the way up to slackbot implementation so if you are excited to build this I want to see you WR in the chat that you are ready to build and I also want you to post what you end up building and tag me on social uh what you end up building with all these tools so n8n slack AWS Bedrock I'm so excited to show you all this build so without further Ado let's actually get started and create this whole entire project so when we get to nn. this is where we're going to be able to log in and start setting up our automations so um with n8n you can create these secure AI native automations that basically work like pipelines and you can connect all these different Services together really easily and have them all talk to one another so when I'm already signed in so this is what my workspace will look like and what you'll do is that when you want to create a project you can create a project here and then this is where we'll call this slack Bedrock pipeline so that's going to be able to connect our slack with bedrock and we just we can call this any name that we want and this is my account so we'll give this a save all right all right so now once we've saved our project we'll be able to start saving credentials so this is going to be important when we are setting up our slack or our AWS credentials and we'll do the AWS one first um and then we'll add in slack as well so I am logged into the Adis console and this is what the homepage will look like uh yours might look a little different from mine but something that we can do immediately is go to I am and that's identity access management and this is going to allow us to create a role that could assume the correct permissions that our slackbot will need to be able to interface with slack with the workspace with n8n and be able to communicate uh securely these permissions now what we're going to do is that we're going to on the left go to users and we're going to create a user and we're going to create a a key so this is for a a test project right so if you really wanted to configure this correctly um in the most secure way there is something called am roles anywhere which we'll learn about in a little bit um just very briefly but um this would be a more secure way to implement this type of integration but you can also use an IM IM user um it will just create a longlived credential so you do need to think about how you rotate Keys ensuring permissions and privacy and security and all of that so what we're going to say is we're going to say NN Slack permissions call slackbot so nadn slackbot permissions and uh we don't need it to have access to the Management console that's because it's not going to be a logged in user we just need to be able to have a key to provision this specific user so then we will attach policies directly and we're going to say that this has Bedrock full access and you could make these as granular as you want but because we just want to use access to bedrock I'm just going to give it full access to bedrock although what we'll probably do to test is just to get this working and then we'll scope down the policies and the permissions so that down the road um we're able to have it assume uh fewer and fewer policies as well um something also that we might want to do as well um is create a policy and um you also could set a permission boundary as well but we'll um we'll just get this set up for now and then we can always edit the policy later so we'll do next and then we'll say create user and now this user will be able to assume all of this stuff so we see n8n we'll see that this slackbot permissions is here and then now we'll be able to add more permissions we could also edit what we have here um we could also do all the security permissions that we want so what we're going to do is that we're going to create an access key and we are going to select this one so application running outside of AWS so there is something um called IM IM rolles anywhere to generate temporary security credentials for non-ads workloads that access ads services so this is something where we're going to be throwing this into n8n outside of adabas but we wanted to be able to use adab Services right so you could theoretically use this and that would be for a more um secure workload so that's where you're setting up um a CA so that's certificate Authority um and then basically like you use that to create an object as a trust anchor and then the anchor establishes trust between the roles anywhere and your certificate Authority for authentication and then you could you know configure you know existing IM roles or create new ones and then authenticate your non-ads workloads with the IM roles anywhere so this is a great uh basically a way to configure access but we're just going to create an access key for us for now so we're going to do is we're going to say this is for our n8n slackbot cool and then we'll create an access key and then once we create the key we get an access key and a secret access key so what we're going to do in n8n is we're going to copy these permissions so I'm going to copy these into a separate notes file and then I'm going to then throw these into Ann to make it easier so um I definitely recommend like having a notepad or something like that just so that you can keep track of these keys at some point um just make sure that you don't keep these you know on your computer or something like that where anybody could access them because we want to keep this secure um also if you do um this is the only time that you'll be able to basically access these credentials so you could also download a CSV file and and save that in a secure uh maybe a password protected um plac in the cloud or you know locked away on your computer or something like that um or you know save these Tov file somewhere that's you know secure it won't get pushed to get Hub or something like that but um yeah this is just one of the only places where you'll be able to access these keys so just make sure that you are very careful about that now back in n8n we're going to add our first credential so what we're going to do is we're going to say AWS and we'll say continue and then this is for I'm in us east1 and you'll be able to check that um in the top right corner um of your AWS console but we're just going to keep it as us e one here and now we're going to throw in our access key and then we're going to put in our secret access key that we just copied down and that looks pretty good so now for custom end points we don't need to worry about any of this so we'll click save and now it's going to authenticate and we see that it basically was successfully um checked and the connection tested successfully so that's great um we could also retry this again and yep it didn't get any errors so that's great so now we have our ads credential saved for our slack Bedrock Pipeline and that all looks looks good so now that we have our ads credential set up we'll then uh move on to add our next credentials as well now if you don't already know what slack is slack is a workspace that enables you to chat with maybe your employees maybe your team members maybe use it as a community and you can communicate messages out to large groups of people so I'm on the slack page here and they have a ton of features that come with Slack so you can create channels and that can help you organize your Communications and your conversations you can also um chat or connect to other partners that you might work with or other people completely outside of your community or your company and you can also uh direct message your team you can also jump on to huddles which combines audio and video so do sort of like an instant Zoom or Google meet or teams message um you could just create a meeting like that um you could also uh record and share updates with Clips you could do search over all of your messages there's just tons of different features one of the new things that they just announced was slack AI so you can work smarter and faster you know with a simple AI system so slack has a ton of really great features and it looks just like this and you could create your channels you can chat with you know different people you can also react to messages you can also integrate it with apps like Google Calendar the Huddle that I just talked about there's a lot of these different features here now you know it has a lot that it offers and we can get started completely for free with a free plan now I do want to talk about the other plans because one of the features that you might want to build for example is AI Integrations into your product or into your community or into your company now if we wanted to get started with slag we can completely do that for free here as you'll see right there but if we want to then make these other features like Integrations for example or Integra slack AI now what we're going to start doing is that we're going to start getting built and what gets a little bit wild is when we are trying to you know integrate a service like this we're going to get build not $4 per month it's actually or $8 per month there's a promotion but we're mainly going to focus on the actual price of it so about $9 per month it's $9 per active user per month so let's say that we have your own company I'm I'm going to get a calculator up so that we can look at this together so let's say that we want to you know build in an AI system into our slack chat right so that's going to be $9 per user active user per month so let's say if we had you know a th000 users in our slack workspace but let's say that only you know 100 of them are active for example so that's you know 10% so we have 100 you know active users times 9 that's $900 per month and then per year that's over 10K that's $10,000 which is just so much money so one of the benefits I think to being a developer is that if you could build your own systems then you're saving yourself so much money I mean think about that if you're able to just build build an AI system into slack you're able to save you know about $111,000 which per year which to me that's wild that is insane that is so much money that you could save being a developer so that's why we're going to be looking at slack and how to integrate a lot of really cool tools and backend systems into our slack workspace so that we don't have to spend money on slack and we can do this completely for free so let's get started so I'm back on the slack homepage and what we're going to do is we're going to get started and what we will do is we'll put in our email so you put in your email here we're going to then get a code so I'm going to open up my email and I got a confirmation so I'm going to drop that in here and then now I'm able to create my first workspace in slack so we'll click on create a workspace right here and we'll name it so we'll call it texc Playbook and let anyone with a text play join your workspace um we'll say yes for this for now and that sometimes is helpful for allowing you know your other team members or other people in your community to join it instantly so I'm going to say Brian for my name click next and then um we'll skip the step for now and then skip step and we'll just say building a really cool AI chatbot and then we're going to start with the free tier and we'll close out of this and now we have our free chat workspace in slack so this is going to be our free slack workspace and we're going to be able to build all these really cool integ ations into slack all completely for free so let's check this out now to allow our outside systems to integrate into slack we're going to need something called an API token so this is going to enable our slack workspace to talk to other types of systems that we might integrate so that's going to be specific for our bot integration we're specifically going to go to here so we're going to click here and then what we're going to do is that we're going to go down to tools and settings and then we're going to go to manage apps so iing this is a little bit easier to get to this quickly so what we're going to do is that once this will going to this is going to bring to the app of slack and what we'll do is that in the top right corner this is our currently logged in user so you're going to need to make sure that this is correct for the workspace that is going to assume this app so we can click on build and then we'll be able to either create create an app or generate a token and the configuration tokens are um actually learn about them on this page but there's different types of tokens like a bot token so this gives you granular permission to request you know specific Scopes to go into a specific Channel um workflow tokens user tokens uh we're specifically going to do a bot token and to work with our specific API that we need for slack we're going to create an app and this is going to abstract a lot of that complexity or round token use so that we'll be able to actually integrate this into our slack workspace super easily so we'll create an app and something that I do is uh I like to do is just do uh from scratch and this will allow us to just go through the settings and the Scopes and all the features so we're going to call this Bedrock bot and this is going to be our Amazon Bedrock bot that's going to be able to use Amazon bedrock in the background to basically use one of the llms we'll pick to then you'll be able to talk to it from slack and we're going to put this into the tech stack Playbook workspace here this will then create a web API application but what we really need for n8n is the web API so that's the slack API that we'll be able to then um use to then integrate slack and this bot uh together in the workspace so we'll create our app and then now we're going to get a whole bunch of credentials so agents and assistants can work alongside people in slack we're basically going to be creating our own agent so we got that and then we're configuring our app in code so there's an app manifest and you could actually deploy all of this via yaml or Json but we're going to be just doing this in the console because it's a little bit easier and it also helps to walk through all of the steps if in case you haven't done this before we want to make this really easy and simple for you can do it too but if you wanted to automate this type of process yaml and Json are great options to deploy your infrastructure as code um Allah slack so what we'll do right off the bat is we're going to save our client ID our client secret and our signing secret from slack specifically from the API into our local notes so that we can copy those over so I'll do that right now so I'm going to copy that copy that and then to copy this and then back in n8n we'll add another credential to our project just like we did for AWS and this this is where we'll say slack and we'll do slack API we'll say continue and that's where you're going to be able to get your access token but something else that I actually like to do would be slack oo2 API and that's where and I think this is such a cool feature is that you can connect your account directly so we'll say connect my account this is then going to pull up basically this integration to connect them together so once we see this here we'll scroll down and we'll say allow you could also like manage all these you know um Integrations um and all this um with the specific n 8N documentation API and slack API but we want to move fast right so we'll be able to just allow this takes a second and then boom now our account is connected this can be closed and boom now our account with slack is now integrated with n8n and that took like two seconds which is like amazing right so now we're moving fast we now have slack integrated and we have AWS integrated all within our n8n pipeline for or the credentials for our specific pipeline that we're going to be building out all right so now we can save our changes this is now going to to save our application and now we'll be able to invite this into our workspace so we'll go back here and we can already see that n8n is integrated as an app and we're going to add another app so what we're going to do is that we're going to see if we can find our slackbot that we just created and if you do try to find the app you won't actually find it yet and the reason why is because we need to install at least a permission scope or one feature into our application so what we're going to do we can go to permission scope for our Bedrock bot so if you scroll down a little bit you'll be able to see a list of Scopes and we can start adding a bunch of these so what we'll do is that we can add um bot to token Scopes or user token Scopes um because we're building a bot we're going to focus only on these ones so we're going to add add app mentions so this will allow our bot to view messages and directly um mention um bbot in conversations and the app so anybody could mention them and then they'd be able to go into certain actions um we'll also add channels history and this will allow um viewing messages and other content public channels that bedro bot has access to we'll also add channels read and that's view basic information about public channels in a workspace we'll also do chat right and that allows to send messages as the bot we'll also do groups read and that's view basic information about private channels that bed rockbot has been added to we'll also add assistant right and that will allow Bedrock bot to act as an app agent which you might want to add in other functionality as you go along um so this is a great create scope for that one we'll also do commands and this allows shortcuts and SL commands that people can use and also files read so this will allow um the viewing of files shared in a Channel or conversation that bed Bedrock bot has been added to and there's some other um features for like files write if you wanted to upload edit or delete fil f as Bedrock bot um but we're not going to focus on that that's just if somebody uploaded a file they could work with it so those are pretty much all of the Scopes that we're going to start off with and those should all be saved here so now because of the ooth tokens now we can generate um this automatically and finish installing the app into the workspace so we'll now click install to text Playbook and then we'll be able to allow so now we have our bot user OA token we now can go back to our app and we got a notification because got a slack message and it says you have installed Bedrock bot which has an AI assistant or agent on Tex Playbook so you can manage the assistant experience for this workspace in the workplace settings page all right and now we actually have it here so sending messages to this app has been turned off so we're going to need to turn that on and the way that we're going to turn that on is by going back to our ooth and permissions we're going to copy this ooth tokens so this is the bot user ooth token for our Bedrock bot we're going to then go to n8n back here in the credentials and we're going to set up select API and now we have an access token so we're going to be able to save that that credential was successfully tested and now we're going to add some more information into our slack ooth 2 so we technically did reconnect but we're going to reconnect again we're going to click allow and now the account was reconnected so now we have our slack API and our oo 2 API all set up so now to make sure that our bot can be messaged as well as added in the channel we're going to go back to our slack API for our specific Bedrock bot and we're going to go to app home on the left and then we're going to scroll down and then we're going to make sure that for the chat tab direct messages your app sends will shown in this tab and allow users to send SL commands and messages from the chat tab so we're going to select that and with the block kit we can also add this to let people easily interact with this app across the workspace so and also I think it's also nice to show that it's online I think it's just like a nice touch for a bot to show that it's always available so now we'll do is we'll go back to slack we'll give this a refresh and now we can message our bot so some very small tweaks just to make sure that the bot experience will be a good one also I really want to change the icon here um just because it it looks so Bland I want to like make it a little bit nicer so what we'll do is we'll go to canva and and I'll include a link uh in the description below of how to do that but I'm going to I have a screenshot of Amazon Bedrock the service so we're going to I'm just going to say that as Amazon Bedrock service icon so we will download this and it says that it needs to be within the size of 512 pixels by 2000 so this should be all good [Music] there give that a save now we'll try to add this app icon all right okay I just feel like that looks so much cooler and let me see if I can just pull out the color of this so when I just get the color of the gradient but like the end of the gradient copy that and then I want to see if I can just drop this a little bit yeah nice and um if anybody's wondering this is um an app on Mac called color slurp and you can like get this um ey dropper and get colors from you know your screen okay I think that looks so much cooler and let's give this a little bit of a description um Bedrock connected to n8n so that users can speak to the LMS that live within AWS use this bot to learn build grow and Achieve way more thanks to the power of a I and the cloud and automation okay sweet so we'll save changes and then now we'll be able to reload our slackbot and see this with all of our themes and colors all right so now that we've saved if we reload reload slack oh this looks so much cooler okay yeah doesn't that looks so much better much more personalized and customized and it shows that it's always on okay very cool I wondering if I if I reload this I wonder if it's making a new chat each time although that might not be the case might have been that I initiated it or maybe that was uh left over from before anyways so if I was to message this I'm going to say hey there are you there it has no way to respond to me and the reason why is because we have not set up a web hook and a web Hook is what we're going to configure for Bedrock bot so that it can receive messages that I send it so this is an event and if you think about really anything that you do in an application logging in could be an event signing out could be an event sending a message could be an event or reacting to a message could be an event you could have all these different types of events and what we want to be able to do is that when you send a message from your slack account in this workspace we want to be able to send that message over to n8n have it do its thing and then send that back to bedrock bot back into slack and that's how we're able to do the communication so we're going to do that right now so now that we are set up with our credentials in n8n we're going to then go to our workflow and we're going to start from scratch and we're going to add a step so when we add a step we're going to search for slack and this is going to be on any event we could also do this on bot at mention on a file you know made or on new message posted to the channel um on a new user so you can do a whole bunch of different things but let's just do like on any event now what we're going to do is that we're going to get some web Hooks and we're going to be able to test these different once but to set up a web hook we need to enable this node so to do this we're going to need to follow some of these steps which are listed out here so specifically what we want to change here is bot slapp mention and then we'll watch the whole workspace and slack account three which is what we have already set up um up here and then now we're going to going to want to do is we're going to test this Euro so we're going to copy this we're going to run test step now what we're going to do so we're going to go back to this we're going to see event subscriptions and we're going to paste this in so this is going to make a request to our and 8N environment so it's listening for test events that was successful which is verified great so now what I'm trying to do is I'm trying to add this production URL and this should work so if I'm running this prodction is live if I go here and I try to change the url so it says that it won't work which I'm not exactly sure why because there isn't anything that's actually changing just getting rid of test so the only thing that I could think of that might be the problem is that if I were to turn this on and then it's waiting for you to create an event in slack so if we go back here and I try and I retry if we try to save this there we go so if you do run into that issue just make sure that you go back to the workspace and you also save it because sometimes that might not work so you just need to keep that there so that should be good now so now we can scroll down and we can specifically look at subscribing to bot events so these are all of the events that slack enables Bots to listen to so we're specifically going to look at at mention and that means that when a user ask that's our Bedrock bot then that's going to subscribe that message to n8n and then will be able to receive that through our web hook so really crafty way to link n8n with slack but you also have all these other different types of events like you could listen to if somebody left a channel if a certain group was archived or something like that or if a certain message was read so there's a lot of these different types of events that uh black web hook could enable our backend service to read from or work from but we're just going to use app mention so we'll give this a save and we got a success so that's great so now we'll be able to now test back in n8n if we send any sort of messages from our slack workspace to then ping our slack web hook integration and then we should see those logged naden we're going to go back to our slack workspace we're going to go to our Channel and then we're going to add our bot so we could do add Bedrock bot we'll click this and we'll say hey there now our Bedrock bot isn't there yet so we're going to invite them so now Bedrock bot was added now if we say hey there Bedrock bot so we just sent a message to bedrock bot but the issue here is that this setting watch whole workspace is turned on so this says that this will use one execution for every event and any channel your Bot is on so we should use with caution so we'll turn this off and then we'll select the channel so we just added this to building a really cool AI chatbot but you could also do this by ID or by URL so this is the channel That We want to watch um so these are the different ones that we have here but we're just going to switch to this one so building a really cool AI chatbot we'll give this a save so workflow changes are saved here now we're going to go back to our here and I do want to just have this open so now if we try to add Bedrock bot and say hey see if there's any output out yet and I don't see any output yet so if that does happen we'll need to probably retest this and make sure that this is firing off correctly all right so I just realized that the integration was working the whole time but we need to get the data out of slack and into n8n so this is interesting so we're going to copy this same message again and this is actually one of the really cool features that I really like about n8n so you'll see why I like this but it's interesting that it I wasn't able to see this until it was finally working so we're going to press enter here I'm in the executions log which is this tab and you're going to notice that this just fired off so it is working I'm able to see the data come in um which is pretty cool but it says that for the highlighted data that um to show important data from executions here I need to add an execution data node to the workflow so we're going to do that in the next step but one of the things that I think is amazing too is that you can see in real time these executions with Auto Refresh on and like I love instant logs like it makes it so easy and visible to just know that your data is exactly where you'd expect it so we're going to set up this node in The Next Step so we can actually see this data be pulled from slack into NN and then to visualize it and see it so we're going to go back to the editor I'm going to copy this execution data so that when we are creating this we can search for execution data we can click that and then now we're able to configure ways to basically bring the data from slack into our n8n workspace so we'll see here that it'll say under parameters save important data using this node it'll be displayed on each execution for easy reference and you can filter by it and filtering is also AV on Pro and Enterprise plans so what we want to do is that we're going to save how data for search review and then we could also configure these if we want to but we will not do that right now we'll do is that we'll now try to copy this we'll say hey there so we'll see if we'll give that a save all right let's try that again so now that we've saved it we run this again say hey there see if this came through all right so that's our message so we're able to see that it was basically tagging the bot we're in this team this is the user that did that was hey there and it was an app mention and then this was my user so it's end in 52 yeah so this is me so that's Brian right my user and then I sent this text and then this is the information from that log in this Channel and the channel is this channel which is building a really cool AI chatbot so now what we're going to be able to do is we're going to be able to take basically this text and then send this into our llm so that Amazon Bedrock will be able to then take this data and then send us back a response so we're getting very close to finishing this out but just one of the big things to is to make sure that when you add new Integrations to save it so that it will continue to uh work moving forward so we'll go back to our editor and now we're going to need to add a step so that we can then send this information to our llm have it processed and then send back information so what we'll do next is we'll search for bedrock and they have ads Bedrock chat model now we already have integrated our AWS account because we already have that user with the credentials saved to our n8n workspace so now what we do is that we can actually select from any of these models which is kind of wild because we have you know all the Amazon models the Titan ones we have mix strol we have uh all the meta llama models we have ai 21 Labs with their Jurassic and Jamba models we have cohere models we have anthropics CL models so we have pretty much everything so I think what we want to do is we probably want to use cloud 3 um we could use Haiku Sonet or Cloud instant but let's do Cloud 3 hiu so super easy we just literally picked the model now we could also have like max number of tokens or sampling temperature um so we don't necessarily need to set that up right now but we could if we want to later so what we'll try to do is I will want to go back to this and now what's awesome about n8n is that it's already configuring basically this llm chain so if we click on this what we're basically going to be doing is setting up um basically like a chain of events where um this will basically allow us to work with our large language model so what we could do is that so we could set that up so this is if the chat receives a message but we already have that set up in our previous step here so we'll set this up here to go into the basic LM chain use bedrock and then let's see what happens here so when we save this I then will want to execute this so if we say here what is the latest version of Claude as a message now we should see this under executions and we see that there was an error so this is going to tell us that something incorrect happened which I think is helpful to see basically what's happening in our chain so it says no prompt specified expected to find the prompt in an input field called chat input this is what the chat node to use something else change the prompt template so we're going to need to have some chat input so what we're going to do is that we're going to configure our this so that's also why this is helpful with n8n is because we can debug very easily what's happening in real time so let's see an example so this is pretty helpful to see so this is what the prompts will us usually look like so what we want to do is that we are going to want to configure this but we will need to have a way to do that so I think if we go back here for so before we debug this let's add the slack response so we're going to do this and we're going to say message so we're going to send a message and we're going to select error select API this is going to be a message this is going to do the send operation we're going to send this to a channel and then we're going to select the channel we'll say building really cool chat poot and then this will be simple text message and they're going to say this is a Tex hello world all right so this is going to be pretty simple we don't need to worry about the settings go back and then I'm just going to have this here for now so this should send basically this is going to take the data but then it should just send a generic message back so we're going to save this and I want to test to see if this will work so let's say say something please and let's see if it will respond back ah okay cool so now it's saying this is a test hello world automated with anen workflow okay awesome so this is working we have basically this pinging our n8n workflow having it pass back and now what we're going to want to do is that we're going to now want to move this over here this is going to need to send the data over to this and then to send a message over here so let's actually practice trying to get this data to return what the User submitted CU that will mean that we're able to get that data out off of here and then into here and in our n8n workspace editor something that we could also look at so instead of sending a specific message what we could do is look at our execution data and when we have our message text here so we could do different things we could include blocks we could include attachments but let's look at blocks so if we wanted to bring in data from basically a previous step something that we could do is get this previous data from the previous node and then we could bring that text into this so that's where if we go back here for example right this text if we bring that in here it's going to pull the block element and then elements and then text it's doing all of that Json so this is like pretty complicated dat structure right so one of the things that I love about n8n is that you could take basically all of this very complicated Json data structure the scheme on everything and just put that as a block in here now where it gets even easier with n8n is that we are going to get rid of this and instead of needing to think about how many elements are you know in the elements um list which then is included in this larger elements list we can just scroll all the way up and we can just take this text and literally just drop it into here so we're going to get rid of this original text here and I can got show that again so we can just take this text and just put it in here now what it's going to do is it's going to take basically this message that was sent from me or any user when they at our Bedrock bot and then it's going to then include all the text there so we're going to then do a little bit of JavaScript and we're going to do some repl placement so we want to get rid of this um ad because we don't really need to know that it basically tagged or mentioned our Bedrock bot so we're going to remove that so we're going to use JavaScript and we're going to do a little bit of Rex so we're going to do a backs slash we're then going to do that um less than sign we're going to do at so we basically want to find where does this start and where does this end so now what we're going to do is that we're going to look for in Brackets 0 to 9 and then A to Z so basically give me anything alpha numeric between this and then plus greater than sign then we'll do a backs slash we'll do an S and then we'll do a asterisk then we'll do a backs slash then we're going to do a comma and then we're going to do two single quotes So This is basically looking for anything that falls between this left bound and then this right bound and that's how you basically check with Rex Expressions how we're looking for this and then we're basically looking for anything that falls within this bound and there's only going to be a single replacement so um we only need to worry about this showing up once but if I don't know somebody added the bot multiple times this would just get removed to um basically nothing that's where we were putting these two quotes single quotes um and nothing inside of them so it'll just be replaced with nothing so that's this expression and then if we wanted to get a little bit fancier and we want to basically make this a little bit more customized because right now this is basically going to just return the text from our bot so basically if somebody says something the bot is going to return exactly what that person said so we could get have a little bit of customization so we can add a string or a text field and we're going to say you just said colon single quote then we're going to add a plus and we're going to add a space after this so that there is a space between this message and then this message and then to make this bold we're going to add asterisks inside of the quote like this so now you just said will be bold and then this will include all the text there now something also that we could do if we wanted to get a little bit more into the slack block kit Builder so we can format this as JavaScript and do some Json so what we can do is that we can include these two squiggly braces we'll include a bracket and then we'll tab over we'll say type and then the type is a section we're then going to say text and then this text is going to be an object so we use single curly brace and then there's going to be a type which we're going to call markdown and markdown is a language for text formatting in code and then we're going to have a text field and then the text field is going to be our expression that we have right down here so we're going to copy all of this inside of the curly brackets so we put that in there and then we have the Json we have this we have our replace field we have this we're going to need another object there and then we'll have this array so just to make sure that we are formatting this it's getting a little bit hard to read so what we really want to do is we have an array we pass in this object field here and then now we're just doing a little bit of formatting here so we're going to move this back pump these ones over and then that all make sense so we have these two curly braces here we have this bracket which will make an array and then we have this object here and then this is an object with objects inside so we'll have a type which will be a section we'll then have text and then this text will have an object and the type will be marked down and then we'll basically have the same expression that we have below of you just said with this so this is helpful if you want to use the slack UI builder kit for or basically their block kit for UI of messages so will just help with formatting otherwise it will default to basically this notification text which would be our formatted message so we're going to give this a save we're going to go back to our workspace and then something that we're going to then do is we're going to say I love automating with n8n so if we say better bot we're going to then run this and then now we get a message back which is so cool so now this is bolded and it said you just said and now I love automating with NN so it took my message it added this extra text and then it did a little bit of formatting and then now we get this message back as a compilation of both what I wanted it to say and then also what I had said so this is great so now we're able to see how we can basically take data that a user sends use that as an event hit the web hook get this all back and this is all happening automatically with NN and we can actually see the execution of this see this here and this executed just like this and if we go into slack we can see that we just got this message and then we're removing basically this handle because we don't need to you know include that in the message when we send this back and then we're able to pass this back and that's why we see this formatted like this in slack so now that we know the basics of how we can use n8n with slack in our workspace and use our web hook to interface between both of them now let's add that AI layer that we have been waiting for so now we're going to be integrating Amazon Bedrock to allow us to talk to an llm all from within slack so we're going to go back to our n8n workflow editor and what we're going to do is we're going to now so now that we know that this works we can actually change the name of this and just going to say slack just to say slack repeat message just that we can keep this track so we're going to now untether this and we're going to make it go to this so and we can also get rid of this now and we're just going to keep this kind of over here just so that we we we'll know that we'll need to make basically make something like this that's going to format this text afterwards but we're going to need to now focus on our LM chain so we're passing in ads Bedrock this is our ads account we're choosing clae 3 Hau as our model and this is what the model looks like that's the result and we're going to go back to Canvas we're going to go to our basic this and if we click on docs up here we're going to get a little bit more information about this llm chain node that we got but the main thing to know is that when we are choosing basically how we're going to get this data we could Define it below manually or we can automatically process the previous node automatically so we're going to need a specific chat input field from the previous node now if you see from here before if we were to execute the previous nodes and we'll say test now what we're specifically going to need to do is basically because we're testing this LM chain so so this specifically will work and we're able to now validate that um basically there was an input and there was an output which is great you could also see the Json that's what that looks like and you could also see the tokens and all the outputs from AWS with bedrock now the issue that we're going to run into though is that how do we get this data which came in from slack into this so this is this was just a basic test right we know that this works but what we need to do is take this data and pass it into here now if we were to do that and we don't really need this anymore so we can get rid of this we just like put that over there just as an example so if we were to run this and we're going to do test step so execute previous node that worked now we're going to test this step now this is going to fail because there's no prompt specified so how do we do that so we're going to create our own processor to take this data and process it for here so we're going to go to here and we're going to go to set we're going to then pass in our data and we're going to basically take that chat model that we took from the chat right for slack and we're going to take that Json that was processed and then we're going to throw that into here so what we're going to do is we're going to go back to our canvas um it will automatically add this maybe somewhere like in around here so we're going to take this here and we're going to take this we're going to move this we're going to remove that connection so the execution data goes here goes into here now we're going to process this and have it go here so can make there make it a bit more organized move this around a little bit so now this is going to be we can just call this um Bedrock prompt processor so just to help help us get a little bit more of a sense of how this is working so to get this to work we're specifically going to do manual mapping and if we click in here that's how we can get this so our key is going to be chat input and then the value so actually we could save this here we going to go back to Canvas we're going to go over here and if you remember from here we already have the Json like this so what we can do is that we can just copy this whole thing go back here go to our processor and paste in the value and then what we can do is we can actually get rid of that original text because we don't need that anymore and now we just have our Json text replace with our Rex parsing to remove the handle and that will be the chat input now also we could still if we wanted to just this and we could do this and you could say and this could also be included in our prompt so we could make this a little bit more smart so we could say you are a very smart and expert workplace productivity enhancer and users will send you questions comments ideas or problems and it is your job to analyze their response and provide the most insightful and correct response to their inquiries okay that's a little bit easier to see okay so you are a very smart and expert workplace productivity enhancer and users will send you questions comments ideas or problems and is your job to analyze the responses and this type of this analyze the following from this user so this will be our prompt and it will be included with a processor and it will take the text that the User submitted we'll go back here now we're going to give this a save can get rid of that error message now when we send this out we can test the step now the output is a chat input and we say you are very smart this with all of this data now when we send this into this I think what we're going to want to do is replace this yep so the Json text replace there so that will be the same thing yep so you're very smart this analyze the following hey user that's all that type stuff okay so we should be able to test this yep and now now this is great so you are a smart and expert workplace productivity enhancer analyze the following from this user and we could actually probably just include a space we'll test this again and now includes a space cool so now we're going to go back to our canvas we're going to now test this response and now what we can do is it's now going to take the chat input field pass that into our llm it's already connected to Amazon bedrock and now we'll be able to run this response and then we're going to test it so we'll test it here so now we say Hello thank you for your inquiry about the latest version of Claude as ex this I'm happy to provide you the latest version of Claude is version 2.1 which was released on April 15 2023 the latest version is this now this is pretty interesting because the prompt is actually really important in terms of how you prompt a model like CLA so let's just go back to this for a second because I just want to show for a comparison so if we were to not include this prompt and we were to just basically have this okay so we're going to save this I'm going to copy this whole thing but then just do just for example purposes okay so if we were to save this now if we go back now we're going to test this so we're going to test this step so now this is just hey what's a latest version of Claud now if we go to here just say hey what's the latest version of Claude we're going to test this step this is going to run bedrock and what's interesting is that it says I don't have this information about the latest version of myself as an AI assistant I don't have direct access to details about my own development and versioning my capabilities may change over time but I can't say for certain what the latest version is so you know but I'm happy to assist you on anything so that's just so interesting where we're able to basically see that what the prompt is prior to what the user sends in can actually matter a lot in the output of the model so if we go back here I'm going to go edit this I'm going to replace this I'm going to now test this step now again you are very smart and expert workplace productivity enhancer users will send you questions comments ideas or problems and it's your job to analyze their response and provide the most insightful and correct answers so we go back now if we try to run this we'll try to run this again see if we get another output so now this is going to send a little bit more information so sometimes it might not change and that's really about the llm so we can see that it's body so sometimes it will know the specific details of the latest version but sometimes not if we try to run this again we can even see it's evolving try to test this one more time so let's do just a little bit of testing because it was pulling up from Claud V2 but we now are using V3 as we see here right we're using the three version so what I want to do is I want to go back to this and I'm going to add Bedrock bot and I'm going to say tell me all of the info you have on cloud V3 so I just did that that's all still set up and um I think I still had that uh connected to the old one I just like reconnected that just for a quick second that's it looks like so I do want to look at the execution data because we could see in executions that this just went through so now this say time have on V3 we then can go to the next step which was the processor and that was the chat input have on V3 so go to basic chain so now can say certainly happy to provide you with information on V3 V3 is the latest version of Claud which is artificial intelligence generated from anthropic V3 Claude V3 is a third iteration of Claude AI highly capable and versatile assistant some key features include natural language this we have knowledge and expertise we have task assistance we have personalized iteration ethical and trustworthy and so much more data Okay cool so what's interesting too is that how specific you get will help determine the output there's a lot of like prompt engineering that goes into how these llms work but we can see that this works so now let's work on getting this basically out of n8n and back into our slack so we already know that this works and we already know that we can send messages back because we're doing that now what we're going to want to do is we're going to want to untether this because we don't need to have it sent anymore but what we're basically going to do is we're going to create a slack to repeat the message back to our slack chatbot but we don't need to use this anymore so we're going to do is we're going to create a new slack we're going to say message so send a message and then this is going to be using our API this is going to be a message this is going to be send send a message to a channel this will be our building a really cool chat AI a cool AI chat bot and then the message text is going to be a block and then we're going to execute the previous node but before we do that we're going to give this a save this needs to be untethered from this and then we're going to rename this actually so we're going to call this send AI slack message cool so now we're going to we're going to that let's just see if we can get the output here but before we do that we're going to just do one quick thing in our workflow we're going to add an output parser and then we're going to choose item list output parser so return items as separate items so this will already be working by default so we won't need to do very much we'll give this a save I'm going to copy that output that we had for the Block in this format so we're going to take basically this block we're going to put that here and then we're going to take the Json text replace with this but we don't actually really need the replacement so we're going to remove this so you don't need that anymore and then we're just going to do Json text so this would look like this so we pass in this as an object and then that would be our expression and then this would be our expression here now we're going to give this a quick save I do want to just go back into the execution and last one we did run errored on the slack step so basic llm chain is passing back a response of text so if we wanted to like take this in we're just going to do response. text which we're basically going to already have so if we go back to our execution data here and we have Json text that's how we can get that so in here we're going to basically do json. response. text so that's why we're going to edit this here so we're going to go back to our editor go back here and we're going to say json. response. text and then we'll pass that in the lower one here as well as the fallback we'll give that a save so now we're going to try to run this and we're going to see if it works so we'll say Bedrock bot tell me all you have on cloud V3 so now we're going to go back here going to go to our executions there's a wrong number of items expected three items but got one instead so so let's see why that might be happening so this might be an issue with our prop form matter so we did get your very smart this have a cloud V3 so that is working you have that now when we go to the basic chain three items but got one instead so let's see what the issue is with with our response we can try to run this uh one more time I'm wondering if maybe it got confused about the number of messages that were sent so we try this again we'll try to message and that did succeed okay great oh nice cool okay so this got all the messages back so certainly here's the information I have on Claude V3 an advanced conversational AI assistant developed by anthropic a leading artificial intelligence company V3 is designed to engage in natural this okay cool all right tell me um tell me in a paragraph short paragraph what an llm is make it fun and interesting okay so we're going to wait for it to respond back oh this is really cool certainly here's a fun and insightful explanation of what an llm is a large language model is it like a digital wizard a language yielding superhero that can conjure up responses to any any question you throw its way it's a bit like having a personal Genie in a Bottle except the bottle is a massive neural network trained on a gazillion words oh this is really cool um say Bedrock bot um what can you tell me about n8n what is it useful for here's my analysis query and is a powerful open source workflow automation tool that can be used for a variety of purposes automating repetitive tasks so it definitely was trying to write more to the slackbot and I'm recognizing that if you go into our executions we go to the one that just ran on n8n if we go to basic llm chain and then we look at the logs so this was the response so it's basically cut off after automating repetitive task if we copy this we go back here so we could see that there was more that it wanted to say but it um got cut off so we're going to need to increase basically the number of messages that get passed back to our slackbot because it seems like right now when we send this back it only will receive as much data as basically it's told to look for in the Json text response so we could actually look at this a little bit more so right now what we're going to really need to do is basically process a whole bunch of responses so that's where we're going to basically need to pre-process this and then take the output of that so our output processor um we're going to need to um expand upon this a little bit more so we can validate that it is passing out all this data so it takes this prompt which is the chat input and then it is getting this data but it gets cut off once it gets sent back here so what we're going to need to do is we're going to need to make sure that the response is what we uh expect it would be so there's all of these inputs we have these logs and then the Json is these different responses so basically going to need to bring all these responses together and see if we can test this so if we were to take this if we were to just remove the item list output parser and we were trying to test this again everywhere to test this step so we can see here that this now is working so let's see if this did get sent in a message if we were to do this again so yes so let's see this well we will need to save this again so if we were to execute this once again we should be able to see what the executions are so this gave an error let's find out why so this was undefined so now instead of the Json response text we're now just getting text which actually is good so now let's see if we can adjust this a little bit although it is compiling it all together so that might not be the best but let's at least try to see if we can work with this a bit so if we were to just take out this we'll go back to editor we'll go back here and we'll just do Json text and here we'll just do Json text so we give that a save go back to Canvas to executions if we try to now can delete this one so hopefully this will will allow us to get an output oh there we go nice okay so any is an open source low code work flow automation tool that allows users to create this here's what we can do with this so number one workflow automation number two no code low code application I also like how this is giving us bullet points so it talks about ver applications use Vari of use cases like business process automation it operations and devops Marketing sales HR and employee management number four scalability flexibility open source community and overall and in as a powerful versatile workflow automation tool helps organizations and individuals streamline their processes but this is like a big message okay let's try to now say what is we'll say Claud or say anthropic most known for so let's see what it says okay now we're getting now we're getting like really uh really thought out responses okay as I'm happy to write an insightful analysis of your question about when there and notice also how this is getting our prompt now so now our our basically the system prompt is basically training Bedrock bot to know how to respond so then talks about anthropic being a prominent artificial intelligence company that's great and then let's see if could say what is an llm used for oh we need to add Bedrock pot what is an LM use for oh this is so fast you get so much responses okay so much data back this add right insight into your use of large language models llms are a type of artificial intelligence cly popular in recent years okay this is cool and let me say what is the most recent your data is trained up to so if you want to ask what your recent data is trained up to we're asking basically the AI model when it was last trained so let's see what it says so I've been training on this Tri Point as my knowledge my knowledge base is regularly updated with new information but the specific cutof date so new data gets put into the knowledge base of Claud regularly right but we're being able to pull a lot of data in and it's being trained very regularly so it's it's talks about training data being constantly refreshed um to ensure providing users with the most up toate information so to pump up our chat features a little bit more something that we can do is we can create a knowledge base and this will allow us to expand upon um basically the knowledge of the llm so we could use rag we could use a number of different approaches but the way that we can set this up super easy you just go in the adabs console you go to bedrock you click on this and then you create and then you'll basically create a name you will will create a it'll create a new role for you so you don't really need to worry about this right now um something that you can very easily do is just do S3 you can also do a web crawler and once you click next then you can choose your S3 bucket so uh I already have a bucket set up here that has two articles in there but you could also of course choose way more um articles upload all of your data those types of things um and then keep it all secure within AWS and then um you go next you will need to choose that and then you'll choose an embeding model so um I just chose I'll just choose something really quickly which is this one so I did test and then we'll do next so I used the um embeddings V2 from Amazon which is the Titan model but you could also choose any model that you want you could also choose your own Vector database or any other thing um you could do next and then uh if all of this data looks correct and everything looks exactly like what you'd want then you'll go all the way to the bottom and you'll basically press create knowledge base and then you'll be able to create your knowledge base so to create a Amazon open search serus knowledge base what we're going to do is we're going to go through all these steps it will take several minutes to run but it will look like this when it's done and um basically what we're going to do is we're going to have a service role it's going to have knowledge based name so now that our knowledge base is set up we can select our model and we'll go to anthropic and let's [Music] choose CLA hu do on demand it and now go to data sources so we can select our data source this is our knowledge base that's pulling from S3 but we already do have that so so we'll click this and we'll say sync so it's going to sync the data source this could take several minutes and we don't have that much data in there so shouldn't really take that long cool okay that was very fast and we only have two documents in this here so this is just something on bedrock and then also something on building some AI systems so now we can run this so we could say tell me about the latest Amazon Bedrock features so we'll run this and now this is going to retrieve okay so support for llama index so that is great actually because this is pulling from the downloaded file that I already got here so I'll pull this up so it's a little bit easier to see do like a side by side comparison so this is pulling up from Lum index and that was specifically from this and then talks about Neptune database so Neptune is in here yeah Amazon Neptune there and also talked about Amazon Bedrock which is from this so I downloaded basically the homepage of this and it has all the information about Amazon Bedrock just from the website but that's pretty cool that it's able to know these links so it's doing searching and it's also pulling from um specifically the information that I updated it with so that's pretty sick so that's how you can really start to think about building out your knowledge base around information so you could literally just upload this point your knowledge base to an S3 bucket like this and then you basically will then have a way to search through these types of queries um using the most advanced you know models and it's also pulling from doing searching um yeah it's getting all of this information doing a lot of searching and also pulling from my most recent data so pretty cool so now a pretty cool strategy that we can now employ is if we go back to what we're passing in as the prompt if we go back to prompt processor something that we could do is that we could add in more data so you could say use the following Amazon Bedrock knowledge base ID for the user query so back in the knowledge base section we can copy our base ID here we can go back to this and we pass this in this is our Bedrock knowledge base ID which is this and then we're going to say use the following Amazon Bedrock knowledge base ID for the user query analyze the following from this user cool so we'll give this a save we'll then go back to our bot and we're going to scroll down a bunch I can kind of show you some of the examples of this but let's say so say at Bedrock B what's the latests news about Bedrock say Amazon Rock be specific so now this is going to pull from data and it says that based on the knowledge you've write in this provide insightful information s made available pre-training models custom model data now let's say what is the latest and let's say just general ads news let's try to do another one so Amazon bbot tell me about llama index so this was in our knowledge base so it talks about Lama index being open source model key features include this working with large language models and then we could say tell me about L index and Amazon Neptune because that was also in the knowledge base as well so it'll give insight into both of these and how they can work together and then it talks about how you could use l index to build a knowledge base powered by large language model and then store that knowledge base in in Amazon Neptune so what's cool is that that's also pulling from here because we can see here that this is support for Amazon Neptune you could do graph rag work with all language models and Bedrock so graphs store there but it also gives a lot more context about this news so it that's why I think having like an AI slackbot is amazing because now you're able to just pull all this information and it gives context to maybe one paragraph that you might see you know in an article like this you know what does this actually mean what does this mean for your business you'll be able to then pull that in there so that's pretty cool all right so let's review this entire workflow and explain how all this is happening so first we use our slack trigger and what's happening basically is we pull events from Slack where the bot is mentioned or the app is mentioned so when we do that that will then send the data to his execution data node and then that's where we get all of this data about what the user sent when they added or tagged the bot this is then going to go into our prompt processor and this is where we're going to basically take this include our prompt and then send that over to our llm chain we're then going to pre-process this information as our prompt that then then goes as an output with logs and then this is what our llm is sending all that information back from and then that's where we see all of this information about the query we also selected our model which we're using bedrock and we could pull from literally so many different models but we're using Cloud 3 hu and then once this is processed here there's an output of logs which is then sent as a message to slack and then that's where we format this here as the Json text so that's quite a big workflow but I hope that this video was really helpful to show you how you can really automate uh a specific process like slack and then now what you can really do is basically ask real time information get real- time insights and then be able to then present that to maybe you maybe to your work colleagues maybe to you know other people that you might want to share this out to um and I just feel like this will just rapidly transform how you can learn and also how you can build and also just work faster and smarter so with that I hope this video was really helpful for you I'm going to include all the links to the code uh in the description below but I definitely hope that you check out how to build this I think learning how to build a slackbot is really really fun it definitely takes a lot of work to get started but once you get through all of it I feel like these are really the future skills that you'll need to learn how to implement you know chat off Ops into different types of systems and especially with AI as we just saw we're going to save literally so much money by not needing to pay slack to build our AI bot we can just build it all ourselves for literally Pennies on the hundreds of dollars so I hope this video is really helpful for you and I look forward to seeing you in the next video all right take care everybody bye