Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram BOT - setWebhook not working

I'm new to creating telegram bots and I really don't know where to start. Only thing I know about is PHP.

Making it simple I have a VPS with Windows Server 2008 R2 installed on it and I've made a self-signed certificate using

openssl req -newkey rsa:2048 -sha256 -nodes -keyout server.key -x509 -days 365 -out server.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"

Then I converted PEM to CER using

openssl x509 -inform PEM -in server.pem -outform DER -out server.cer

I'v had WAMP server installed and set it to work with server.cer & server.key as certificate and key then I'v tested the HTTPS(443) and it worked.

Then I installed a REST client on the chrome and sent URL of the bot.php and PEM file as multipart form data as the official documentation said.

Now I get this error:

{
    ok: false,
    error_code: 400,
    description: "Error: Bad webhook: Posix Error: Success: getaddrinfo: Name or service not known"
}

and ... I'm here now ! :| asking you for help What is the problem and how should I solve this

Thanks in advance :)

NOTE: I don't have a domain I'm using my VPS's IP

like image 624
Ebrahim Tahernejad Avatar asked Oct 29 '15 18:10

Ebrahim Tahernejad


People also ask

Why Telegram bots are not working?

Suggestions: Ensure the Bot is in the group and as an admin. Try adding a new access token (revoke existing API key and create a new one then replace in plugin settings) If you edited the bot with @BotFather, make sure to restore it to the default settings.


1 Answers

Telegram requires valid ssl certificate for your domain.

I will tell how I solved this.

You can use NGROK that can expose local ip to the internet with temporary domain and https enabled.

Link to install - https://ngrok.com/

After you install it, just run in your console:

ngrok http 127.0.0.1:8003

(ofc use ip and port of from your WAMP configuration)

and you will get a free temporary domain (it will look like https://f9eb2f08.ngrok.io) with https enabled.

Then set url with your new domain as a telegram webhook_url and bot's requests will go to your local server as long as NGROK is running.

like image 101
IYHunko Avatar answered Sep 30 '22 17:09

IYHunko