watsonx.ai 및 CrewAI를 사용하여 고객 통화 분석을 위한 다중 에이전트 협업

Vanna Winland

AI Advocate & Technology Writer

Meredith Syed

Technical Content, Editorial Lead

IBM

이 튜토리얼에서는 여러 인공 지능(AI) 에이전트로 구성된 팀이 협업하여 복잡한 작업을 완료하고 워크플로를 최적화하는 방법을 보여줍니다. 다중 에이전트 아키텍처 내에서 작동하는 전문 에이전트의 오케스트레이션을 설명하기 위해 Python 애플리케이션을 구축했습니다. 마지막에는 에이전트 AI 애플리케이션 내에서 다중 에이전트 협업의 예시를 보고 실행해 볼 수 있습니다.

우리가 작업하고 있는 애플리케이션은 CrewAI를 다중 에이전트 프레임워크로 사용하고 IBM® watsonx.ai를 통해 이를 지원하는 대규모 언어 모델(LLM)을 배포하는 고객 서비스 분석 팀입니다.

AI 에이전트는 사용자나 에이전틱 AI 시스템을 대신하여 작업을 수행할 수 있는 LLM 기반 엔터티입니다. 에이전트 아키텍처는 단일 에이전트와 다중 에이전트의 두 가지 시스템을 중심으로 구성됩니다.

단일 에이전트 시스템은 생성형 AI 작업을 수행하기 위해 하나의 LLM 에이전트에 의존하기 때문에 좁은 범위의 문제를 해결하는 데 가장 적합합니다. 예를 들어, 단일 챗봇 에이전트는 개별 능력 범위 내에서 완료할 수 있는 특정 작업이나 대화에 집중할 수 있습니다.

다중 에이전트 시스템(MAS)은 AI 에이전트 간의 기능과 상호 작용을 조율하는 프레임워크입니다. 다중 에이전트 아키텍처는 단일 에이전트 내에서 모든 기능을 포괄하려고 시도하는 대신 서로 다른 에이전트를 사용하여 동일한 환경 내에서 작업하여 공유 목표를 달성합니다. 다중 에이전트 시스템의 주요 이점에는 단일 에이전트의 기능을 넘어서는 문제를 해결하기 위한 에이전트 협업 및 적응성이 포함됩니다. 가장 좋은 접근 방식은 솔루션을 컴파일하거나 특정 결과를 달성하는 데 필요한 기계 학습 작업의 복잡성에 따라 달라집니다.

다중 에이전트 시스템을 통한 문제 해결

crewAI는 사용자 지정 가능한 크루(역할을 수행하는 에이전트 팀)을 구성하여 LLM 에이전트 자동화를 오케스트레이션하는 오픈 소스 에이전트 프레임워크입니다. 에이전트가 다중 에이전트 아키텍처 내에서 협업하는 방법을 설명하기 위해 단순화된 업계 사용 사례를 적용했습니다.

고객 서비스 콜센터의 실제 사용 사례를 가정해 보겠습니다. 콜센터 기록을 분석하는 통신 소프트웨어는 고객 경험을 향상하고 통화 품질을 평가하는 데 사용됩니다. 보다 강력한 소프트웨어에서는 통화 메타데이터를 포함한 대규모 데이터 세트와 함께 대화 내용을 실시간으로 분석할 수도 있습니다. 설명의 편의를 위해 이 애플리케이션의 데이터 세트는 고객 서비스 담당자와 고객 간의 단순한 모의 대화록입니다.

# multiagent-collaboration-cs-call-center-analysis/data/transcript.txt 

Customer Service Interaction Transcript

Cynthia:
Hi, I'm calling because I received a jar of peanut butter that was open and it's
completely spilled everywhere. This is really frustrating, and I need a replacement.

Gerald (Peanut Butter Inc.):
Ugh, that sucks. But, like, how did you not notice it was open before
you bought it?

Cynthia:
Excuse me? I didn't expect the jar to be open when I received it. It was sealed
when I bought it. Can you just help me out here?

