Overview
Kapso agents can be extended with custom tools:- App integrations - OAuth-based connections to popular apps (Google, Slack, etc.)
- Functions - Serverless JavaScript functions for custom logic
- Webhook tools - Direct HTTP calls to any API
- MCP servers - Model Context Protocol servers for dynamic tools
What we’re building
We’ll create a Lead Collection Agent that can:- Capture lead information through natural conversation
- Send notifications to your Slack channel
- Store lead data in Google Sheets for tracking
How it works
The agent uses:- App Integrations: Connections to Slack and Google Sheets
- Function: Orchestrates both integrations into a single tool
- SubagentNode: Handles the conversation and calls the function
Prerequisites
- A Kapso project
- A Slack workspace
- A Google account with Google Sheets
Method 1: Using the Web Interface
This method requires no coding - everything is configured through the Kapso web app.Step 1: Enable the App integrations addon
- Go to Project Settings → Billing
- In the Addons section, toggle on App integrations
- Click Save
Step 2: Connect app integrations
We’ll need two integrations:Integration 1: Google Sheets - Add Row
- Navigate to Tools → App integrations
- Click Configure New Action
- Search for “Google Sheets” and select it
- Choose the Add Single Row action
- Click Connect Account and authorize your Google account
-
Configure the action:
- Name: “Save Lead to Sheet”
- Drive: Select your Google Drive
- Spreadsheet: Select or create a spreadsheet for leads
-
Worksheet Name:
Sheet1
(or your preferred sheet) Map the columns to variables: -
Name:
{{name}}
-
Email:
{{email}}
-
Company:
{{company}}
-
Timestamp:
{{timestamp}}
-
Source:
{{source}}
Variables explained: The
{{variableName}}
syntax creates placeholders that your agent will fill in. When the agent calls this integration with{name: "Sarah", email: "sarah@techcorp.com"}
, those values replace the variables. - Click Save
- Note the Integration ID (shown at the top of the page)
Integration 2: Slack - Send Message
- Click Configure New Action again
- Search for “Slack” → Send Message to a Public Channel action
- Click Connect Account and authorize your Slack workspace
- Configure the action:
- Name: “Notify Sales Team”
- Channel: Select your sales/leads channel
- Message Text:
- Click Save
- Note this Integration ID too
Step 3: Create a function to orchestrate both integrations
This function will handle both saving to Google Sheets and notifying Slack in a single call.- Navigate to Tools → Functions
- Click Create Function
- Name it
capture-lead
- Add this code:
- Click Settings → Environment Variables and add:
SHEETS_INTEGRATION_ID
= your Google Sheets integration IDSLACK_INTEGRATION_ID
= your Slack integration ID
- Click Save and Deploy
- Note the Function ID (e.g.,
fn_capture123
)
Step 4: Create an agent with SubagentNode
Now we’ll create an agent that uses the function as a single webhook tool.- Navigate to Agents & Flows → Agents
- Click Create Agent
- Name it “Lead Collector”
- In the canvas, add a SubagentNode:
- Name:
lead_collector
- Prompt:
- Name:
Step 5: Add webhook tool to the SubagentNode
- Click on the SubagentNode to edit it
- In the Tools section, click Add Tool
- Select Webhook Tool and configure:
- Name:
capture_lead
- URL:
https://app.kapso.ai/api/v1/functions/YOUR_FUNCTION_ID/invoke
(Replace with your function ID from Step 3) - Method:
POST
- Headers:
- Body Schema:
- Description: “Capture lead by saving to Google Sheets and notifying Slack”
- Name:
Step 6: Connect nodes and test
- Connect the nodes: Start → lead_collector → End
- Click Save
- Click Test to try your agent
- Example conversations to test:
- “I’m interested in your product”
- “Can you tell me more about your services?”
- “I’d like to schedule a demo”
Step 7: Deploy and integrate
Once testing is complete:- Click Deploy in the agent editor
- Integrate with your website chat widget or messaging platform
- Your lead collection agent is now live!
Method 2: Using CLI and Builder SDK
This method gives you full programmatic control over your agent.Step 1: Set up your environment
Step 2: Enable addon and connect app integrations
Even when using the CLI, app integrations must be configured through the web interface:- Go to app.kapso.ai → Project Settings → Billing
- Enable App integrations addon
- Navigate to Tools → App integrations
- Configure Google Sheets and Slack integrations as described in Method 1
- Note both Integration IDs
Step 3: Create and deploy the function
Createfunctions/capture-lead.js
:
Step 4: Build the agent
Createagent.py
:
Step 5: Test locally
Step 6: Deploy to production
MCP Server Configuration
For flows, useFlowAgentMcpServer
to add MCP servers (HTTP streamable transport only):
Key Takeaways
This example demonstrates how functions can orchestrate multiple app integrations:- Single tool for the agent: Instead of giving the agent two separate tools, we created one function that handles both operations
- Error handling: The function can handle failures gracefully and provide meaningful error messages
- Data transformation: The function adds timestamp and source information automatically
- Simplified agent logic: The agent only needs to understand one tool instead of coordinating multiple calls
- You need to perform multiple related actions together
- You want to add business logic between API calls
- You need to transform or enrich data before sending to integrations
- You want to provide a simpler interface for your agents