Back to Composio

Support Knowledge Agent

docs/content/cookbooks/support-agent.mdx

0.11.13.3 KB
Original Source

View source on GitHub

This cookbook builds an agentic RAG system: an interactive CLI agent that triages support issues by pulling context from Notion docs, Datadog monitors, and GitHub issues. It uses scoped sessions, multi-turn chat with streaming, and a structured system prompt.

Prerequisites

Project setup

Create a new project and install dependencies:

bash
mkdir composio-support-agent && cd composio-support-agent
uv init && uv add composio composio-openai-agents openai-agents

Add your API keys to a .env file:

bash
COMPOSIO_API_KEY=your_composio_api_key
OPENAI_API_KEY=your_openai_api_key

Setting up the client

Composio takes an OpenAIAgentsProvider so that tools come back in the format the OpenAI Agents SDK expects. We also import the streaming event types we'll need for real-time output.

<include>../../examples/support-agent/main.py#setup</include>

Defining the agent

The system prompt tells the agent what tools it has and how to behave. It knows about Datadog, Notion, and GitHub, and decides on its own which to use based on the question.

<include>../../examples/support-agent/main.py#agent</include>

Chat loop with streaming

The chat loop creates a session scoped to three toolkits: datadog, notion, and github. The agent only sees tools from these services. Runner.run_streamed streams tokens as they arrive so you see the response in real time. Message history is tracked in a list for multi-turn context.

<include>../../examples/support-agent/main.py#chat</include>

<Callout> If a toolkit isn't connected yet, the agent will automatically return an authentication link in its response. The user can complete OAuth and then retry. </Callout>

Complete script

Here's everything together:

<include>../../examples/support-agent/main.py</include>

Running the agent

bash
uv run --env-file .env python main.py

The agent starts an interactive chat. Type a message and watch the response stream in. Type quit to exit.

Support Knowledge Agent (type 'quit' to exit)
--------------------------------------------------

You: The payments service is returning 500 errors. Can you check what's going on?

Agent: I checked Datadog and found an active alert on the payments-api monitor...

Take it further

The agent's scope is defined by its toolkits and system prompt. Swap them to build different support workflows:

  • Escalation bot: add PagerDuty and Slack toolkits so the agent can page on-call engineers and post incident threads automatically
  • Customer-facing KB: replace Datadog with Zendesk, let the agent search help articles and draft replies to open tickets
  • Incident timeline: add Jira and Confluence toolkits so the agent can cross-reference tickets with runbook docs and build a timeline
<Cards> <Card title="Workplace Search" href="/cookbooks/workplace-search" description="Search across GitHub, Slack, Gmail, and Notion from a single agent" /> <Card title="Background Agent" href="/cookbooks/background-agent" description="Run a multi-app agent autonomously on a cron schedule" /> </Cards>