Transcript for:
Building AI Agents with Make.com and OpenAI

in this video I'm going to show you how to create an AI agent using make.com and openai assistance we'll be able to have conversations with this agent via telegram but you could also use WhatsApp slack or lots of other triggers this agent will be able to post to social media and before it does that it can research topics using perplexity and also generate images using flux one that might all sound very complicated but we're using a powerful feature in open AI assistance called function calling where we can create really simple separate scenarios such as a research tool and image tool this is our simple image tool where it goes to flux one and this is our simple research tool where it goes to perplexity when the agent gets our approval to post it of Facebook we use this simple scenario which uses makes's internal Facebook app to publish it directly I'll explain how to set up the assistant afterwards but let's just start with a demo and if you want to get way ahead in your AI automation Journey then check out the link in the description to our community we'll get access to all of our automations including the one in this video I'm going to ask it to create a Facebook post about deep seek V3 so while it's doing that what it's doing is we've sent the telegram message it's hit or main make.com scenario then it's called this open ey assistant we're expecting it to request this research tool which is this perplexity scenario it's researched this topic and has now come back with a draft Facebook post within the assistant we can tweak the settings to write in our tone of voice but in this case we can have a back and forth conversation to get it to refine the output so I can ask it to make it more casual okay so this is far better saying deep seek V3 is shaking things up in the world of language models with a whopping 671 billion parameters and so on that's a much better post I'll say that's good okay now it's asking me would I like to generate an image to go with the post I'll say yes now it's likely that the open ey assistant will choose to use our image generation tool scenario and then it'll come back with the result from that perfect here's a generated image to accompany your post that looks good but let's just say I want to create a different image looks good but I'd rather use an image of a robot at a computer desk there we go the opening ey assistant has interpreted that that we need to generate a new image so I'll say that looks good finally it says awesome are you ready to publish this post to Facebook with the text and image provided I'll say yes perfect there we go we have the text and the image directly uploaded to Facebook let's dig into this design pattern because once you understand how this works you can create agents with lots of different tools that can do lots of different things while keeping your make.com scenarios very modular and easy to understand once we send a new message it triggers the make.com scenario and that is this main scenario we have here this is a telegram bot that's just watching for updates and it's using an instant trigger so this will run instantly when the data arrives and it does not need to run on a scheduled basis that's searching a data store to get the thread ID for the openai assistant I'll explain that a little bit later the magic for orchestrating this agent is the openai assistant here I've selected social media agent the easiest way to create this is to go to platform. open.com and go to assistants and just create a new assistant you simply add in the name of the assistant then you provide system instructions you can make these pretty detailed for example you're a Facebook posting AI agent designed to assist users with creating and posting content Your Role involves guiding the user through a structured workflow to create and publish Facebook posts you want to provide clear rules for the agent to follow but you do not want to make the rules so complicated and convoluted that might confuse the agent and might make this difficult to adapt to other use cases or difficult to update in this case I'm simply asking to generate draft text for a social media I'm asking it for feedback when it's happy you should ask for an image but it's optional if an image has been generated ask for feedback when finish ask the user do they want to post anything else this is a general operating procedure for what it needs to do I've added in a general tone of voice but you can also be far more specific with this and I've given some Specific Instructions such as to understand the user intent we want to determine whether the user wants to research and draft a pulse or to draft a pulse directly from the text so you can ask this agent to research for which it's going to use this research tool or otherwise you can get it to bypass that entirely and you can pause the video as you see here I've mentioned these research tool image tool Facebook posting tool but where does the connection actually happen I'll click save and down here you see these functions these functions are going to trigger simple make.com scenarios so for example the research tool is going to use this simple perplexity scenario where we're using web hooks so there's a web hook at the start it's waiting for the incom in data it's going to trigger perplexity then it's going to respond back to whoever called it with the data so let's go into it this might look a bit intimidating but it's actually not that difficult once you can work from their examples if I was recreating this two from scratch go to functions click generate and then function name should be research tool and input parameter it's generated that perfectly it's research tool that is a name a function to process the query that's going to just pass in this query opening ey assistant is going to get make.com behind the scenes to call this scenario it's going to provide the query as you see here and the query is what we defined there which is this query so it might look a bit complicated but it is pretty easy to set these up once you know what you're looking for for image tool we have image tool our description that we've just added the parameters the only parameter is prompt that's the only difference between the last tool that we use here and I just added in a description there finally for the Facebook posting tool again name is Facebook posting tool description in this case we have two parameters we have text and image URL you could also add in a link URL here but you could get open AI to generate that code for you or paste this into chat gbt it would do the same thing now because we've added these functions within the openai assistant when you add in this message and assistant module Within make.com These functions autop populate so we have this research tool the image tool and the face Facebook posting tool and we can hook these up to our other scenarios such as the post of Facebook go to this we can copy the web hook and then we've copied the web hook there I really like make.com integration with the openai assistant on how it calls these tools because I can make this diagram pretty easy like so and we can just pretend that it's calling these research tools AI image tool Facebook posting tool directly because it all happens behind the scenes within this one module because we've added these web hooks here in reality once we're sending a message via telegram to get it to research a topic it's going to go to the main scenario go to the openai assistant the open AI assistant behind the scenes actually goes back to the make.com scenario it says I need to use the research tool behind the scenes make.com will trigger this web hook which then triggers this scenario it gets the result from perplexity and returns this web hook response and then it Returns the web hook response from this research scenario back to the openai assistant it's a pretty complicated recursive relationship the open a assistant can call multiple Tools in one go so it could say I want to research but I also want to generate an AI image we could ask it to do both at once when it does that it's going to go through this scenario behind the scenes multiple times but all we need to do is just wait for this assistant to finish processing it will send the result back to telegram a great benefit of this design pattern is that we can reuse these tools across lots of different agents because they're just simple scenarios within make.com in our community we have the concept of micro templates where we have lots of these kind of smaller scenarios in this case they are agent specific microt templates because they have an incoming and outcoming web hook that we can call from our agent platforms these are not just applicable for openai assistance if you're using a different agent platform like relevance. a or lots of others you could use the exact same scenarios because you can call these web hooks from anywhere if you don't use function calling you could have everything in one scenario but that results in a spaghetti of nodes of routers of filters and then it's not easy to reuse these across scenarios and it's very easy to make mistakes and get messed up in your logic within our main scenario I have two more things I'd like to show you you may be wondering how we handle the chat history within this agent and this happens within this message and assistant when you create an assistant you pass a thread ID and that ID is what you see here we're using a data store to store this data so if you do not have one set up go to data store click and you can choose a data structure in the data structure you can type Channel ID add item and add item and get your thread ID and click save the first time an authorized user sends a message through this the thread ID is going to be blank so it's going to pass nothing here that's effectively a new conversation at the end of this flow we're checking to see if the thread ID is blank if it is it creates a new data store item that's the channel ID so this is the telegram Channel ID and the new thread ID that's been created by openai the first time that's been wrun it will go through this entire flow the second time it runs a scenario it'll go through this it's going to search the data store to see if a record exists for that channel ID if it exists then this thread ID is not going to be empty so we're going to pass this into the openai assistant so then it will have the context of the conversation history and then because there is a thread ID this filter will be false and it will not add or replace the record in the data store so that's a very simple use case of how you can use a data store to store something like a thread ID without having to have routers and extra filters and things like that in place the last thing I've done is to add in a router after an error Handler so to add an error Handler right click and select add error Handler I've added in a router and it's going to check to see if the run is in progress so if we got an error back from open AI assistant such as can't add messages to this thread while a run is active that's because when you send a message to the open assistant and if it calls an external tool such as po to Facebook or call in or research scenario then it locks that thread or that conversation I have a pretty primitive filter in here to check the error message to see if it contains Wilder run is active if it does it's almost definitely going to be for this reason if so it's going to respond this to telegram I'm working on a response to your previous message hold tight and I'll get back to you shortly please wait before sending another message otherwise if that's not the problem it will just relay the original error message back to telegram if this is a customer facing agent you probably do not want to do that but because this is an internal agent it's handy to do it because if errors show up then I'll be able to quickly diagnose it directly from telegram you could use this design pattern for so many different types of workflows in your business or for your clients we're going to have a lot more AI agent content in this channel coming soon so make sure to hit subscribe to stay in the loop and if you want to get way ahead in your AI automation Journey then check out the link in the description to our community we'll get access to all of our automations including the one in this video we'll be greatly expanding our micro template section in the community to include lots of modular scenarios that you can easily call from your AI agents you'll get instant access to all of these courses with more on the way you can get Live support from us directly via our live workshops or via our active Community thanks for watching