Creating Custom Tools
This guide walks through the process of creating and registering custom tools in the Cognipeer platform, allowing your AI assistants to interact with your external systems.
Step 1: Plan Your Tool
Before coding, define what your tool will do:
- Identify Purpose: What data or actions will this tool provide?
- Define Actions: What specific operations should be available?
- Determine Parameters: What inputs will each action require?
- Plan API Endpoints: What endpoints will serve these actions?
Step 2: Implement Your API
Develop the API endpoints that will power your custom tool:
- Create a new or use an existing API service
- Implement secure authentication
- Build endpoints for each tool action
- Follow the API implementation guidelines
- Test the endpoints thoroughly
Your API should:
- Accept parameters in the format defined by your tool schema
- Return properly formatted JSON responses
- Handle errors gracefully
- Process requests quickly (ideally under 3 seconds)
Step 3: Create the Tool Definition
Create a JSON definition for your tool following the custom tool format:
{
"name": "CRMTool",
"label": "CRM Integration Tool",
"actions": [
{
"name": "getCustomer",
"description": "Retrieves customer information from the CRM system",
"displayName": "Get Customer Information",
"api": {
"url": "https://api.yourcompany.com/crm/customers",
"method": "GET",
"headers": {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
},
"parameters": {
"type": "object",
"properties": {
"customerId": {
"type": "string",
"description": "Unique identifier of the customer",
"required": false
},
"email": {
"type": "string",
"description": "Email address of the customer",
"required": false
}
}
}
},
// Additional actions...
]
}
Step 4: Register Your Tool in Cognipeer
Register your custom tool in the Cognipeer platform:
- Log in to the Cognipeer Dashboard
- Navigate to Tools > Custom Tools
- Click Add New Tool
- Enter a name and description for your tool
- Paste your JSON tool definition
- Click Save Tool
Step 5: Associate Tool with Peers
Connect your custom tool to specific Peers:
- Go to the Peers section in the dashboard
- Select the Peer you want to enhance
- Navigate to the Tools tab
- Enable your custom tool
- Save the changes
Step 6: Test Your Tool
Test that your tool works correctly:
- Open a conversation with the associated Peer
- Ask a question that should trigger tool usage
- Verify that the tool is called with correct parameters
- Check that the response is properly incorporated
Example conversation flow:
User: "Can you tell me about customer Jane Smith?"
Peer: [Calls getCustomer tool with {email: "jane.smith@example.com"}]
Peer: "Jane Smith is a Premium tier customer who joined on January 15, 2025.
She has purchased 3 products in the last 6 months and has an active support ticket
regarding her recent order #12345."
Debugging Tips
If your tool isn't working as expected:
- Check API Logs: Verify if the API is being called
- Review Parameters: Ensure parameters are being passed correctly
- Test Directly: Call your API endpoints directly to verify they work
- Examine Responses: Check if your API is returning appropriate responses
- Review Tool Definitions: Make sure your JSON schema is valid
Security Considerations
When implementing custom tools:
- Use HTTPS: Secure all API endpoints
- Secure Authentication: Use strong API authentication
- Validate Input: Check all parameters before processing
- Rate Limiting: Prevent abuse of your API
- Data Privacy: Only return information appropriate for the user
Advanced Features
Default Parameter Values
You can set default values for parameters:
"parameters": {
"type": "object",
"properties": {
"limit": {
"type": "number",
"description": "Maximum number of results to return",
"default": 10
}
}
}
Dependent Parameters
Some parameters may depend on others:
"parameters": {
"type": "object",
"properties": {
"searchType": {
"type": "string",
"enum": ["name", "email", "id"],
"description": "Type of search to perform"
},
"searchValue": {
"type": "string",
"description": "Value to search for based on searchType"
}
}
}
Response Templates
Provide hints for how the AI should format responses:
"responseTemplate": "Customer {name} has been with us since {signupDate}. Account status: {status}."
Example Use Cases
Common custom tool implementations:
CRM Integration
- Get customer details
- Create/update customer records
- View purchase history
- Check support tickets
ERP/Inventory System
- Check product availability
- View pricing information
- Process orders
- Check shipping status
Ticketing System
- Create support tickets
- Check ticket status
- Update ticket information
- Assign tickets to team members
Calendar/Scheduling
- View available time slots
- Book appointments
- Reschedule meetings
- Send calendar invites
Best Practices
- Clear Descriptions: Write detailed action and parameter descriptions
- Consistent Naming: Use clear, consistent naming conventions
- Appropriate Permissions: Only expose actions that are appropriate for users
- Limited Scope: Each tool should have a focused purpose
- Regular Updates: Keep your tool definitions and APIs updated
- Comprehensive Testing: Test all possible parameter combinations