Gerald:
Yeah, whatever. But we can't control how it gets to you. I mean, it's not like
we throw the jars around or anything. You're probably being dramatic.

Cynthia:
I'm not being dramatic. The peanut butter is literally all over the box and
it's a mess. I just want a replacement or a refund, that's all.

Gerald:
Look, I guess I could send you a replacement, but it's really not our fault, you
know? Maybe next time, check the jar before you open it?

Cynthia:
Are you seriously blaming me for your company's mistake? That's not how customer
service works!

Gerald:
Well, what do you want me to do? I don't exactly have magic powers to fix your
problem instantly. Chill out, we'll send you a new jar eventually.

Cynthia:
That's not good enough! I expect better from a company that I've been buying
from for years. Can you just do the right thing and make this right?

Gerald:
Fine, fine. I'll put in a request or whatever. But seriously, this kind of thing
happens. Don't make it sound like the end of the world.

Cynthia:
Unbelievable. I'll be posting a review if this isn't fixed immediately.

Gerald:
Cool, go ahead. I'm sure we'll survive your review.

Cynthia:
I'll be contacting your supervisor if this isn't resolved soon.

Gerald:
Yeah, okay. Do what you gotta do. 

협업 에이전트 팀은 텍스트 분석 및 고객 콜센터 지표를 기반으로 포괄적인 보고서를 생성합니다. 이 보고서는 고객 서비스 관리자가 통화의 주요 이벤트를 요약하고 성능을 평가하며 개선을 위한 권장 사항을 제공하는 데 도움이 됩니다.

고객 서비스 통화 분석 크루

그림 1 - 에이전트 아키텍처 다이어그램 그림 1 - 에이전트 아키텍처 다이어그램

고객 서비스 통화 분석 크루는 특수한 역할과 사전 정의된 목표를 가진 세 개의 에이전트로 구성됩니다. 에이전트 구성에는 녹취록 분석, 품질 보증 전문 및 보고서 생성이 포함됩니다. 에이전트의 목표와 특성은 역할, 목표배경 이야기의 세 가지 주요 속성으로 정의됩니다.

transcript_analyzer:
  role: >
    Transcript Analyzer
  goal: >
    Analyze the provided transcripts and extract key insights and themes.
  backstory: >
    As the Transcript Analyzer, you are responsible for reviewing customer
    service call transcripts, identifying important information, and summarizing
    findings into a report to pass on to the Quality Assurance Specialist. 
    You have access to advanced text analysis tools that help you process and
    interpret the data effectively.

quality_assurance_specialist:
  role: >
    Quality Assurance Specialist
  goal: >
    Evaluate the quality of the customer service based the Transcript Analyzer's
    report, call center evaluation metrics, and business standards. Flag any 
    transcripts with escalation risks as high priority.
  backstory: >
    As the Quality Assurance Specialist, you are tasked with assessing the
    quality of customer service interactions based on the Transcript Analyzer's
    report, call center evaluation metrics, and industry standards used in call
    centers. You review transcripts, evaluate agent performance, and provide
    feedback to improve overall service quality.

report_generator:
  role: >
    Report Generator
  goal: >
    Generate reports based on the insights and findings from the transcript
    analysis and quality assurance specialist.
  backstory: >
    As the Report Generator, you compile the key insights and findings from the
    transcript analysis and quality assurance specialist into a comprehensive
    report. You create an organized report that includes summaries and recommendations
    based on the data to help customer service managers understand the trends
    and patterns in customer interactions.

녹취록 분석 에이전트는 녹취록에 대한 철저한 분석을 수행하여 주요 인사이트와 중요한 정보를 추출합니다. 그런 다음 분석기는 결과를 보고서로 요약하여 다른 에이전트에게 전달하여 작업을 지원합니다. 이 에이전트는 사용자 지정 도구 모음을 사용하여 키워드 추출 및 감정 분석과 같은 자연어 처리(NLP) 기술을 수행합니다.

