What you’ll build
- A CrewAI agent configured with one or more backend tools.
- Tool functions that validate inputs, call external APIs, and raise exceptions on failure.
- A
/kickoffendpoint that surfaces tool call events to CometChat.
Prerequisites
- CrewAI project from crew-ai.mdx
- API keys for any services you call (store them in
.env)
Steps
1
Model your tools
Keep each tool focused (single responsibility) and add clear docstrings so the LLM knows when to call them.
2
Validate inputs
Check for required fields and raise exceptions for bad data—don’t return error strings.
3
Register in CrewAI
Add tools to the agent in
crew.py and set process=Process.sequential or another flow as needed.4
Stream via FastAPI
Reuse the NDJSON stream from crew-ai.mdx so CometChat can render tool progress.
Sample tool: fetch deals from a CRM
src/crew_demo/tools/get_deals.py
crew.py:
Agent/task configuration
src/crew_demo/config/agents.yaml
src/crew_demo/config/tasks.yaml
Connect to CometChat
- Provider: CrewAI
- Agent ID:
backend - Deployment URL: your public
/kickoff - Optional headers:
{ "Authorization": "Bearer <token>" }