Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ Reduce APort integration time from hours to minutes.
| Tool | Description | Status | Maintainer |
|------|-------------|--------|------------|
| [APort CLI](tools/cli/) | `npx create-aport-integration` scaffolding tool | ✅ Active | Community |
| [Discord Verification Bot](examples/developer-tools/discord-bot/) | Slash-command bot for team workflow verification | ✅ Active | Community |
| [VS Code Extension](tools/vscode-extension/) | Policy development with IntelliSense | 🚧 In Progress | Community |
| [Postman Collection](tools/postman-collection/) | Complete API testing collection | ✅ Active | Community |

Expand Down
6 changes: 6 additions & 0 deletions examples/developer-tools/discord-bot/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DISCORD_TOKEN=replace_with_your_bot_token
DISCORD_CLIENT_ID=replace_with_your_application_client_id
DISCORD_GUILD_ID=replace_with_your_test_server_id
APORT_API_KEY=your_aport_api_key
APORT_BASE_URL=https://aport.io
APORT_DEFAULT_POLICY=code.repository.merge.v1
73 changes: 73 additions & 0 deletions examples/developer-tools/discord-bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# APort Discord Verification Bot

Discord bot for checking team workflow actions with APort policy verification.

The bot adds slash commands that let a team verify whether an agent is allowed to perform actions such as merging a pull request, processing a refund, exporting data, or requesting admin access.

## Commands

| Command | Description |
| --- | --- |
| `/aport-verify` | Verify an agent action against an APort policy. |
| `/aport-help` | Show usage details and a context example. |

`/aport-verify` options:

| Option | Required | Description |
| --- | --- | --- |
| `agent-id` | Yes | APort agent id or team-mapped agent identifier. |
| `action` | Yes | Team workflow action to verify. |
| `policy` | No | APort policy pack. Defaults to `APORT_DEFAULT_POLICY`. |
| `context` | No | Additional JSON context for the policy check. |

## Setup

1. Create a Discord application in the Discord Developer Portal.
2. Add a bot user and copy the bot token.
3. Enable the `applications.commands` OAuth2 scope when installing the bot.
4. Copy `.env.example` to `.env` and fill in the values.

```bash
npm install
cp .env.example .env
npm run register
npm start
```

For local development, set `DISCORD_GUILD_ID` so commands register immediately in one test server. Leave it empty when you want global commands.

## Environment

```bash
DISCORD_TOKEN=replace_with_your_bot_token
DISCORD_CLIENT_ID=replace_with_your_application_client_id
DISCORD_GUILD_ID=replace_with_your_test_server_id
APORT_API_KEY=your_aport_api_key
APORT_BASE_URL=https://aport.io
APORT_DEFAULT_POLICY=code.repository.merge.v1
```

## Example

```text
/aport-verify agent-id:ap_a2d10232c6534523812423eec8a1425c action:merge_pr policy:code.repository.merge.v1 context:{"repository":"owner/repo","pull_request":42}
```

The bot replies privately with an approval or denial embed. The request context sent to APort includes the Discord guild, channel, user, selected action, and any custom JSON context.

## Development

```bash
npm test
npm run check
```

## Files

```text
src/index.js Discord client entrypoint
src/register-commands.js Slash command registration
src/commands.js Command definitions and handlers
src/aport.js APort policy verification helper
tests/ Unit tests for parsing, context, and API behavior
```
Loading