Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Add Ubuntu Guide from idoco#88
  • Loading branch information
fox34 authored May 4, 2020
1 parent df1a412 commit 4a2bb40
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,71 @@ Currently you can customize all visible texts and the main widget color by setti
<script id="intergram" type="text/javascript" src="<Server url>/js/widget.js"></script>
```
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<TOKEN>/setWebhook?url=<https://yourServerURL:8443>/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"

<script id="intergram" type="text/javascript" src="yourServerURL:8443/js/widget.js"></script>
Hope this helps

0 comments on commit 4a2bb40

Please sign in to comment.