Modl Documentation
Welcome to the official documentation for Modl, a modern toolkit for creating, training, and deploying AI agents. Modl combines Python’s robust AI capabilities with Next.js’s dynamic dashboards to offer a seamless, developer-friendly experience. Whether you're automating tasks, building conversational agents, or managing social media bots, Modl empowers you to deploy AI agents across platforms like Discord, Twitter, and Telegram effortlessly.
Key Features
Hybrid Architecture: Python for backend AI logic, Next.js for frontend management.
Cross-Platform Integration: Build agents for Discord, Twitter, Telegram, and more.
Ease of Use: Prebuilt modules, APIs, and dashboards make development intuitive.
Extensibility: Easily customize and expand functionality with Modl’s modular design.
Getting Started
Prerequisites
Ensure you have the following installed:
Python (3.8 or higher)
Node.js (Latest LTS version)
npm or yarn (for managing frontend dependencies)
Installation
Set Up Python Dependencies Create a
requirements.txt
file and include the following:Copy
Then install the dependencies:
Copy
Set Up Node.js Dependencies Install the required frontend dependencies:
Copy
Or use yarn:
Copy
Configure Environment Variables Create a
.env
file in the root of your project and include your platform API keys:Copy
Core Concepts
Agents
Agents are the heart of Modl. They encapsulate AI functionality, connecting your logic to external platforms like Discord, Twitter, or Telegram.
Training
Modl allows you to train AI models using prebuilt pipelines or custom datasets. You can incorporate libraries like TensorFlow, PyTorch, or transformers to optimize performance.
Platform Integrations
Modl simplifies connecting your agents to platforms via API keys. Each platform has dedicated modules for quick integration.
Deployment Workflows
Deploy agents with minimal setup. Use Next.js dashboards for real-time monitoring, performance insights, and updates.
Quickstart Guide
Follow these steps to create, train, and deploy a simple Discord chatbot.
Create an Agent
Copy
Train the Agent
Copy
Deploy the Agent Run the following command to deploy the agent:
Copy
Monitor and Manage Open the dashboard:
Copy
Use it to track performance and fine-tune configurations.
API Reference
Python API
DiscordAgent
Copy
Trainer
Copy
JavaScript API
deploy
Copy
Platform Integrations
Discord
Register your bot on the Discord Developer Portal.
Obtain your bot’s token and add it to your
.env
file.Start your agent:
Copy
Twitter
Create a developer account on the Twitter Developer Portal.
Generate API keys and add them to your
.env
file.Use Modl’s
TwitterAgent
to integrate:Copy
Telegram
Register your bot with BotFather.
Add your bot token to the
.env
file.Deploy the bot:
Copy
Customization
Adding Custom Logic
Extend Modl’s functionality by subclassing its core classes:
Copy
Creating New Integrations
Refer to the platform’s API documentation.
Wrap the functionality in a custom class compatible with Modl.
Best Practices
Prepare Your Data: Ensure datasets are clean, labeled, and diverse.
Monitor Performance: Use the Next.js dashboard to track key metrics.
Scale Responsibly: For high traffic, consider hosting agents on cloud services.
Troubleshooting
Common Issues
Environment Variables Not Found: Ensure
.env
is correctly configured.Dependency Errors: Re-run installation commands (
pip install -r requirements.txt
andnpm install
).Agent Not Responding: Verify API keys and check the agent’s status.
Debugging Tips
Use logging for detailed error tracking:
Copy
Refer to the platform’s API documentation for common error codes.
Frequently Asked Questions
Q: Can I use Modl without the dashboard? Yes, but the dashboard significantly enhances usability and monitoring.
Q: Does Modl support other platforms? Yes, Modl is extensible and can support additional platforms through custom integrations.
Twitter Integration
Modl makes it easy to build, train, and deploy AI agents for Twitter. This section will guide you through the process of creating a Twitter bot using Modl’s tools and integrating it with the Twitter API. You’ll learn how to set up a basic bot that can respond to tweets, retweet, and post updates automatically.
Setting Up Your Twitter Agent
Step 1: Obtain Twitter API Keys
To interact with Twitter, you need API keys. Follow these steps:
Go to the Twitter Developer Portal and log in with your account.
Create a new project and app.
Generate the following keys:
API Key
API Key Secret
Access Token
Access Token Secret
Add these keys to your
.env
file:Copy
Writing Your Twitter Agent
Create a file (e.g., twitter_bot.py
) and write the following code:
Copy
Training the Agent
If your bot uses AI for advanced responses, you can train it using Modl’s training tools. For instance:
Copy
Deploying the Agent
To deploy your Twitter bot, follow these steps:
Step 1: Run Your Bot Locally
Run the script locally to test the bot:
Copy
Step 2: Deploy Using Modl Dashboard
Launch the Modl Next.js dashboard:
Copy
Navigate to the dashboard at
http://localhost:3000
.Add your bot under the "Agents" section.
Configure deployment settings, including:
Frequency of actions (e.g., how often to check for new tweets).
Rules for responding to users or hashtags.
Click "Deploy" to launch your bot.
5. Example Use Case: Twitter Community Bot
Here’s an example of a bot that:
Welcomes new followers.
Responds to specific mentions.
Retweets posts with a specific hashtag.
Copy
Deploy the bot using the same steps as above to make it live.
6. Monitoring and Managing Your Twitter Bot
Use the Modl dashboard to monitor your bot in real time:
Analytics: Track engagement metrics (e.g., tweets posted, followers gained, hashtags used).
Logs: Review the bot’s activity for debugging or analysis.
Updates: Modify bot behavior or retrain the model without downtime.
7. Troubleshooting
Issue: Bot not responding to tweets.
Solution: Check your API keys in the
.env
file and ensure the bot is running.
Issue: Deployment fails.
Solution: Ensure Node.js is installed and that you ran
npm install
in your project directory.
Issue: Rate limits reached.
Solution: Use Twitter’s API documentation to optimize the bot’s activity.
Discord Integration
Modl makes it simple to create Discord bots that can interact with users, moderate communities, and automate tasks. This guide walks you through setting up, developing, and deploying your Discord agent using Modl.
1. Setting Up Your Discord Agent
Step 1: Register Your Bot
Go to the Discord Developer Portal and log in.
Click “New Application” to create a new bot.
Under the “Bot” section:
Click “Add Bot”.
Copy the bot token and store it securely.
Step 2: Add Your Bot to a Server
In the OAuth2 tab, under “URL Generator”, select:
bot
under Scopes.Permissions such as
Send Messages
,Read Message History
, andManage Roles
under Bot Permissions.
Copy the generated URL and paste it into your browser to invite the bot to your server.
Step 3: Configure Environment Variables
Add the bot token to your .env
file:
Copy
2. Writing Your Discord Agent
Create a file (e.g., discord_bot.py
) and write the following code:
Copy
3. Training the Agent (Optional)
If your bot needs advanced AI capabilities, such as sentiment analysis or question-answering, you can train it using Modl’s tools:
Copy
This allows your bot to handle more complex interactions like dynamic conversations or user-specific responses.
4. Deploying the Agent
Step 1: Run the Bot Locally
Test the bot locally to ensure it works as expected:
Copy
Step 2: Deploy Using Modl’s Dashboard
Launch the Modl Next.js dashboard:
Copy
Navigate to
http://localhost:3000
in your browser.Add your Discord bot under the “Agents” section.
Configure deployment options:
Set response rules (e.g., commands, reaction handling).
Define server-specific behaviors.
Click “Deploy” to launch your bot.
5. Example Use Case: Moderation Bot
Here’s an example of a Discord bot that:
Deletes messages containing banned words.
Welcomes new users to the server.
Assigns roles automatically.
Copy
Deploy this bot using the same steps as outlined above.
6. Monitoring and Managing Your Discord Bot
Use the Modl dashboard to:
Track the bot’s activity, including messages processed, commands handled, and user interactions.
Update banned words or server-specific settings dynamically.
Stop or restart the bot without downtime.
7. Troubleshooting
Issue: Bot not responding to messages.
Solution: Ensure the API key in the
.env
file is correct and matches the bot’s token in the Discord Developer Portal.
Issue: Missing permissions.
Solution: Re-invite the bot with the correct permissions using the OAuth2 URL generator.
Issue: Deployment issues.
Solution: Restart the Modl dashboard and verify Node.js dependencies are installed (
npm install
).
Telegram Integration
Modl makes it straightforward to create Telegram bots for automating tasks, engaging users, and managing communities. This guide will walk you through setting up, coding, and deploying a Telegram bot using Modl’s tools.
1. Setting Up Your Telegram Agent
Step 1: Register Your Bot
Open Telegram and search for BotFather.
Start a chat with BotFather and send the command:
Copy
Follow the prompts to:
Name your bot.
Set a unique username for your bot (must end in
bot
).
Once created, BotFather will provide an API Token. Save it securely.
Step 2: Configure Environment Variables
Add the token to your .env
file:
Copy
2. Writing Your Telegram Agent
Create a file (e.g., telegram_bot.py
) and write the following code:
Copy
3. Training the Agent (Optional)
If your bot requires more advanced AI-driven responses, you can train it using Modl’s tools:
Copy
4. Deploying the Agent
Step 1: Run the Bot Locally
Test your bot locally before deployment:
Copy
Step 2: Deploy Using Modl’s Dashboard
Launch the Modl Next.js dashboard:
Copy
Open the dashboard in your browser at
http://localhost:3000
.Add your Telegram bot under the "Agents" section.
Configure deployment options:
Set rules for responding to messages and commands.
Enable or disable specific features like inline queries.
Click "Deploy" to make your bot live.
5. Example Use Case: FAQ Bot
Here’s an example of a Telegram bot that:
Provides answers to frequently asked questions.
Sends rich content like images or buttons.
Copy
Deploy this bot using the same steps as described earlier.
6. Monitoring and Managing Your Telegram Bot
The Modl dashboard allows you to:
View bot interactions, including messages handled and commands executed.
Adjust FAQ topics or custom callbacks dynamically.
Monitor the bot’s uptime and performance metrics.
7. Troubleshooting
Issue: Bot not responding to messages.
Solution: Verify that the API token in the
.env
file matches the token provided by BotFather.
Issue: Deployment fails.
Solution: Ensure the Modl dashboard is running and all dependencies are installed (
npm install
).
Issue: Callback buttons not working.
Solution: Double-check the callback data and ensure the bot is properly handling it.
Last updated