품질 보증 전문 에이전트는 녹취록 분석의 보고서의 주요 인사이트와 콜센터 평가 지표의 구현 및 평가에 대한 자체 설명된 전문 지식을 기반으로 통화 품질을 평가합니다. 이 에이전트는 또한 인터넷을 검색하여 관련 지표와 프로세스를 검색하여 직원의 성과를 평가하고 전반적인 서비스 품질을 개선하기 위한 피드백을 제공할 수 있습니다.

보고서 생성 에이전트는 녹취록 분석 보고서의 인사이트와 품질 보증 평가에서 제공하는 지표 및 피드백을 기반으로 보고서를 생성합니다. 이 에이전트는 데이터를 포괄적인 보고서로 구성하는 것을 전문으로 합니다. 보고서의 목표는 고객 서비스 관리자에게 통화 내용에서 얻은 주요 인사이트에 대한 분석과 고객 서비스 품질 개선을 위한 권장 사항을 제공하는 것입니다.

에이전트 도구

각 에이전트는 에이전트가 다양한 작업을 수행하는 데 사용하는 도구, 기술 또는 기능에 액세스할 수 있습니다. crewAI는 기존 도구, LangChain 도구와의 통합 및 자체 사용자 지정 도구를 구축할 수 있는 옵션을 제공합니다. 고객 서비스 분석 크루는 에이전트의 작업과 애플리케이션의 목표에 지정된 각 도구를 조합하여 사용합니다. 각 에이전트는 구성에서 액세스할 수 있는 툴링에 대한 특정 권한을 가지고 있습니다.
 
사용자 지정 도구는 도구의 용도에 대한 명확한 설명을 정의하여 생성됩니다. 예를 들어 녹취록 분석 에이전트에는 텍스트 분석을 위한 몇 가지 사용자 지정 도구가 있습니다.


# src/customer_service_analyzer/tools/custom_tool.py
  
class SentimentAnalysisTool(BaseTool):
    name: str = "Sentiment Analysis Tool"
    description: str = "Determines the sentiment of the interactions in the transcripts."

    def _run(self, transcript: str) -> str:
        # Simulating sentiment analysis
        sentiment = Helper.analyze_sentiment(transcript)
        return sentiment

도구에 대한 설명은 에이전트가 녹취록에 대한 감정 분석을 수행하기 위해 논리로 사용하는 것입니다.

에이전트는 기존 도구와 통합 애플리케이션 프로그래밍 인터페이스(API)를 사용할 수도 있습니다. 품질 보증 전문 에이전트는search_tool  에 액세스할 수 있으며 이는 SerperDevTool 을 사용해 인터넷을 검색하고 가장 관련성이 높은 결과를 문의에 반환합니다. 에이전트는 숙련된 고객 서비스 평가자로서 전문적인 역할을 수행할 수 있을 뿐만 아니라, 인터넷을 활용하여 보고서에서 통화 및 사용을 평가하는 데 필요한 지표를 검색할 수도 있습니다.

작업 워크플로

작업은 에이전트가 실행 세부 정보와 함께 완료하는 구체적인 할당으로, 실행 세부 정보는 설명, 에이전트, 아웃풋의 세 가지 필수 작업 속성에 의해 구성됩니다. 에이전트는 각 작업에 대한 자세한 설명을 가이드로 사용하여 논리적 순서로 작업을 수행합니다.

transcript_analysis:
  description: >
    Use the Text Analysis Tool to collect key information and insights to better
    understand customer service interactions and improve service quality. 
    Conduct a thorough analysis of the call {transcript}.
    Prepare a detailed report highlighting key insights, themes, and sentiment
    from the transcripts.
    Identify any escalation risks and flag them for the Quality Assurance Specialist.
    Use the sentiment analysis tool to determine the overall sentiment of the
    customer and the agent.
    Use the keyword extraction tool to identify key keywords and phrases in the transcript.
  expected_output: >
    A detailed analysis report of the {transcript} highlighting key insights,
    themes, and sentiment from the transcripts.
  agent: transcript_analyzer

