Overview
This guide will walk you through creating a functional Atomemo plugin that adds a weather lookup tool. You’ll learn the core concepts of the SDK and have a working plugin by the end.Prerequisites: Complete the installation guide before starting this tutorial.
What We’ll Build
We’ll create a plugin that:- Adds a weather lookup tool
- Uses an API key credential for authentication
- Returns real weather data for any city
- Demonstrates proper error handling
Step-by-Step Guide
Create the plugin instance
Start by importing the SDK and creating a plugin instance with basic metadata:
src/index.ts
The
createPlugin function is async because it fetches user session data in debug mode.Complete Code
Here’s the full plugin implementation:Run Your Plugin
Start the plugin in development mode:Your plugin is now running and connected to Atomemo Hub! It will automatically register in debug mode.
Test Your Plugin
In debug mode, the SDK automatically saves your plugin definition todefinition.json. You can inspect this file to see how your plugin is registered:
View example definition.json
View example definition.json
Key Concepts Learned
Plugin Initialization
Use
createPlugin() to initialize your plugin with metadata and configuration.Credentials
Add credentials with
addCredential() to manage authentication for external services.Tools
Define tools with
addTool() to add capabilities that AI agents can invoke.Lifecycle
Use
run() to start the plugin and connect to Atomemo Hub.Understanding Tool Invocation
When an AI agent invokes your tool, the flow looks like this:Adding Internationalization
Extend your plugin to support multiple languages:Adding Models (Optional)
You can also integrate AI models into your plugin:Error Handling Best Practices
Tool Invocation Errors
Tool Invocation Errors
Always wrap tool logic in try-catch blocks:
Credential Validation
Credential Validation
Throw descriptive errors when authentication fails:
Parameter Validation
Parameter Validation
Validate parameters before processing:
Next Steps
Explore Advanced Features
Learn about advanced SDK features like custom transporter options and model integrations.
Common Issues
Getting Help
Need assistance?- Check the API Reference for detailed documentation
- Browse Examples for more use cases
- Report issues on GitHub
Congratulations! You’ve built your first Atomemo plugin. Continue exploring the SDK to unlock more powerful features.