Giter Club home page Giter Club logo

botter's Introduction

Packagist Packagist Version GitHub issues

Botter is a PHP library, designed to build powerful Telegram bots in the fastest and easiest way possible.

require_once "vendor/autoload.php";

use ffb255\Botter\BotterFactory;
use ffb255\Botter\Updates\Events\On;

$config = [
     'token' => "YOUR_BOT_TOKEN"
];
$botter = BotterFactory::create($config);

On::text("/start", function() use ($botter) {
    $botter->reply("Hello user!");
});

$botter->listen();

Features

  • Conversations: Building chatbots often requires gathering information from users through conversations. Botter provides an intuitive way to handle conversations, enabling you to create interactive and dynamic bot interactions. This feature allows you to create conversational flows and collect user input efficiently.
  • Custom Request Builder: With Botter's custom request builder, you have full control over the requests sent to the Telegram Bot API. This flexibility allows you to tailor the requests according to your specific bot requirements. You can easily customize and extend your bot's functionality by leveraging the request builder feature.
  • Multi-Level Cache Storage (Redis, JsonFile and etc..): Botter supports multi-level cache storage, including popular options like Redis, JsonFile, and more. This feature helps optimize bot performance by caching frequently accessed data and reducing the need for repetitive API and Database calls.
  • Readable Codes: Botter is designed with readability in mind, making it easy to understand and maintain your bot's codebase. The library follows clear and consistent coding conventions, allowing you and your team to collaborate seamlessly. By using Botter, you can write clean and readable code that enhances code quality and promotes efficient development.
  • Incoming update AutoComplete in IDEs (OO): Botter provides comprehensive incoming update autocomplete functionality in popular IDEs. This feature assists developers in leveraging Botter's full object-oriented programming (OOP) capabilities when handling incoming updates. With autocomplete support, you can easily explore available methods and properties, improving development speed and reducing errors.

alt text

Installation

Using Composer:
composer require ffb255/botter

Documentation

Check Wiki Pages for documentation.
You can find Botter's API with their examples in the wiki.

Conversation

When it comes to chatbots, you probably don't want to react to single keywords, but instead, you might need to gather information from the user, using a conversation. Let's say that you want your chatbot to provide a rich user onboarding experience for your application users. In the onboarding process, we are going to ask the user for their first name and email address - that's a perfect fit for conversations! (More on Conversation Wiki)

$config = [
     'token' => "YOUR_BOT_TOKEN"
];
$botter = BotterFactory::create($config);

class SignupConversation extends Conversation {
     public function start()
     {
          $this->say("Welcome, Whats your name?");
          $this->next("askEmail");
     }

     public function askEmail()
     {
          $this->name = $this->getAnswer()->getText();
          $this->say("Whats your email?");
          $this->next("finishSignup");
     }

     public function finishSignup()
     {
          $name = $this->name;
          $this->say("Thanks {$name}! Your account has been created.");
          $this->finish();
     }
}

On::text("/signup", function() use($botter){
     $botter->startConversation(new SignupConversation);
});

$botter->listen();

Why did I make Botter?

Botter was created to simplify the process of building Telegram bots for my personal projects. After two years, it was released as an open-source library. While Botter aims to provide a smooth experience, there might still be some issues that are actively being addressed. If you encounter any problems, please feel free to report them in the Issues section.

License

Botter is free software distributed under the terms of the MIT license.

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.