Boost Your Small Business ‘Crew’ with ‘AI’-Driven Agentic Workflows

Lakshmi narayana .U
13 min readMay 31, 2024
‘AI Pioneers Chart Digital Treasure’ — image by author and DALL.E-3

Artificial Intelligence (AI) can help small businesses improve their operations. AI expert Andrew Ng is a big advocate of Agentic Workflows that uses AI agents to improve work processes. These agents learn and improve on their own, helping to increase productivity and efficiency. This new approach can be used in many areas, such as project management and research and development, changing the way small businesses work and succeed.

CrewAI, employing Agentic Workflows, is a good tool for small businesses. It allows for the creation of autonomous AI agents, assigned with specific roles and tasks, who work collaboratively in “crews”. This system enhances efficiency, automates complex processes, and drives innovation. By integrating with external services, CrewAI can be applied across various domains, automating operations and facilitating growth..

In this article, we will examine a use case involving “LN Consulting,” a hypothetical small business consulting firm, and explore how it can effectively utilize CrewAI.

Before we dig in, a brief intro about CrewAI…

Understanding CrewAI: Key Concepts, Features, and Practical Applications

CrewAI is a framework that enables the collaboration of autonomous AI agents in a team-like environment. It revolves around key concepts like agents with specific roles and abilities, well-defined tasks, and groups of agents known as crews. CrewAI supports various features including role-based agent design, autonomous delegation, customizable tools, process-driven task execution, and integration with external services. It’s particularly useful in areas requiring complex collaboration, such as project management, research and development, and content creation, enabling automation, enhanced decision-making, and innovation.

Do check out my previous article here.

Recently, the founder of CrewAI — João Moura — launched an insightful course on the deeplearning.ai platform. This educational offering explores the intricate workings of CrewAI, providing an in-depth understanding of its structure and functionality. The course is meticulously designed to offer comprehensive knowledge about key CrewAI concepts, its unique features, and how it facilitates collaboration among autonomous AI agents. It is an invaluable resource for those seeking to explore the potential of CrewAI in automating complex tasks and enhancing decision-making processes. Whether you’re a seasoned AI professional or a curious learner, this course promises a wealth of information on the dynamic world of CrewAI.

This article highlights the following important learnings from this course and applies them to a use case.

An agent asks questions and receives answers, going through iterations that we typically initiate. So, if a chatbot involves us asking questions to an LLM and then iterating, an agent is something that we commission to do the same autonomously, thus freeing us from this task.

Source: “Multi AI Agent Systems with crewAI” course at Deeplearning.ai

Tasks and agents should be granular and focused on one specific thing. Tasks can be executed in different ways, such as in parallel(asynchronous), sequentially, or hierarchically.

Source: “Multi AI Agent Systems with crewAI” course at Deeplearning.ai

There is a very high correlation between being a good manager and the ability to create great multi-agent systems, as managers are conditioned to think about the goal and the process.

Source: “Multi AI Agent Systems with crewAI” course at Deeplearning.ai

Tasks should have clear descriptions, and clear and concise explanations. CrewAI emphasizes two attributes: description and expected outcome. All the above in bold red are supported by CrewAI

Google Serper Search CSV RAG Search Code Docs RAG Search
Scrape Website XML RAG Search Youtube Video RAG Youtube
Directory Read JSON RAG Search Channel RAG Search
File Read Docx Rag Search
Selenium Scraper MDX RAG Search
Directory RAG Search PG RAG Search
PDF RAG Search Website RAG Search
TXT RAG Search Github RAG Search
...and many more CrewAI tools...

Usage of CrewAI tools and creating custom tools using BaseTool class


from crewai import Crew, Process
from langchain_openai import ChatOpenAI

# Define the crew with agents and tasks
financial_trading_crew = Crew(
agents=[data_analyst_agent,
trading_strategy_agent,
execution_agent,
risk_management_agent],

tasks=[data_analysis_task,
strategy_development_task,
execution_planning_task,
risk_assessment_task],

manager_llm=ChatOpenAI(model="gpt-3.5-turbo",
temperature=0.7),
process=Process.hierarchical,
verbose=True
)

The `Process` class helps to delegate the workflow to the Agents (kind of like a Manager at work)

  • In the example above, it will run this hierarchically.
  • manager_llm' lets you choose the LLM you want to use as Crew Manager

Putting it all together…

Source: “Multi AI Agent Systems with crewAI” course at Deeplearning.ai

Thus, my use case will involve a manager LLM, a custom tool, a few CrewAI tools (directory read, file read, search), and will build on the model of a manager hiring for skills to delegate.

Digital Aides for Small Business Using CrewAI Agents

Consider a small business consulting firm, ‘LN Consulting,’ which operates on a partner model. In this model, each partner assumes leadership responsibilities and handles clients from start to finish, encompassing sales to final delivery.

