I Automated my Instagram with AI Agents - CrewAI Hierarchical Tutorial (Instagram Automation)
Key Takeaways
This video demonstrates how to automate Instagram using AI agents with CrewAI, a tool that overcomes ChatGPT's limitations by creating crews of autonomous AI agents, and utilizes GPT 3.5 Turbo for better results and cost-effectiveness. The tutorial covers the hierarchical process of Instagram automation, including product analysis, competitor analysis, ad campaign development, and photography planning.
Full Transcript
these are three Instagram posts I generated with my crew for the Galaxy watch 6 they aren't perfect but I think they are pretty impressive if you consider that it took just a link to the product page of the watch and it was done in about 1 minute and cost about 2 cents of open AI credits let me walk you through how I did it I made some changes to my crew setup that made it work so much better and quicker and cheaper than in my previous video be sure to watch my previous video on crew AI to be up to speed in the other video I explained more of the basics and here I will go into some more details but I will give you a very quick review here anyway I'm trying not to repeat myself too much here but basically crew AI allows you to create Crews of autonomous AI agents that take generative AI tools like chat GPT to the next level big limitations of Chad GPT include the lack of knowledge of current events the inability to multitask the necessity of tedious fine-tuning for complex tasks and the inability to work with long texts here is a list of these and other limitations of working with chat GPT crew AI basically gets rid of most of these limitations by instructing a team of autonomous AI agents to collaborate on a larger task for you being able to use all their chat GPT Power Plus collaborative efforts and feedback loops and access to current info from the web to come up with really mind-blowing answers on their own in a fraction of the time it would take a human even equipped with chat GPT we talked about the sequential process last time today we will talk about the even more powerful hierarchical process which with a the few tweaks gave me truly amazing results first I wanted to run the crew with a local olama model that's simply a large language model hosted on my own laptop avoiding any usage costs with open AI when experimenting I quickly learned however that any model I can comfortably run on my own computer resulted in pretty terrible results so then I switched over to GPT 3.5 turbo which is much cheaper than GPT 4 and I got pretty amazing results right off the bat in a fraction of the time it took the local model I wanted a setup that's a bit more complex than in my previous video where I only had three agents in a single sequential crew so I cloned Jon's crew AI examples repo and made adjustments to his Instagram post example a note on dependencies again this is always a bit tricky and I don't want to waste time in the video on that and there are also a lot of resources out there already both on Google and YouTube If you need a video on that in the future just leave me a comment because I wanted to use some of the newest features of crew AI like the hierarchical process I couldn't use the dependencies as they are in the Poetry lock file in his repo but instead needed to upgrade crew Ai and some dependencies so this is the setup for the two Crews for the current project the overarching goal is to create an Instagram advertising strategy which includes three post ideas about a specific product you're going to provide a link to the product online which it will then use for all of its research so the subtasks are product analysis so you provide the link to the product it will then go online research the product all the features and specifics about the product it will then do a competitor analysis find the top three competitors in the market and the competing products it will then develop an ad campaign and strategy it will then go and actually create the actual ads for the actual Instagram posts providing three options with an ad text that can be used to then plan photographs with the next subtasks is photography planning where the agents will provide you with a description for a photograph that you're supposed to take and finally the last task is to review the photographs the tools for all the agents are website access and scraping Google search and Instagram search so all of the agents in two different Crews will have access to these three tools for this project I created two Crews so there's first the ad copy crew which is a hierarchical crew which has a manager llm the manager can just delegate tasks to its three agents and specify when each agent is supposed to do what and you don't really have to think about this crew aai takes care of the manager for you you just have to say you want a manager involved and that's it you just Define these three agents the lead Market analyst the chief marketing strategist and the creative content creator which will perform these four tasks in Orange here and then the output of this which is the ad campaign and the three options for the Instagram posts will be handed off to the photography crew which is a sequential crew just like we have had last time the photography crew has a senior photographer who decides on the initial ideas for the photographs for the ad campaign and then the chief creative director who will review these photograph ideas okay so let's look at the code we're going to run so this is the folder this is basically a copy of the Instagram post um example from Jan and the structure the file structure is exactly the same I just changed some things in the files which I'm going to walk you through so first of all make sure that in the EnV file you have your serer Dev API key and your openai API key if you don't know how to get those I have a video on that so check that out next thing we're going to do is look at the main.py file which is here so most of the basics are the same as in the last video we will use the N library to load our umn file like the package name says and get the API keys that we need to run the tools we import all the important um agents and tasks that we create in the tasks and agents py file which I'm going to walk you through after this here are the prompts for the command line so basically all that the crew needs is the product website of the product we want to create a marketing strategy for and any extra details you want uh the crew to know about the product here we basically instantiate the uh three agents I'm going to walk you through um the agent um description after this here are the tasks so we have four tasks and this is the first screw we're going to create so we're calling this the copy crew and just like last time we're just simply passing the Agents of the screw and the tasks for the crew into the into the crew we always set verbos to true because we want to see what's going on and here's the important difference to last time we specify a process so for this we have to import process up here from crew AI we import process and we specifying a hierarchic process if you do use the hierarchical process and not the sequential process you need to specify a manager llm and here as I said I was playing around with local L&M before but it was a disaster so I decided to use um jgpt again but uh version 3.5 turbo which is quite a bit cheaper than gbd4 but will probably also give you worse results but the results were really good I think so um yeah you can try to change it to gbd4 and see if the results are better but if you're just playing around with it I suggest using 3.5 just because it's a little bit cheaper um memory equals true basically gives the crew a memory and a short-term and long-term memory um for the context of their task and do um supposedly makes the crew work better um so there's something else to play play around with here's another parameter you can play with the temperature so the temperature goes from 0 to one as far as I'm aware and zero gives you more reliable answ whereas one gives you more creative answers but you can set it to any value in between so if you want something more creative you might want to set it to 0.6 or 0.8 or something so something to play around with but for this tutorial I wanted to set it to zero to get more reliable answers and then you kick off the crew so this is the crew that creates your ad copies and the marketing strategy and so on and now we're doing the same thing for the second crew so right after we're creating the second crew with the photographer and the creative director um and the tasks to take the picture and approve the picture um same thing for instantiating the crew we're passing the agents and the tasks to the crew but we don't pass uh process equals hierarchical or the manager llm because this crew is now sequential because there's only these two people and this agent will just review the um photos of the photographer and then we kick it off and print the results so this is it for the main.py file now let's look at the agents so here are the agents and basically same as for for the manager llm we can specify a agent llm and each a each agent could technically have a different llm but we're using 3.5 as well um as you saw I was playing around with AMA models before so we have the product competit uh product competitor agent so this this guy or this girl is conducting a analysis of the products and the competitors and we're providing a backstory to train the llm to know what kind of agent they're supposed to be importantly you can always make these prompts better so this is kind of a lazy you know lazy description for this agent but you can describe a little bit better what you want from this agent and your results might get better we're passing some tools so there's a custom tool that John made for this Instagram post example crew but I didn't have good results with this so I'm using just the web search and the serid dev tool that come out of the box so here are the um the two tools I'm using and they're just in the crei tools so if you install crei tools you will have these tools but obviously you need to have your Ser Dev API key for this and then here are some settings um that you can play around with so verbos equals true I would always set to see what's going on and um here you can set your llm so I Define it up here as gpt3 and then I set this to four so I think the default is 25 the max iterations so until the agent has to decide and give you an answer and it I think the default is 25 but I had especially with the uh models I had some of the agents just like take forever so I set it to four and I was much happier with this so um play around with this if you want and allow delegation equals true just means that if the agent thinks the tasks is better solved by someone else they can pass the task to someone else which is very useful um same thing for the chief ma uh marketing strategist so this is the uh person that creates the marketing strategy with a goal in a backstory um we talk about the T asks later so this person has the web search tool but also search internet and search Instagram custom tools which I'm going to show you now so we can go into the tools folder this is a Custom Tool in search tools here that Jean wrote up so the search internet tool is basically just a Google search so this is this is using uh serd as well and then so here you can see it's just using the serd tool and searching for you know your queries and the Instagram one in particular is uh just a Google search that uh that just searches Google results from the site instagram.com so it's like an Instagram search um so those are the tools you can you know use them as they are or you can program your own tools if you need to um and then let's go back to the agents file so yeah so we have we have discussed the strategy planner agent and the the parameters you can play with are the same so you can change the llm you can change Max iterations and allow delegation is true is I think always a good choice um we have the Crea creative content creator so that person is creating the actual posts so here here is the goal for that agent and then the backstory for that agent that describes the kind of agent they are the tools are the same as before and the parameters are the same as before for the next crew we have the senior photographer who is supposed to take these amazing photographs and a backstory for that person again play with the prompts to make them behave even better um but I left them as they are these are Jean's descriptions from the original Instagram post crew and then lastly we have the chief creative director that is just reviewing the photographs taken by um their team and the team in this case is just a senior photographer that's it for the agents let's go to the tasks and yeah here here's where most of the magic happens this is really describing the different tasks for the different agents so um here is the English text description for what this uh agent is supposed to do analyze the given product website and this is where most of the magic happens right so we pass the product website to the agent and we give it the extra details that we provided so in our case this was just like bestselling watch uh perfect for traveling or something like this and then it's supposed to look for the unique features the benefits and the overall narrative and it can you know look on the website and on Google and on Instagram for these things um your final report should clearly articulate the product's key setting points and so on um importantly for the latest version of crei or at least the version I'm using it is expecting an expected output parameter so here you you just describe the what the output should look like um basically your description of the of the output of that agent of that task um same for competitor analysis explore the competitors off and then here's the product website extra details provided by the customer and then um you know your expected output your final report must include both uh the context about the website and the detail comparison to whatever competitor they have in competitors um and I just specified that it must be the top three competitors because you could you know technically come up with a long list but you know change the prompts if you need more competitors to be analyzed then um campaign development task um you created you're creating a targeted marketing campaign for the product and the expected output is just a step-by-step campaign idea for Instagram but again you can be much more clever than me in describing the expected output uh Instagram ad copy is CRA uh crafting the actual post copies for the Instagram posts and again uh describing the expected output so we want three options for an ad copy for Instagram um and yeah so be more creative when writing your prompts than me but this is just for the purpose of this tutorial not to create per perfect a perfect ad campaign the photographer agent uh is getting the task of taking the photograph and then here are some examples of what this should look like this is to to pass on to an a generative AI to create these pictures so it's good to give some examples of what these descriptions could look like yeah basically write down the um expected output with three photographs that correspond to these three ad copies that we created with the other crew and then lastly we have the task of reviewing the picture again describe um what you want the this agent to do and the expected output with the three options of um photographs with a paragraph describing the photograph to be generated with Gen generative Ai and some examples okay so let's now run the crew this is the folder on the command line so those the files in there the main file the tasks file the agents file and the tools folder and I'm going to simply run the crew by typing python Main py and I decided to run this crew to create an Instagram ad campaign for the Galaxy watch 6 I'm not getting any kickbacks from Samsung this just an idea uh so I'll paste the link to the product here and then some sentence about the product the bestselling smart watch in the world perfect for travelers and let's see how long this takes okay so the crew is now done let's go through what it did and look at the results together so let's go all the way to the beginning so this is really nice because you can really figure out what's going right and wrong okay here we go so it basically we gave it the company or the product website it went there and found out about the watch itself um did some online research about the benefits about the features and so on um which had wrote down here and then it kind of like you know went looked for news articles about the watch and everything you know about the potential audience for our ad campaign and basically yeah all the det details about the watch then it went on to look for um competitors of the watch so here it found out the three top competitors for the watch the Garmin venue 3 the Apple Watch series 9 and the Google pixel Watch 2 which um seems plausible to me I don't know anything about SmartWatches but those seems very plausible and then the next agent figured out the pros and cons of the different competitors and so on and then it designed an ad campaign for Instagram and this was passed on to the next agent that created the actual Instagram posts so here are the three options that were then reviewed and passed on to the photographer who designed the descriptions for the photo shoots and um here is our final answer so this is the copy po the post copy for the three options here the descriptions of the three photographs that go along with these posts which we can then copy into mid journey and or Dolly and or adobe Firefly or similar generative AI programs to generate these images that go along with the post to then post on Instagram so here are the three Instagram posts generated with this crew with my current settings just took about a minute for everything from product research competitor analysis marketing strategy development ad copy and photograph planning I paid two cents in open a ey credits each time I ran it things to play with to get results more to your liking are upgrading the llm to GPD 4 for example which will cost more money playing with the temperature to get more creative answers Max iterations and of course you know playing with your prompts for the different agents and maybe even the crew setup itself you will of course need a serer Dev and an open AI API key to run the screw if you need help getting your key or cloning a repo from GitHub make sure to check out my other videos on the topic see you next time
Original Description
Automate your Social Media with AI Agents - CrewAI Hierarchical Crew Tutorial (Instagram Automation)
In the last video, I showed you the power of AI Agents by introducing you to the powerful new tool Crew AI, which gets rid of most of ChatGPT's limitations by creating crews of autonomous AI Agents.
As requested by many of you, this video goes into a more complex task for our crew: Instagram Automation! More specifically, automatically generating a Social Media Ad campaign for Instagram. This included Product research and competitor analysis, the development of a full ad campaign for instagram, generating three optoins for instagram posts including images.
I am creating two separate crews for this: A hierarchical crew with a Manager LLM that takes care of the Product Research and Competitor Analysis, Develops the Ad Campaign Strategy and the three post ideas.
The second crew - a sequential crew - is designing three photographs to go along with these three posts.
I will describe the crew setup in detail and take you through all of my code, before running the script with you and looking at the results together.
I played around with local LLMs (Ollama) but ended up going with OpenAI's GPT-3.5-turbo in the end, because it gave much better results.
If you have foundational Python skills, are able to clone a repository from github and know how to use ChatGPT, you should be able to follow along.
Resources:
CrewAI website: https://www.crewai.com/
Joao’s CrewAI github repo: https://github.com/joaomdmoura/crewAI
Example crews and templates: https://github.com/joaomdmoura/crewAI-examples
To follow along just clone the crewai-examples repo and make a copy of the Instagram post folde and change the files in there.
You will need an OpenAI API key (https://platform.openai.com/) and a SerperDev API key (https://serper.dev/) to run this crew.
To install crewAI & tools:
pip install crewai
pip install 'crewai[tools]'
Use Artificial Intelligence and AI Agents to automate w
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Infinite Codes · Infinite Codes · 12 of 39
1
2
3
4
5
6
7
8
9
10
11
▶
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Why Python is the BEST programming language (Top 10 2024)
Infinite Codes
The Most Fun Programming Language for Beginners!
Infinite Codes
Why Python is the Hottest Programming Language
Infinite Codes
How to delete a repository in GitHub (2024 updated)
Infinite Codes
How to get OpenAI API key / ChatGPT API key (2024 updated)
Infinite Codes
How to clone GitHub Repository (2024 updated)
Infinite Codes
How to Clone GitHub Repository in Visual Studio Code (2024 updated)
Infinite Codes
How to Push Code to GitHub from Visual Studio Code & Create a GitHub Repository (2024 updated)
Infinite Codes
How to Push Code to GitHub on the Command Line (2024 updated) - with Authentication
Infinite Codes
CrewAI Tutorial: Automate your Life with AI Agents
Infinite Codes
Automate your Life with AI Agents (EASY CrewAI Tutorial)
Infinite Codes
I Automated my Instagram with AI Agents - CrewAI Hierarchical Tutorial (Instagram Automation)
Infinite Codes
How I’d learn Machine Learning & AI in 2024 (if I could start over) -- 7-step Roadmap
Infinite Codes
How to Create an EC2 Instance in AWS in 2024
Infinite Codes
How to connect CrewAI to different LLMs (GPT4o, Groq, Llama3, Ollama) - Tutorial & LLM comparison
Infinite Codes
How to Learn Machine Learning in 2024 (7 step roadmap)
Infinite Codes
How to Use Ollama in 3 minutes - Run LLMs locally for FREE (LLama3 & more)
Infinite Codes
How to get a Groq API key - Run LLMs for FREE (LLama3 etc.)
Infinite Codes
What is Groq? - 30 seconds
Infinite Codes
Perplexity AI Tutorial: Why you don't need Google and ChatGPT anymore
Infinite Codes
All Machine Learning algorithms explained in 17 min
Infinite Codes
How Math makes Machine Learning easy (and how you can learn it)
Infinite Codes
15 Machine Learning Lessons I Wish I Knew Earlier
Infinite Codes
Learn Machine Learning Like a GENIUS and Not Waste Time
Infinite Codes
All Machine Learning Concepts Explained in 22 Minutes
Infinite Codes
All Machine Learning Beginner Mistakes explained in 17 Min
Infinite Codes
Neural Networks in 100 seconds
Infinite Codes
Generative AI in 100 seconds
Infinite Codes
GPTs in 100 seconds
Infinite Codes
22 Machine Learning Projects That Will Make You A God At Data Science
Infinite Codes
Transformers in 100 seconds
Infinite Codes
THIS is Why Machine Learning Is Hard For you
Infinite Codes
Deep Learning in 100 seconds
Infinite Codes
30 Machine Learning Facts Most People Get Wrong
Infinite Codes
Gradient Descent in 100 Seconds
Infinite Codes
Computer Vision in 100 Seconds
Infinite Codes
Reinforcement Learning in 100 Seconds
Infinite Codes
32 Machine Learning Facts That Make No Sense
Infinite Codes
What is Machine Learning? Your 2025 Guide to the AI Revolution
Infinite Codes
More on: Multimodal LLMs
View skill →Related Reads
📰
📰
📰
📰
When an AI Starts Talking to Itself: The Birth of Self-Awareness
Dev.to AI
RAG vs. Agentic RAG vs. Graph RAG: Which One Actually Fits Your Use Case?
Dev.to AI
Understanding Token-Based Pricing for LLMs
Dev.to AI
Honesty Theater: Why Disclosure Reliability in LLM Guardrails
Dev.to · correctover
🎓
Tutor Explanation
DeepCamp AI