Code Monkey home page Code Monkey logo

agentbot's Introduction

AgentHub Telegram Bot Integration

This project integrates Telegram bots with the AgentHub API using the Laravel framework and the BotMan library. It allows for the creation and management of bots through Telegram chat commands, and enables dynamic bot interactions with users.

Features

  • Create and manage bots via Telegram chat commands
  • Dynamically create bots with unique tokens
  • Integrate with the AgentHub API for user and chat creation
  • Handle incoming messages from users and send responses via the AgentHub API
  • Middleware for bot and user authentication
  • Use migrations to create necessary database tables

Requirements

  • PHP >= 8.2
  • Laravel >= 11.0
  • BotMan >= 2.8
  • SQLite database

Installation

  1. Clone the repository:

    git clone https://github.com/sevakode/agentbot.git
    
  2. Install dependencies via Composer:

    composer install
    
  3. Copy the .env.example file to .env and configure the necessary settings, such as database connection and AgentHub API credentials.

  4. Run the database migrations to create the required tables:

    php artisan migrate
    
  5. Start the development server:

    php artisan serve
    

Usage

  1. Create a Telegram bot using BotFather and obtain the bot token.

  2. Send the create_bot command to the main bot in the Telegram chat and follow the instructions to create a new bot.

  3. The bot will be dynamically created with a unique token and ready for use.

  4. Users can interact with the bot by sending messages in the chat.

  5. The bot will handle incoming messages, create users and chats in the AgentHub API, and send responses back to the user.

Configuration

  • Configure the database connection in the .env file.

  • Set the AgentHub API credentials (AGENTHUB_LOGIN and AGENTHUB_PASSWORD) in the .env file.

  • Customize the routes for handling incoming bot messages in the routes/web.php file.

Models

  • Bot: Represents a bot entity with attributes such as token, group ID, authentication code, and user ID.

  • User: Represents a user entity with attributes such as username, chat ID, messenger ID, driver, email, and password.

Controllers

  • BotManController: Handles the main bot interactions, including creating bots, handling dynamic bot messages, and sending responses.

  • AgentBotController: Handles agent bot interactions, including processing commands and messages, and sending dialogs to a specified URL.

Middleware

  • BotAuthenticationMiddleware: Handles bot and user authentication, creating users in the AgentHub API if necessary.

Services

  • AgentHubApiService: Provides methods for interacting with the AgentHub API, including user and chat creation, sending messages, and token management.

Dependencies

  • Laravel Framework
  • BotMan Library
  • AgentHub API

agentbot's People

Contributors

sevakode avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.