Welcome to OneChat API β a powerful, easy-to-use instance server system developed by 1Click.AI. π This repository provides everything you need to set up and manage your own instance server for seamless multi-platform bot automation.
- π’ Multi-Platform Support: Connect WhatsApp, Telegram, and Discord instances to the same webhook for unified bot functionality.
- π’ Cross-Platform Presence: Keep your bot available on WhatsApp, Telegram, Discord, and the 1Click.AI app simultaneously.
- π Secure API: Protect your instance server with an API key.
- π OneChat API Documentation: Explore all API routes with an easy-to-use interface.
- π Instance Dashboard: Includes a beautiful, responsive dashboard to monitor and manage instances.
- πΎ Persistent Sessions: Sessions are saved to ensure uninterrupted service.
- π Docker Ready: Deploy effortlessly using Docker Compose.
OneChat API is an advanced multi-platform bot management system designed for developers and businesses to control multiple bot instances across WhatsApp, Telegram, and Discord. It's powered by 1Click.AI's cutting-edge infrastructure and is highly customizable to fit your automation needs.
With OneChat API, you can:
- Manage instances in real time.
- Use a single webhook to receive messages and events from multiple platforms.
- Integrate with your own systems using the secure API.
- Streamline operations with webhooks and automation.
- Docker & Docker Compose: Make sure Docker and Docker Compose are installed.
- Node.js: For local development, install Node.js (if not using Docker).
- Git: Ensure Git is installed to clone the repository.
-
Clone this repository:
git clone https://github.com/1clickai/onechat-api.git cd onechat-api -
Run the containers:
docker-compose up -d
-
Access your instance server:
- Dashboard & Backend: http://localhost:3000
- API Documentation: http://localhost:3000/api-docs
To deploy using EasyPanel, you can use the following JSON schema:
- In EasyPanel, import the JSON schema above without making any edits to it.
{
"services": [
{
"type": "app",
"data": {
"projectName": "1ClickAI",
"serviceName": "onechat-api",
"source": {
"type": "image",
"image": "ghcr.io/1clickai/onechat-api:latest"
},
"domains": [
{
"host": "$(EASYPANEL_DOMAIN)",
"port": 31000
}
],
"env": "SERVER_URL=https://$(PRIMARY_DOMAIN)\nAPI_KEY=YOUR_API_KEY\nPROXY_HOST=\nPROXY_PORT=\nPROXY_PROTOCOL=\nPROXY_USERNAME=\nPROXY_PASSWORD=\nLOG_LEVEL=warn\nDB_CONNECTION_STRING=postgres://postgres:secret@$(PROJECT_NAME)_onechat-db:5432/$(PROJECT_NAME)?sslmode=disable",
"mounts": [
{
"type": "volume",
"name": "node_sessions",
"mountPath": "/app/sessions"
}
]
}
},
{
"type": "postgres",
"data": {
"projectName": "1ClickAI",
"serviceName": "onechat-db",
"image": "postgres:16",
"password": "secret"
}
}
]
}- Open your OneChat API Dashboard
- To access the dashboard, type the
YOUR_API_KEYthat you defined in the Environment Variables. If you need to change theAPI_KEY, simply update it in the Environment Variables, then click "Stop," "Deploy," and "Start" to apply the changes.
The system allows you to configure a webhook URL and an API key through the interface. These inputs are essential for enabling real-time communication between your bot and external systems.
- Webhook URL: Enter the URL of your webhook endpoint.
- Webhook ApiKey: Enter the API key to secure communication with your webhook.
When the bot sends a request to your webhook, it will include the following JSON payload:
{
"platform": "<platform>",
"id": "<id>",
"user": "<user>",
"message": "<message>"
}platform: The platform the message originates from. Possible values are:whatsappdiscordtelegram
id: A unique identifier for the conversation or interaction.user: Information about the user (e.g., user ID or contact information).message: The content of the message to be processed.
Every request includes an Authorization header for security:
Authorization: Bearer <webhook_key>
The <webhook_key> corresponds to the API key you provided during webhook configuration.
The webhook should return the following JSON payload:
{
"message": "Hello World!"
}message: The text the bot will send as a response to the user.
Once the webhook responds with the message field, the bot will reply to the user with the specified text. For example:
-
If your webhook sends back:
{ "message": "Hello World!" } -
The bot replies to the user with:
Hello World!
- Ensure that your webhook is capable of handling and responding to the outlined JSON structure.
- The
Authorizationheader must be validated on your webhook server to ensure secure communication. - The bot will not proceed with a response if the webhook fails to respond or returns an invalid format.
The complete API documentation can be found at /api-docs in your installation.
-
Create Instance:
curl -X POST http://localhost:3000/api/instances -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"udid": "unique-id-123"}'
-
Get QR Data:
curl -X GET http://localhost:3000/api/instances/unique-id-123/qr -H "Authorization: Bearer YOUR_API_KEY" -
Delete Instance:
curl -X DELETE http://localhost:3000/api/instances/unique-id-123 -H "Authorization: Bearer YOUR_API_KEY" -
Update Webhook:
curl -X PATCH http://localhost:3000/api/instances/unique-id-123/webhook -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"webhook": "https://your-webhook-url.com", "webhook_key": "secure-key-1234"}'
-
Disconnect Instance:
curl -X POST http://localhost:3000/api/instances/unique-id-123/disconnect -H "Authorization: Bearer YOUR_API_KEY" -
Send Message:
curl -X POST http://localhost:3000/api/instances/unique-id-123/send-message -H "Authorization: Bearer YOUR_API_KEY" -d '{"platform": "telegram", "recipient": "5492361899", "message": "Hello, this is a test message."}'
Manage your instances visually through an elegant, responsive UI.
Your instance server is protected with API key validation to ensure unauthorized users can't access it.
Receive real-time updates for messages and instance status using webhooks.
Customize your deployment using the following environment variables:
| Variable | Description | Default |
|---|---|---|
SERVER_URL |
Base URL for the server | http://localhost:3000 |
API_KEY |
The API key for secure access | YOUR_API_KEY |
DB_CONNECTION_STRING |
Database connection string | postgresql://onechatuser:secret@db:5432/onechatdb |
PROXY_HOST |
Proxy hostname | |
PROXY_PORT |
Proxy port | |
PROXY_PROTOCOL |
Proxy protocol (e.g., http, https) | |
PROXY_USERNAME |
Proxy username | |
PROXY_PASSWORD |
Proxy password | |
LOG_LEVEL |
Logging level (e.g., warn, info) | warn |
The official Docker image of OneChat API is now available on the GitHub Container Registry. π
You can pull the latest version of the OneChat API Docker image using the following command:
docker pull ghcr.io/1clickai/onechat-api:latestTo run the container, use:
docker run -d -p 3000:3000 --name onechat-api ghcr.io/1clickai/onechat-api:latestReplace 3000:3000 with the appropriate port mapping for your setup.
Stay tuned for updates and improvements! π
We welcome contributions to OneChat API! Please fork the repository and submit a pull request. π€
1Click.AI specializes in developing AI-driven solutions for businesses worldwide. Our mission is to create tools that streamline operations and boost productivity. OneChat API is just one of the many innovative solutions we offer.
For more information, visit our website at 1Click.AI. π
If you encounter any issues, feel free to open an issue in this repository or contact us via email at info@1click.ai.






