From 4a2bb4078e06a14b724ec3486556402101373808 Mon Sep 17 00:00:00 2001 From: fox34 Date: Mon, 4 May 2020 11:31:53 +0200 Subject: [PATCH] Update README.md Add Ubuntu Guide from https://github.com/idoco/intergram/issues/88 --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/README.md b/README.md index 0347994..46d9904 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,71 @@ Currently you can customize all visible texts and the main widget color by setti ``` 6. :tada: + +### Install on Ubuntu + +Source: https://github.com/idoco/intergram/issues/88 + +Install on Ubuntu 18.04.4 LTS to run standalone +(I condense a 14 hour research and headaches into a 5 minutes install) + +Make sure you have the latest node.js and npm + +Create your bot with @Botfather (/newbot) + +add `TELEGRAM_TOKEN` with the value you got from @Botfather in /etc/environment (TELEGRAM_TOKEN="theToken Value") + +apt-get update + +apt-get install -y curl gnupg2 git build-essential + +cd /opt + +git clone https://github.com/idoco/intergram + +cd /opt/intergram + +edit server.js and add the following at the top: + +const fs = require('fs') // Required for reading the certificate and key files +let options = { key: fs.readFileSync("/opt/intergram/key.pem"), cert: fs.readFileSync("/opt/intergram/bundle.crt") }; + +replace the line +const http = require ('http').Server(app); +with +const http = require ('https').Server(options,app); + +change the port as 3000 does not seem to be allowed -i have also added a line to see if we get the TELEGRAM_TOKEN from environment +http.listen(process.env.PORT || 8443, function(){ +console.log('listening on port:' + (process.env.PORT || 8443)); +console.log(process.env.TELEGRAM_TOKEN); +}); + +**IMPORTANT! YOUR CERTIFICATE MUST ALSO CONTAIN THE INTERMEDIATE CERTIFICATE AT THE BOTTOM OTHERWISE THE HOOK WILL NOT WORK** +SEE https://cubewebsites.com/guides/fix-telegram-webhooks-not-working/ + +Point the bot webhook to your bot server by making a `GET` request to the following url (just put the address in your browser) +`https://api.telegram.org/bot/setWebhook?url=/hook` + +npm install + +npm run build + +npm start + +you should see: +listening on port:8443 +1xxxxxxxxxxxxxxxxxV10etq-UVxxxxxxxxxxxxxhAIU3XYZtkI + +test by navigating on your browser to https://yourServerURL:8443 +you should get the demo page + +type /start in your bot in order to get the client-id + +in your project: +window.intergramId = "client-id" +window.intergramServer = "https://yourServerURL:8443" + + +Hope this helps +