swsnu / swpp2019-team7

1 stars 1 forks source link

telegram bot integration #67

Closed jaehunjung1 closed 4 years ago

jaehunjung1 commented 4 years ago

Currently implemented webhook for telegram bot, such that when bot receives some message, the telegram server sends us post request to notify us.

jaehunjung1 commented 4 years ago

But to run the webhook, we need public ip address to which telegram server will send request. Since we do not have any domain yet, in order to run webhook in local, you need to follow below steps.

  1. you should download ngrok and start it at the same port with the backend (8000 default) like ngrok http 8000. This will give you temporary public address for our backend.
  2. Then, you need to register this as our webhook, by sending GET request to api.telegram.org/bot1007785006:AAGZNrBr4w-Eovrf-ZQj7P7MSN6KS3Cl23g/setWebHook?url=https://SOMETHING.ngrok.io/api/telegram/
  3. Run our server as usual.
  4. When you send any message to telegram's @PillBoxNotificationBot, you will see that backend server receives POST request containing information about the message.

But I recommend not to try this at home... except when you really need it for debugging!

jinsun-yoo commented 4 years ago

Open again for Reference