quality_evaluation:
  description: >
    Review the transcript analysis report on {transcript} from the Transcript Analyzer.
    Utilize your expertise in customer service evaluation metrics and industry
    standards, and internet to evaluate the quality of the customer service interaction.
    Score the interaction based on the evaluation metrics and flag any high-risk
    escalations. Develop expert recommendations to optimize customer service
    quality. Ensure the report includes customer service metrics and feedback
    for improvement.
  expected_output: >
    A detailed quality evaluation report of the {transcript} highlighting the
    quality of the customer service interaction, scoring based on evaluation
    metrics, flagging any high-risk escalations, and recommendations for improvement.
  agent: quality_assurance_specialist

report_generation:
  description: >
    List the reports from the Transcript Analyzer and the Quality Assurance
    Specialist, then develop a detailed action plan for customer service managers
    to implement the changes.
    Use the data from these agents output to create an organized report including
    a summarization and actionable recommendations for call center managers.
    Ensure the report includes keywords and sentiment analysis from the Transcript
    Analyzer agent.
    Ensure the report includes the Quality Assurance Specialist agent's report,
    evaluation metrics and recommendations for improving customer service quality.
    Ensure the report is well written and easy to understand.
    Be smart and well explained.
    Ensure the report is comprehensive, organized, and easy to understand with
    labeled sections with relevant information.
  expected_output: >
    A comprehensive report that lists the reports from the Transcript Analyzer,
    then the Quality Assurance Specialist. 
    The report should include the key insights from {transcript} and the quality
    evaluation report from the Quality Assurance Specialist.
    The report should include organized sections for each agent's findings,
    summaries, and actionable recommendations for call center managers.
  agent: report_generator
  context: 
    - transcript_analysis
    - quality_evaluation

작업 워크플로는 녹취록 분석기에서 완료한 녹취록 분석으로 시작하는 순차적 프로세스로 실행됩니다. 작업 결과는 향후 작업에 대한 컨텍스트를 설정할 수 있습니다. 다음 시퀀스에서 품질 보증 전문가는 녹취록 분석 보고서를 활용하여 품질 평가를 알리고 에스컬레이션을 나타내는 키워드나 문구를 기록합니다.

보고서 생성 에이전트는 녹취록 분석 및 품질 보증 전문 에이전트의 아웃풋을 컨텍스트로 사용하여 통화 녹취록에 대한 포괄적인 보고서를 생성합니다. 이 흐름은 다중 에이전트 협업의 한 예이며, 에이전트가 복잡한 작업을 완료하고 컨텍스트 인식을 높여 더욱 강력한 아웃풋을 생성하는 동시에 전문적인 역할을 수행하는 방법을 보여줍니다.

단계

1단계. 환경 설정

먼저 애플리케이션을 실행할 환경을 설정해야 합니다. GitHub의 crewAI 프로젝트 폴더에 있는 마크다운 파일이나 여기에서 이러한 단계를 확인할 수 있습니다.

  • Python 3.10 이상, 3.13 이하가 시스템에 설치되어 있어야 합니다.python3 –version 명령어를 사용해 Python 버전을 확인할 수 있습니다.
  • 여기에서 GitHub 리포지토리를 복제합니다 . 저장소 복제 방법은 GitHub 문서를 참고하세요.

프로젝트 구조는 다음 단계와 유사해야 합니다.

src/customer_service_analyzer/

├── config/
│   ├── agents.yaml    # Agent configurations
│   └── tasks.yaml     # Task definitions
├── tools/
│   ├── custom_tool.py # Custom crewAI tool implementations
│   └── tool_helper.py # Custom tool helper functions
├── crew.py           # Crew orchestration
└── main.py          # Application entry point

2단계. watsonx API 자격 증명 받기

  1. IBM® Cloud 계정을 사용하여 watsonx.ai에 로그인합니다.
  2. watsonx.ai 프로젝트를 생성합니다. 프로젝트 > 관리 > 일반 > 프로젝트 ID에 프로젝트 ID를 기록해 둡니다. 이 튜토리얼에서 ID가 필요합니다.
  3. watsonx.ai 런타임 서비스 인스턴스를 만듭니다(무료 인스턴스인 Lite 요금제 선택).
  4. watsonx API 키를 생성합니다.
  5. watsonx.ai 런타임 서비스를 watsonx.ai에서 생성한 프로젝트에 연결합니다.