Can AI agents enhance the capacity of LN Consulting’s partners or lead consultants? One potential application could be the generation of sample reports, akin to a movie trailer, to provide prospective clients with a glimpse of the firm’s capabilities. This concept is not dissimilar to an astrology website offering free sample reports and then providing paid services based on those samples.

AI agents could generate these sample reports by analyzing the client’s problem and the firm’s past projects and case studies, summarizing this information into a concise, digestible format. This approach not only showcases the firm’s expertise but also offers potential clients an idea of what to expect. Furthermore, AI could personalize these sample reports based on the potential client’s industry, size, or specific needs, enhancing the relevance and appeal of the samples.

Let’s dive in! In this use case, we will configure agents and establish tasks using a custom tool and a manager_LLM. The objective is to generate a sample report for a client whose details we have obtained through a form or email. Additionally, we will generate corresponding messages that can be delivered via email, Twitter DM, or LinkedIn message. Remember, this is just a sample scenario but it provides a good insight into the potential applications of CrewAI for a small business.

Some synthetic data

Firstly, we need to create some synthetic data for ‘LN Consulting.’ This data should include a basic profile, a set of case studies, and a services delivery process to start with. Here’s how I created these using GPT4-o.

Source: Author-ChatGPT4-o

Note: To benefit from the best practices learned in the course, one should adopt role definitions for key hires. This will assist in better designing agents and tasks.

Towards the end of the article, I will provide the link to github that has all the generated files and code files.

Let’s look at how the agents, tools and other features of crewAI are put together.

Four Agents (Added one extra as an afterthought to generate messages)

# Define the Data Analysis Agent
data_analyst_agent = Agent(
role="Data Analyst/Scientist",
goal="Collect, process, and analyze data to generate insightful and actionable study reports for existing and new clients.",
backstory="You're tasked with supporting LN Consulting's comprehensive strategy reports for existing and new clients. "
"You gather and clean data from various sources relevant to market and competitor analysis, "
"perform statistical analyses and data modeling, and create visualizations, wherever possible to interpret data trends. "
"You collaborate with the Research Specialist and Lead Consultant to integrate your findings into strategic recommendations.",
#allow_delegation=False,
tools=[search_tool],
verbose=True
)


# Define the Research Specialist Agent
research_specialist_agent = Agent(
role="Research Specialist",
goal="Conduct thorough research to gather qualitative and quantitative information relevant to study topics for existing and new clients.",
backstory="You're responsible for supporting LN Consulting's comprehensive strategy reports by conducting in-depth research for existing and new clients. "
"You review relevant literature, studies, and data sources on market trends and competition, "
"synthesize this information, and collaborate with the Data Analyst to integrate research findings with data analysis. "
"Your research provides the foundation for strategic recommendations and report writing.",
#allow_delegation=False,
tools=[search_tool, directory_read_tool, file_read_tool],
verbose=True
)

# Define the Lead Consultant Agent (Consultant Digital Twin)
lead_consultant_agent = Agent(
role="Lead Consultant",
goal="Oversee the entire study report generation process, ensuring timely delivery and high-quality output for existing and new clients. "
"Identify solutions in line with desired outcome in {client_problem} and analysed problem statement from analysis_agent. "
"You will map these solutions to the services offered by LN consulting, identify the relevant case studies, and generate a comprehensive report.",
backstory="You're the driving force behind LN Consulting's comprehensive strategy reports for existing and new clients. "
"You plan and coordinate all phases of the report generation process, manage timelines, resources, and budgets, "
"and communicate with clients to understand their requirements and provide updates. "
"You ensure that all team members are aligned and meeting project milestones. "
"Additionally, you have a knack for compiling insightful reports that provide actionable solutions based on analysed problem statement mapping to desired outcome and timeline. "
"Your reports are known for their clarity, depth, and practical recommendations.",
allow_delegation=False,
tools=[ directory_read_tool, file_read_tool ],
verbose=True
)
# Define the agent
message_drafter = Agent(
role='Message Drafter',
goal='Create concise and effective message drafts for email, Twitter DM, and LinkedIn.',
verbose=True,
memory=True,
backstory=(
"As an expert communicator, you excel at crafting concise and impactful messages tailored for various platforms, peppering with relevant a movie quote."
),
tools=[summarization_tool],
allow_delegation=False
)

A custom tool

import os
import openai
from crewai_tools import BaseTool
from openai import OpenAI
client =OpenAI()
class DocumentSummarizationTool(BaseTool):
name: str = "Document Summarization Tool"
description: str = "Summarizes the content of a specified file into a concise summary."

def _run(self, file_path: str) -> str:
# Read the content of the specified file
try:
with open(file_path, 'r') as file:
document = file.read()
except FileNotFoundError:
return f"Error: File {file_path} not found."
except Exception as e:
return f"Error: {str(e)}"

