Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Add ability to create examples

haxziefcd797b42da6
diff --git a/examples/triggers/.env.example b/examples/triggers/.env.example
new file mode 100644
index 000000000..0e728257c
--- /dev/null
+++ b/examples/triggers/.env.example
@@ -0,0 +1,6 @@
+# Composio API Key - Get it from https://app.composio.dev
+COMPOSIO_API_KEY=your_composio_api_key_here
+
+# Add other environment variables as needed for your example
+# OPENAI_API_KEY=your_openai_api_key_here
+# ANTHROPIC_API_KEY=your_anthropic_api_key_here
diff --git a/examples/triggers/README.md b/examples/triggers/README.md
new file mode 100644
index 000000000..edfc440cb
--- /dev/null
+++ b/examples/triggers/README.md
@@ -0,0 +1,53 @@
+# Triggers Example
+
+This example demonstrates how to use Composio SDK for triggers.
+
+## Setup
+
+1. **Install dependencies:**
+ ```bash
+ pnpm install
+ ```
+
+2. **Configure environment:**
+ ```bash
+ cp .env.example .env
+ ```
+
+ Then edit `.env` and add your API keys:
+ - `COMPOSIO_API_KEY`: Get it from [Composio Dashboard](https://app.composio.dev)
+
+## Running the Example
+
+```bash
+# Run the example
+pnpm start
+
+# Run in development mode (with file watching)
+pnpm dev
+```
+
+## What This Example Does
+
+- Initializes Composio SDK
+- Fetches available tools
+- Demonstrates basic usage patterns
+
+## Customization
+
+Edit `src/index.ts` to:
+- Add specific apps you want to integrate with
+- Implement your business logic
+- Add error handling and logging
+
+## Related Examples
+
+- [OpenAI Example](../openai) - Shows integration with OpenAI
+- [LangChain Example](../langchain) - Shows integration with LangChain
+- [More Examples](../) - Browse all available examples
+
+## Support
+
+- [Documentation](https://docs.composio.dev)
+- [Discord Community](https://discord.gg/composio)
+- [GitHub Issues](https://github.com/composio/composio/issues)
diff --git a/examples/triggers/package.json b/examples/triggers/package.json
new file mode 100644
index 000000000..f156decaf
--- /dev/null
+++ b/examples/triggers/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "triggers-example",
+ "private": true,
+ "version": "0.1.0",
+ "description": "Example project for Triggers",
+ "main": "src/index.ts",
+ "scripts": {
+ "start": "bun src/index.ts",
+ "dev": "bun --watch src/index.ts",
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": ["composio", "example", "triggers"],
+ "author": "",
+ "license": "ISC",
+ "packageManager": "[email protected]",
+ "dependencies": {
+ "@composio/core": "workspace:*",
+ "dotenv": "^16.4.1"
+ },
+ "devDependencies": {
+ "@types/bun": "^1.2.9",
+ "typescript": "^5.8.3"
+ }
+}
diff --git a/examples/triggers/src/index.ts b/examples/triggers/src/index.ts
new file mode 100644
index 000000000..b5fb7b96f
--- /dev/null
+++ b/examples/triggers/src/index.ts
@@ -0,0 +1,46 @@
+/**
+ * Triggers Example
+ *
+ * This example demonstrates how to use Composio SDK for triggers.
+ *
+ * Prerequisites:
+ * 1. Set up your COMPOSIO_API_KEY in the .env file
+ * 2. Install dependencies: pnpm install
+ * 3. Run the example: pnpm start
+ */
+
+import { Composio } from '@composio/core';
+import 'dotenv/config';
+
+/**
+ * Initialize Composio
+ */
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+});
+
+/**
+ * Main function to run the example
+ */
+async function main() {
+ try {
+ console.log('πŸš€ Starting Triggers Example...');
+
+ // Get available tools
+ const tools = await composio.tools.get('default', {
+ // Specify the apps you want to use
+ // apps: ['gmail', 'googlecalendar'],
+ limit: 10,
+ });
+
+ console.log(`βœ… Found ${tools.length} tools`);
+
+ // TODO: Add your example implementation here
+ console.log('πŸ“ Implement your triggers logic here!');
+ } catch (error) {
+ console.error('❌ Error running example:', error);
+ }
+}
+
+// Run the example
+main().catch(console.error);
diff --git a/examples/triggers/tsconfig.json b/examples/triggers/tsconfig.json
new file mode 100644
index 000000000..158c157c8
--- /dev/null
+++ b/examples/triggers/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "module": "ESNext",
+ "declaration": true,
+ "declarationDir": "./dist",
+ "outDir": "./dist",
+ "rootDir": "./src",
+ "strict": true,
+ "esModuleInterop": true,
+ "moduleResolution": "node",
+ "skipLibCheck": true,
+ "resolveJsonModule": true
+ },
+ "include": ["src"]
+}
diff --git a/package.json b/package.json
index 36c678e78..6e22c70bd 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"prepare": "husky",
"create:provider": "bash scripts/create-provider.sh",
+ "create:example": "bash scripts/create-example.sh",
"check:peer-deps": "tsx scripts/check-peer-deps.ts",
"update:peer-deps": "tsx scripts/update-peer-deps.ts",
"prepublish": "pnpm run build",
diff --git a/packages/core/src/models/Tools.ts b/packages/core/src/models/Tools.ts
index 6935fbb7b..b8a997727 100644
--- a/packages/core/src/models/Tools.ts
+++ b/packages/core/src/models/Tools.ts
@@ -263,7 +263,7 @@ export class Tools<
toolkit_slug: queryParams.data.toolkits?.join(','),
cursor: queryParams.data.cursor,
important: queryParams.data.important,
- limit: queryParams.data.limit,
+ limit: queryParams.data.limit?.toString(),
search: queryParams.data.search,
});
diff --git a/packages/core/src/types/tool.types.ts b/packages/core/src/types/tool.types.ts
index 406639c3b..898bdcc0c 100644
--- a/packages/core/src/types/tool.types.ts
+++ b/packages/core/src/types/tool.types.ts
@@ -59,7 +59,7 @@ export const ToolListParamsSchema = z.object({
tools: z.array(z.string()).optional(),
cursor: z.string().optional(),
important: z.string().optional(),
- limit: z.string().optional(),
+ limit: z.number().optional(),
search: z.string().optional(),
toolkits: z.array(z.string()).optional(),
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7cbf9ac90..4d90b7f3a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -183,6 +183,22 @@ importers:
specifier: ^5.8.3
version: 5.8.3
+ examples/triggers:
+ dependencies:
+ '@composio/core':
+ specifier: workspace:*
+ version: link:../../packages/core
+ dotenv:
+ specifier: ^16.4.1
+ version: 16.5.0
+ devDependencies:
+ '@types/bun':
+ specifier: ^1.2.9
+ version: 1.2.13
+ typescript:
+ specifier: ^5.8.3
+ version: 5.8.3
+
examples/vercel:
dependencies:
'@ai-sdk/openai':
diff --git a/scripts/create-example.sh b/scripts/create-example.sh
new file mode 100755
index 000000000..44ab301eb
--- /dev/null
+++ b/scripts/create-example.sh
@@ -0,0 +1,208 @@
+#!/bin/bash
+
+# Check if example name is provided
+if [ -z "$1" ]; then
+ echo "Please provide an example name"
+ echo "Usage: pnpm create:example <example-name>"
+ exit 1
+fi
+
+EXAMPLE_NAME=$1
+EXAMPLE_PATH="examples/$EXAMPLE_NAME"
+CAPITAL_EXAMPLE_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${EXAMPLE_NAME:0:1})${EXAMPLE_NAME:1}"
+
+# Check if example directory already exists
+if [ -d "$EXAMPLE_PATH" ]; then
+ echo "❌ Example '$EXAMPLE_NAME' already exists in $EXAMPLE_PATH"
+ exit 1
+fi
+
+# Create directory structure
+mkdir -p "$EXAMPLE_PATH/src"
+
+# Create package.json
+cat > "$EXAMPLE_PATH/package.json" << EOL
+{
+ "name": "${EXAMPLE_NAME}-example",
+ "private": true,
+ "version": "0.1.0",
+ "description": "Example project for ${CAPITAL_EXAMPLE_NAME}",
+ "main": "src/index.ts",
+ "scripts": {
+ "start": "bun src/index.ts",
+ "dev": "bun --watch src/index.ts",
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": ["composio", "example", "${EXAMPLE_NAME}"],
+ "author": "",
+ "license": "ISC",
+ "packageManager": "[email protected]",
+ "dependencies": {
+ "@composio/core": "workspace:*",
+ "dotenv": "^16.4.1"
+ },
+ "devDependencies": {
+ "@types/bun": "^1.2.9",
+ "typescript": "^5.8.3"
+ }
+}
+EOL
+
+# Create tsconfig.json
+cat > "$EXAMPLE_PATH/tsconfig.json" << EOL
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "module": "ESNext",
+ "declaration": true,
+ "declarationDir": "./dist",
+ "outDir": "./dist",
+ "rootDir": "./src",
+ "strict": true,
+ "esModuleInterop": true,
+ "moduleResolution": "node",
+ "skipLibCheck": true,
+ "resolveJsonModule": true
+ },
+ "include": ["src"]
+}
+EOL
+
+# Create .env.example
+cat > "$EXAMPLE_PATH/.env.example" << EOL
+# Composio API Key - Get it from https://app.composio.dev
+COMPOSIO_API_KEY=your_composio_api_key_here
+
+# Add other environment variables as needed for your example
+# OPENAI_API_KEY=your_openai_api_key_here
+# ANTHROPIC_API_KEY=your_anthropic_api_key_here
+EOL
+
+# Create .env (copy of .env.example)
+cp "$EXAMPLE_PATH/.env.example" "$EXAMPLE_PATH/.env"
+
+# Create src/index.ts
+cat > "$EXAMPLE_PATH/src/index.ts" << EOL
+/**
+ * ${CAPITAL_EXAMPLE_NAME} Example
+ *
+ * This example demonstrates how to use Composio SDK for ${EXAMPLE_NAME}.
+ *
+ * Prerequisites:
+ * 1. Set up your COMPOSIO_API_KEY in the .env file
+ * 3. Run the example: pnpm start
+ */
+
+import { Composio } from '@composio/core';
+import 'dotenv/config';
+
+/**
+ * Initialize Composio
+ */
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+});
+
+/**
+ * Main function to run the example
+ */
+async function main() {
+ try {
+ console.log('πŸš€ Starting ${CAPITAL_EXAMPLE_NAME} Example...');
+
+ // Get available tools
+ const tools = await composio.tools.get('default', {
+ // Specify the apps you want to use
+ toolkits: ['gmail', 'googlecalendar'],
+ limit: 10,
+ });
+
+ console.log(\`βœ… Found \${tools.length} tools\`);
+
+ // TODO: Add your example implementation here
+ console.log('πŸ“ Implement your ${EXAMPLE_NAME} logic here!');
+
+ } catch (error) {
+ console.error('❌ Error running example:', error);
+ }
+}
+
+// Run the example
+main().catch(console.error);
+EOL
+
+# Create README.md
+cat > "$EXAMPLE_PATH/README.md" << EOL
+# ${CAPITAL_EXAMPLE_NAME} Example
+
+This example demonstrates how to use Composio SDK for ${EXAMPLE_NAME}.
+
+## Setup
+
+1. **Install dependencies:**
+ \`\`\`bash
+ pnpm install
+ \`\`\`
+
+2. **Configure environment:**
+ \`\`\`bash
+ cp .env.example .env
+ \`\`\`
+
+ Then edit \`.env\` and add your API keys:
+ - \`COMPOSIO_API_KEY\`: Get it from [Composio Dashboard](https://app.composio.dev)
+
+## Running the Example
+
+\`\`\`bash
+# Run the example
+pnpm start
+
+# Run in development mode (with file watching)
+pnpm dev
+\`\`\`
+
+## What This Example Does
+
+- Initializes Composio SDK
+- Fetches available tools
+- Demonstrates basic usage patterns
+
+## Customization
+
+Edit \`src/index.ts\` to:
+- Add specific apps you want to integrate with
+- Implement your business logic
+- Add error handling and logging
+
+## Related Examples
+
+- [OpenAI Example](../openai) - Shows integration with OpenAI
+- [LangChain Example](../langchain) - Shows integration with LangChain
+- [More Examples](../) - Browse all available examples
+
+## Support
+
+- [Documentation](https://docs.composio.dev)
+- [Discord Community](https://discord.gg/composio)
+- [GitHub Issues](https://github.com/composio/composio/issues)
+EOL
+
+# Install dependencies using pnpm
+cd "$EXAMPLE_PATH" && pnpm install
+
+echo "✨ Created new example at $EXAMPLE_PATH"
+echo "✨ Dependencies installed successfully"
+echo ""
+echo "πŸ“ Generated files:"
+echo " - package.json"
+echo " - tsconfig.json"
+echo " - .env.example"
+echo " - .env"
+echo " - src/index.ts"
+echo " - README.md"
+echo ""
+echo "πŸš€ Next steps:"
+echo " 1. cd $EXAMPLE_PATH"
+echo " 2. Edit .env and add your COMPOSIO_API_KEY"
+echo " 3. pnpm start"
\ No newline at end of file