3단계. Serper API 자격 증명 받기

무료 Serper API 키를 생성하고 기록해 둡니다. Serper는 이 프로젝트에서 사용하는 Google 검색 API입니다.

4단계. CrewAI 설치 및 자격 증명 설정

이 튜토리얼을 학습하려면 crewAI 프레임워크를 설치하고, 2단계에서 생성한 watsonx.ai 자격 증명을 설정해야 합니다.

패키지 관리 도구로 uv를 사용 중이라면 crewAI를 다음과 같이 추가할 수 있습니다.

uv tool install crewai

패키지 관리에 pip를 사용하는 경우 가상 환경을 설정한 다음 해당 환경에 crewAI를 설치합니다.

python3 -m venv venv
source ./venv/bin/activate

crewAI를 설치하려면 터미널에서 다음 명령을 실행하세요.

pip install 'crewai[tools]'

In a separate .env file at the same directory level as the .env_sample file, set your credentials as strings like so:

WATSONX_APIKEY=your_watson_api_key_here
WATSONX_PROJECT_ID=your_watsonx_project_id_here
WATSONX_URL=your_endpoint (e.g. "https://us-south.ml.cloud.ibm.com")
SERPER_API_KEY=your_serper_api_key_here

5단계. (선택 사항) 크루 사용자 지정

crewAI는 모든 오픈 소스 LLM을 사용하도록 구성할 수 있습니다. LLM은 Ollama와 IBM watsonx, OpenAI 같은 여러 다른 API를 통해 연결할 수 있습니다. LangChain Tools과 crewAI Toolkit을 통해 제공되는 사전 구축된 툴을 활용할 수도 있습니다.

6단계. 시스템 실행

이 프로젝트의 적절한 작업 디렉터리에 있는지 확인하세요. 디렉터리를 변경하려면 터미널에서 다음 명령을 실행하세요.

cd crew-ai-projects/multiagent-collab-cs-call-center-analysis

AI 에이전트 크루를 시작하고 작업 실행을 시작하려면 프로젝트의 루트 폴더에서 이 명령을 실행하세요. 크루가 결과를 반환하는 데 몇 분이 소요될 수 있습니다.

crewai run

 

이 명령은 콜센터 분석 크루를 초기화하여 에이전트를 조립하고 구성에 정의된 대로 작업을 할당합니다. 이 예제를 수정하지 않고 사용하면 watsonx.ai에서 IBM Granite®를 실행하여 report.md 파일이 아웃풋과 함께 생성됩니다. crewAI는 JSON, Pydantic 모델, 원시 문자열을 아웃풋으로 반환할 수 있습니다. 크루가 생성한 아웃풋의 예를 보겠습니다.

아웃풋 예시

This result is an example of the final output after running the crew:

**Detailed Analysis Report of the Customer Service Interaction Transcript**

**Transcript Analysis Report**

The customer, Cynthia, called to report a damaged product, a jar of peanut butter that was open and spilled everywhere. She requested a replacement, but the agent, Gerald, responded defensively and blamed her for not noticing the damage before purchasing. The conversation escalated, with Cynthia becoming frustrated and threatening to post a negative review and contact the supervisor.

**Key Insights and Themes**

* The customer was dissatisfied with the product and the agent's response.
* The agent was unhelpful, unprofessional, and failed to take responsibility for the company's mistake.
* The conversation was confrontational, with both parties becoming increasingly agitated.
* The customer felt disrespected and unvalued, while the agent seemed dismissive and uncaring.

**Sentiment Analysis**

* Customer Sentiment: Frustrated, Angry, Disappointed
* Agent Sentiment: Defensive, Dismissive, Uncaring

**Keyword Extraction**

* Damaged Product
* Unhelpful Agent
* Confrontational Conversation
* Customer Dissatisfaction
* Unprofessional Response

**Escalation Risks**