# Summarize the document content
#response = openai.Completion.create(
response = client.completions.create(model="gpt-3.5-turbo-instruct",
prompt=f"Summarize the following document in themes and bullet points:\n\n{document}\n\nSummary:",
max_tokens=150)
summary = response.choices[0].text.strip()
return summary

Five Tasks

# Task for validating the client's problem statement
data_analysis_task = Task(
description=(
"1. Collect and clean data from various sources relevant to the client's market and competition using {client_problem} as context.\n"
"2. Perform statistical analyses and data modeling to identify trends and insights wherever possible.\n"
"3. Create visualizations to interpret data trends and provide data-driven insights wherever possible.\n"
"4. Collaborate with the Research Specialist and Lead Consultant to integrate findings into strategic recommendations."
),
expected_output="A comprehensive data analysis report with deep insights.",
agent=data_analyst_agent,
output_file='problem_analysis.md'
)

# Task for understanding the client's problem
research_task = Task(
description=(
"1. Identify and review relevant literature, studies, and data sources on market trends and competition related to {client_problem}.\n"
"2. Synthesize information to provide comprehensive background and context for strategic recommendations.\n"
"3. Collaborate with the Data Analyst to integrate research findings with data analysis.\n"
"4. Write and edit sections of the report to ensure clarity and coherence."
),
expected_output="A detailed research document with synthesized information and contextual background.",
agent=research_specialist_agent,
output_file='research_doc.md'
)

# Task for vetting research and generating a report
lead_consultant_task = Task(
description=(
"1. Plan and coordinate all phases of the report generation process for existing and new clients.\n"
"2. Manage timelines, resources, and budgets to ensure project efficiency.\n"
"3. Communicate with clients to understand their requirements in {client_problem} and provide regular updates.\n"
"4. Ensure all team members are aligned and meeting project milestones.\n"
"5. Research possible solutions for the identified issues in {client_problem} using LN Consulting Service Delivery process and methodologies.\n"
"6. List and detail solutions that match desired outcome and timeline in {client_problem}.\n"
"7. Map solutions in line with services offered by LN consulting.\n"
"8. Create a brief sample report as prepared by LN that outlines these solutions, including strategic recommendations and actionable insights and relevant case studies from LN Consulting.\n"
),
expected_output="A 2-page sample report in markdown format, including a deep understanding of client requirements in {client_problem} with "
"teaser of possible solutions, how LN Consulting can deliver, and relevant case studies. ",
tools=[directory_read_tool, file_read_tool],
agent=lead_consultant_agent,
output_file='sample_report.md'
)

# Define the summarization task
summarization_task = Task(
description=(
"Summarize the content of the provided document file 'sample_report.md'. Ensure the summary is concise and covers key points."
),
expected_output='A summary of the document content.',
tools=[summarization_tool],
agent=message_drafter,
input_file='./sample_report.md', # Ensure this path is correct
output_file='summary_output.txt' # Specify the output file for the summary
)

# Define the message drafting task using the summary
messages_task = Task(
description=(
"Draft a professional email, twitterd DM message, and linkedin message to the client based on the summarized content from 'summary_output.txt'. Ensure the message is clear, concise, and includes a call to action, mentioning the full report is attached. Add a relevant movie quote."
),
expected_output='A well-crafted set of drafts as email, twitter DM and Linkedin message to the client.',
tools=[summarization_tool],
agent=message_drafter,
input_file='summary_output.txt',
output_file='messages_draft.txt' # Specify the output file for the email draft
)

The Client Problem

client_problem = {
'problem_statement': 'We are facing declining sales in our main product line.',
'key_issues': 'Increased competition, outdated marketing strategies.',
'desired_outcome': 'Revitalize sales and regain market share.',
'background_information': 'Our main product has been on the market for 10 years.',
'timeline': 'Need results within the next 6 months.',
'additional_information': 'Open to exploring new marketing channels.'
}

The Crew

# Define the crew with multiple agents and the tasks
consulting_crew = Crew(
agents=[data_analyst_agent, research_specialist_agent, lead_consultant_agent, message_drafter],
tasks=[data_analysis_task, research_task, lead_consultant_task, summarization_task, messages_task],
manager_llm=ChatOpenAI(model="gpt-3.5-turbo",
temperature=0.7),
process=Process.hierarchical,
verbose=True,
Memory=True
)

The Agentic Execution

Source: Author’s notebook

Report output

# Sample Report: Strategic Solutions for Revitalizing Sales

## Client Requirements:
- **Problem Statement:** We are facing declining sales in our main product line.
- **Key Issues:** Increased competition, outdated marketing strategies.
- **Desired Outcome:** Revitalize sales and regain market share.
- **Background Information:** Our main product has been on the market for 10 years.
- **Timeline:** Need results within the next 6 months.
- **Additional Information:** Open to exploring new marketing channels.

