CrewAI Logo

Composio enables your CrewAI agents to connect with many tools!

Goal: Star a repository on GitHub with natural language & CrewAI Agent

Install Packages & Connect a Tool

These commands prepare your environment for seamless interaction between CrewAI and Github.

pip install composio_crewai

#Connect your Github so agents can use it. 
composio-cli add github

#Check all different apps which you can connect with
composio-cli show-apps

Goal: Use Crew Agent to Interact with Github using Composio


Import Base Packages

from crewai import Agent, Task
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(openai_api_key="sk-<OPENAI KEY>")


Fetch all Tools via Composio

from composio_crewai import ComposioToolset, Action, App

# Get All the tools

tools = ComposioToolset(apps=[App.GITHUB])


Execute the Agent

crewai_agent = Agent(
    role='Github Agent',
    goal="""You take action on Github using Github APIs""",
    backstory="""You are AI agent that is responsible for taking actions on Github on users behalf. You need to take action on Github using Github APIs""",
task = Task(
    description="Star a repo SamparkAI/composio_sdk on GitHub",
    expected_output="if the star happened"


Check Response

> Entering new CrewAgentExecutor chain...[0m
I need to star a repository on GitHub, specifically the repo "SamparkAI/composio_sdk".


Action Input:
"owner": "SamparkAI",
"repo": "docs"

{'execution_details': {'executed': True}, 'response_data': ''}
Final Answer: {'execution_details': {'executed': True}, 'response_data': ''}[0m

> Finished chain.[0m
> {'execution_details': {'executed': True}, 'response_data': ''}

Use Specific Actions

# To restrict agents from using all the actions, filter specific actions
toolsGithubCreateIssue = ComposioToolset(actions=[Action.GITHUB_CREATE_ISSUE])

Use Specific Apps

  # To restrict agents from using all tools, filter specific tools
  specific tools toolsAsanaGithub = ComposioToolset(apps=[App.ASANA, App.GITHUB])

Filter apps actions by tags

  # To restrict agents from using all actions, filter the actions by tags
  specific tools toolsAsanaGithub = ComposioToolset(apps=[App.ASANA], tags=[Tag.ASANA_TASKS])