Skip to content

ChainGPT Twitter/X AI Agent: A powerful AI-driven Twitter agent built with TypeScript, Hono, and the ultra-fast Bun runtime. Automate tweet generation, posting, and Web3 community engagement effortlessly, enhancing your presence with scheduled tweets and real-time ChainGPT AI integrations.

Notifications You must be signed in to change notification settings

ChainGPT-org/AgenticOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AgenticOS – Your AI Agent for Web3 on X (Twitter)

Built by ChainGPT

AgenticOS lets you effortlessly create and deploy your own intelligent AI agent on X (formerly Twitter)β€”purpose-built for the Web3 ecosystem. Automate tasks like real-time market research, breaking crypto news, token analysis, and community engagement, enhancing your digital presence with 24/7 AI-driven insights.

πŸ“Œ Live Demo: ChainGPT AI on X


πŸš€ Overview

AgenticOS is a TypeScript-based AI agent that automates tweet generation and publishing, leveraging ChainGPT's advanced Web3 LLM API and the ultra-fast Bun runtime. Built for ease of integration and secure performance.

πŸ”₯ Key Features

  • AI-powered Tweet Generation using ChainGPT's Web3 LLM
  • Scheduled Automated Tweets via configurable Cron jobs
  • Webhook Integration with ChainGPT for automatic real-time updates
  • Secure Token Storage with encryption
  • Automatic Twitter Token Refresh (OAuth 2.0)
  • TypeScript for enhanced developer experience and type safety
  • Ultra-fast Bun Runtime for optimal performance

βš™οΈ Requirements

Each generated tweet consumes 1 ChainGPT credit.


πŸ”‘ Quick Start

Step 1: Clone and Set Up

git clone https://github.com/ChainGPT-org/AgenticOS.git
cd AgenticOS

# Install Bun runtime
curl -fsSL https://bun.sh/install | bash

# Install project dependencies
bun install

# Configure your environment
cp .env.example .env

Step 2: Configure .env

Update .env with your details:

PORT=8000
NODE_ENV=development

TWITTER_CLIENT_ID=your_twitter_client_id  # generated from Twitter developer portal
TWITTER_CLIENT_SECRET=your_twitter_client_secret # generated from Twitter developer portal

ENCRYPTION_KEY=your_32_character_encryption_key # set a value and keep it secure
ENCRYPTION_SALT=your_hex_encryption_salt # set a value and keep it secure
ENCRYPTION_IV=your_hex_initialization_vector # set a value and keep it secure

CHAINGPT_API_KEY=your_chaingpt_api_key

PASSWORD_AUTH=your_secure_password # API Authentication Password - Required for managing tokens and secure endpoints

πŸ” Generate Encryption Keys

πŸ” Generate New Keys ↗️

Click the button above to generate secure encryption keys for your .env file


🚩 Usage

Production Mode

bun start

Provide Twitter Access and Refresh Tokens

πŸ” Obtain Access and Refresh Tokens via Login API

To generate your Access Token and Refresh Token, open the following URL in your browser:

# Access token Refresh Token Generator
   https://your-domain.com/api/login
⚠️ Make sure to replace your-domain.com with your actual deployed domain (to deploy you can refer to "Deployment on Render" section).

πŸ“… Automated Tweeting Workflows

Workflow 1: Scheduled Tweeting (Cron)

There are two methods to schedule tweets.

  1. Define your schedule in data/schedule.json:
{
  "05:10": {
    "type": "market_insight",
    "instruction": "{{persona}} and excellent at spotting key market movements. Create a tweet (less than {{maxLength}} characters) that's a meme about crypto."
  },
  "05:30": {
    "type": "meme",
    "instruction": "{{persona}} and excellent at spotting key market movements. Create a tweet (less than {{maxLength}} characters) that's a meme about crypto."
  }
}
  1. Edit schedular in dashboard. You can find dashboard at https://<your_domain>/

    Schedule Interface

Tweets are auto-generated and posted according to this schedule (UTC).

Workflow 2: ChainGPT Webhook for Live News

Subscribe to Categories:

There are two methods to subscribe to categories and register Webhook.

  1. Using following APIs:

Register Webhook:

Register your webhook to automatically receive and post updates:

POST https://{your-domain.com}/api/webhook/register
Headers:
{
  "Authorization": "Bearer <your_password>"
}
Body: { "url": "https://{your-domain.com}/api/webhook/" }

AgenticOS will automatically post tweets from ChainGPT news updates.

Get available categories:

GET https://webapi.chaingpt.org/category-subscription/
Headers:
{
    "api-key": "<your_chainGPT_api_key>"
}

Subscribe to categories: You can subscribe to desired categories using their ids

POST https://webapi.chaingpt.org/category-subscription/subscribe
Headers:
{
    "api-key": "<your_chainGPT_api_key>"
}
Body: { "categoryIds": [2, 3] }
  1. Using Dashboard: Goto following page: https://<your_domain>/live-news

Register Webhook:

Schedule Interface

Subscribe to categories:

Schedule Interface


πŸš€ Deployment on Render

Fork on GitHub

To deploy this application:

  1. First, fork this repository using the "Fork" button
  2. Copy your repository URL from the browser's address bar
  3. Open a new tab and paste this URL:
    https://render.com/deploy?repo=YOUR_REPO_URL
    
    Replace YOUR_REPO_URL with your repository URL

For example, if your repository URL is https://github.com/john-doe/AgenticOS, you would paste:

https://render.com/deploy?repo=https://github.com/john-doe/AgenticOS
  1. Configure environment variables as described in the Configure env section above
  2. Wait for the deployment to complete. This may take a few minutes.
  3. Once deployed, visit your domain and click on the "Refresh Token" tab in the sidebar to get twitter access and refresh token.
  4. You can schedule tweets in the "Scheduler" tab and add webhooks in the "Live News" page.

πŸ“š Project Structure

AgenticOS/
β”œβ”€β”€ data/
β”œβ”€β”€ public/
β”‚   └── images/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ jobs/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ types/
β”‚   β”œβ”€β”€ utils/
β”‚   └── index.ts
β”œβ”€β”€ views/
β”œβ”€β”€ .env.example
β”œβ”€β”€ .npmrc
β”œβ”€β”€ bun.lock
β”œβ”€β”€ package.json
β”œβ”€β”€ postcss.config.js
β”œβ”€β”€ render.yaml
β”œβ”€β”€ tailwind.config.js
└── tsconfig.json

🌐 Why Choose Bun?

  • πŸš€ Superior Performance: Faster execution & startup
  • πŸ›  Built-in TypeScript & ESM Support
  • 🎯 Simplified Development: Integrated tools for testing & bundling
  • πŸ“¦ Compatible with npm packages

πŸ” Security

  • Secure encryption of Twitter tokens
  • Environment variable validation
  • Robust error handling

🀝 Contributing

Contributions are welcome! Follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b feature/my-new-feature
  3. Commit changes: git commit -am 'Add feature'
  4. Push changes: git push origin feature/my-new-feature
  5. Open a Pull Request.

πŸ“œ License

ISC

πŸ§‘β€πŸ’» Author

ChainGPT

πŸ“§ Support

Report issues via GitHub Issues.

πŸš€ Happy Coding!

About

ChainGPT Twitter/X AI Agent: A powerful AI-driven Twitter agent built with TypeScript, Hono, and the ultra-fast Bun runtime. Automate tweet generation, posting, and Web3 community engagement effortlessly, enhancing your presence with scheduled tweets and real-time ChainGPT AI integrations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages