# SAP S/4 Agent – Copilot Studio + SAP BTP + CAP

This project demonstrates how to integrate Microsoft Copilot Studio with SAP S/4HANA
using a backend built with SAP CAP running on SAP BTP (Cloud Foundry).

The Copilot agent calls an OpenAPI-based Action that forwards requests to SAP CAP,
which in turn queries SAP S/4HANA APIs from the SAP Business Accelerator Hub.

## Architecture

Copilot Studio (Action)
→ HTTP POST
SAP CAP (BTP – Cloud Foundry) git add .git status
→ SAP S/4HANA APIs (Business Accelerator Hub Sandbox)

## Endpoints

| Method | Path | Description |
|-------|------|------------|
| GET | /mcp/health | Health check |
| POST | /mcp/call | Executes a backend tool |

## Request format

```json
{
  "tool": "sap_s4_get_business_partner",
  "input": {
    "bpId": "1000000"
  }
}
```

## Available tools

- sap_s4_get_business_partner – Fetch Business Partner data from S/4HANA
- mock_get_sales_order_status – Returns Sales Order status (mock)

## Local run

```bash
npm install
npm start
```

## Deploy to SAP BTP (Cloud Foundry)

```bash
cf push
```

Credentials and SAP API keys must be provided using environment variables in Cloud Foundry.