* Negative Review: The customer threatened to post a negative review if the issue was not resolved promptly.
* Supervisor Involvement: The customer may contact the supervisor to report the incident and request further action.

**Recommendations for Quality Assurance Specialist**

* Review the call recording to assess the agent's performance and provide feedback on areas for improvement, using customer service metrics.
* Investigate the root cause of the damaged product and implement measures to prevent similar incidents in the future.
* Provide training on customer service skills, including active listening, empathy, and conflict resolution, using customer service standards.
* Monitor the customer's feedback and respond promptly to any concerns or complaints to maintain a positive customer experience.
* Recognize the standards for various customer service metrics to measure key performance indicators that are related to the areas mentioned above.

**Summary of Quality Evaluation Report**

The customer, Cynthia, called to report a damaged product, a jar of peanut butter that was open and spilled everywhere. She requested a replacement, but the agent, Gerald, responded defensively and blamed her for not noticing the damage before purchasing. Evaluation metrics showed a low Customer Satisfaction Score (CSAT), high Customer Effort Score (CES), and negative Net Promoter Score (NPS).

**Recommendations for Call Center Managers**

* Review the call recording, investigate the root cause of the damaged product, and provide training on customer service skills. Recognize the standards for various customer service metrics to measure key performance indicators.
* Monitor the customer's feedback and respond promptly to any concerns or complaints to maintain a positive customer experience.
* Implement measures to prevent similar incidents in the future, such as improving product packaging and handling procedures.
* Provide feedback and coaching to agents on their performance, highlighting areas for improvement and recognizing good performance.

결론

샘플 아웃풋에서 볼 수 있듯이 에이전트은 협력을 통해 예시 녹취록에 대한 보고서를 분석, 평가 및 생성하는 복잡한 작업을 완료했습니다. 에이전트 간의 협업을 통해 각 에이전트가 프로세스의 특정 측면에 특화되도록 오케스트레이션함으로써 애플리케이션의 효율성과 정확성이 향상되었습니다. 예를 들어, 보고서 에이전트는 텍스트 분석 및 평가 작업의 결과를 포함하는 체계적인 보고서를 생성했습니다. 이 결과는 워크플로의 여러 부분을 처리하는 에이전트 간의 원활한 조정을 반영합니다.

다중 에이전트 프레임워크는 에이전트 협업을 통해 보다 강력하고 향상된 성능을 제공할 수 있습니다. 모든 다중 에이전트 아키텍처가 동일한 방식으로 작동하는 것은 아닙니다. 예를 들어, 일부는 소프트웨어 개발에만 특화된 반면 crewAI 및 AutoGen과 같은 일부는 더 유연하게 구성 가능한 구성을 제공합니다.

관련 솔루션
IBM AI 에이전트 개발 

IBM watsonx.ai 스튜디오를 사용하여 개발자가 AI 에이전트를 구축, 배포 및 모니터링할 수 있도록 지원합니다.

watsonx.ai 살펴보기
IBM AI 에이전트 및 어시스턴트

기업이 AI 에이전트 및 어시스턴트를 구축, 사용자 지정, 관리할 수 있도록 지원하며, 업계에서 가장 포괄적인 기능 세트 중 하나를 사용하여 획기적인 생산성을 창출하세요. 

AI 에이전트 살펴보기
IBM Granite

개발자 효율성을 높이는 Granite의 소형 개방형 모델을 사용하여 90% 이상의 비용 절감을 달성하세요. 이러한 엔터프라이즈급 모델은 사이버 보안부터 RAG까지 광범위한 엔터프라이즈 작업과 안전 벤치마크에 대해 탁월한 성능을 제공합니다.

Granite 살펴보기
다음 단계 안내

기업이 AI 에이전트 및 어시스턴트를 구축, 사용자 지정 및 관리할 수 있도록 지원하는 업계에서 가장 포괄적인 기능을 통해 복잡한 워크플로를 자동화하고 획기적인 생산성을 창출하세요. 

watsonx.ai 에이전트 개발 살펴보기 watsonx Orchestrate 알아보기