Closed ymys closed 9 years ago
Hello,
I'll try to describe the steps one by one:
composer install
in its directory. Then the dependencies will be installed. If you see composer command not found in the terminal, head over to Composer getting started guide and install it, and run the command again.
public
folder, and which should have routes redirected to index.php (think like Laravel's or Wordpress's pretty URLs feature), since this app is build with Silex, you can refer to Silex's official documentation for this. There are examples for Apache and Nginx web servers in the link.The web server should also serve from https (restriction of Telegram) protocol. if you're using Cloudlare DNS, you can have free Flexible SSL which should also work here. Else you need to buy an SSL certificate and install it into your web server. (Self signed SSL certificates don't work!)
To make sure your web server configuration is running, you can make a simple test:
Add this into your public/index.php
before $app->run()
last line:
$app->get('/test', function() use($app) {
return "Test is running, you are awesome!";
});
And navigate to https://yoursite.com/test.
If you see "Test is running, you are awesome!" in the browser, you set the web server right.
config/main.php
file.Let's assume you have a bot called @ymysBot. First, you need an alias (which will be served as route parameter, because this app can handle multiple Telegram bots simultaneously and the alias is what defines to which bot Telegram sends response to) for this.
Let's say alias is ymys for @ymysBot, then config/main.php
's bots
key should be like:
//in config/main.php
'bots' => [
'ymys' => 'ymysBot',
],
Copy or rename config/bots/myDemoBot.php
as config/bots/ymysBot.php
(the name of the bot as file name, not the alias), and fill your API key, and bot responses. You can get the api key from @Botfather from Telegram messenger directly.
Navigate through http(s)://yoursite.com/set_webhook/ymys (ymys = the alias which we've decided moments ago). If everything went okay, you will see a response from Telegram which tells webhook was set.
config/myDemoBot.php
you have two responses: message1 and hodor (please refer to this link and check the highlighted lines if you've lost me.)Now either try sending @ymysBot a message directly or add it to a conversation group.
If you are messaging with the bot directly, you can directly send message1 or hodor as text.
If the bot is in a conversation group, you need to mention it and send the message, like this:
@ymysBot message1 or @ymysBot hodor, the will send the response to the chat.
(p.s: If you typed these, if the hook is set, in the backend, Telegram API sends a POST request to https://yoursite.com/hook/ymys , this is the reason for the alias and SSL)
I hope this message clarifies it a bit. I will try to create a Wiki page after I've completed SQL integration. Nowadays I'm busy with my own work so I cannot find time for them.
Closing this due to inactivity and release of the new version. Please open a new issue when you encounter an error with the new version.
Sorry for asking this, but you said: By installing this app, you can have a working Telegram Bot within minutes!
I'd already follow your instructions, but stuck after eidting config/main.php. How could I navigate to http://yoursite.com/set_webhook/**bothook**? It said error 404.