---

### Teaser of Possible Solutions:
After thorough research and analysis, we have identified several strategic solutions that align with the client's desired outcome and timeline. These solutions leverage innovative marketing strategies, digital transformation, and customer engagement initiatives to revitalize sales and regain market share.

1. **Digital Transformation:** Implementing a comprehensive digital marketing strategy to enhance online visibility and customer engagement.
2. **Customer Segmentation:** Utilizing data analytics to identify target customer segments and tailor marketing campaigns for maximum impact.
3. **Content Optimization:** Enhancing the quality and relevance of marketing content to resonate with target audiences and drive conversions.

---

### LN Consulting Service Delivery Process:
LN Consulting's service delivery process is built on a foundation of industry expertise, innovative methodologies, and a commitment to delivering measurable results within defined timelines. Through a combination of data-driven insights, strategic planning, and execution excellence, LN Consulting has consistently helped clients achieve their business objectives and drive sustainable growth.

---

### Relevant Case Studies:
1. **ABC Media Solutions:** Leveraging digital transformation to enhance audience engagement and revenue generation.
2. **XYZ Broadcasting:** Implementing AI technologies to streamline operations and improve content delivery.
3. **DEF Financial Services:** Optimizing customer experience through personalized marketing strategies and data analytics.
4. **GHI Tech Solutions:** Driving innovation through technology adoption and process optimization.
5. **JKL Retail Group:** Enhancing customer loyalty and retention through targeted marketing campaigns and loyalty programs.

---

In conclusion, the strategic solutions outlined above, combined with LN Consulting's proven track record of success in similar projects, position us well to address the client's challenges and achieve the desired outcome of revitalizing sales and regaining market share. By leveraging innovative strategies, industry best practices, and a customer-centric approach, we are confident in our ability to deliver impactful results within the stipulated timeline.

*Note: The above sample report is a brief overview of strategic solutions and does not represent the full scope of recommendations and insights provided by LN Consulting.*

Messages output

**Email**
Subject: Strategy for Revitalizing Your Sales - Detailed Report Attached

Dear [Client's Name],

I hope this message finds you well. Our team at LN Consulting has carefully reviewed the challenges facing your main product line, specifically the decline in sales due to increased competition and outdated marketing strategies.

We are excited to present a comprehensive plan that includes a robust digital transformation and targeted marketing campaigns designed to regain market share and enhance customer engagement. Key strategies include leveraging new digital marketing channels, optimizing content for better conversion, and implementing AI technologies for a more personalized customer experience.

Please find the detailed report attached for your review. We are committed to delivering measurable results and ensuring the success of your revitalization efforts.

"Opportunity does not knock, it presents itself when you beat down the door." - Kyle Chandler

We look forward to discussing the report with you and exploring how we can support your journey towards revitalized sales.

Best regards,

[Your Name]
LN Consulting

**Twitter DM**
Hello [Client's Username],

We've crafted a strategy to boost your sales and tackle the competition head-on! 🚀 Check out the attached report for our digital transformation and tailored marketing solutions.

"Remember, Red, hope is a good thing, maybe the best of things, and no good thing ever dies." - Shawshank Redemption

Let's chat about driving your sales to new heights!

Best, [Your Name]

**LinkedIn Message**
Hi [Client's Name],

I'm reaching out to share a strategic approach prepared by LN Consulting aimed at revitalizing your product sales. Our team has developed a comprehensive plan focusing on digital marketing, customer segmentation, and AI-driven personalization to address the challenges you're facing.

Attached is our detailed report. As we say in the classics, "Life moves pretty fast. If you don't stop and look around once in a while, you could miss it." - Ferris Bueller's Day Off

I believe our strategies can significantly boost your market presence. Let’s discuss how we can work together to achieve your sales goals.

Warm regards,

[Your Name]
LN Consulting

Note:

  1. GPT-4 is significantly more effective when manager_LLM is used.
  2. OpenRouter AI provides a straightforward option to utilize multiple LLMs and monitor their activities efficiently (refer to the below picture).
Source: Author’s Openrouter.ai Activity

Github link

Conclusion

In summary, CrewAI is a valuable digital aide for small businesses aiming to enhance efficiency and innovation through AI. The example of the fictitious LN Consulting, derived from the author’s profile, illustrates how AI agents can support businesses by creating personalized client reports and simplifying project management. CrewAI automates complex tasks and optimizes processes, leading to better decision-making. At LN Consulting, AI agents took on roles such as data analysis, research, and communication, enabling human workers to focus on higher-value tasks. This is just the beginning — small businesses can leverage CrewAI and other tools for a variety of functions, including automating marketing and improving customer service, helping them stay competitive in a rapidly evolving digital world.

--

--