intergram icon indicating copy to clipboard operation
intergram copied to clipboard

Self hosting - No Chat id

Open soapoperator opened this issue 7 years ago • 9 comments

Hello,

I try to host this good app. As i am not very familiar with node.js, i think i succeed to go to step 4.

On the webhook, i get : {"ok":true,"result":true,"description":"Webhook was set"}

Unfortunately when i open my bot with /start, no chat id was delivred. So i can't embed the snippet...

Is the webhook well related to the bot configuration? Is there a delay with initialisation? Any idea?

Thank you in advance for the help. jb

soapoperator avatar Mar 14 '17 22:03 soapoperator

Hi @soapoperator Do you see something in the server logs? If the server received your start message and tried to answer it you should see something like /start chatId 123.

If you see this message in the log but not in the chat, it is most likely that you didn't set the .env variable TELEGRAM_TOKEN properly.

If you don't see this log message, try to send a POST message directly to the server /hook from any REST client just to see if it works. You can use this json body to test it -

{
   "message":{
      "chat":{
         "id":123,
         "first_name":"test"
      },
      "text":"/start"
   }
}

idoco avatar Mar 14 '17 22:03 idoco

Thank you @idoco for your quick answer. I don't see anything in the log.

I try to send a POST with the your json to test to https://my.adress.com/hook. And i get an 404:

<h2>Error 404</h2>
<address>
  <a href="/">my.adress.com</a><br />
  <span>Wed Mar 15 21:42:42 2017<br />
  Apache/2.2.31 (Unix) DAV/2 mod_ssl/2.2.31 OpenSSL/1.0.2j</span>
</address>

I guess my app installation is wrong?

soapoperator avatar Mar 15 '17 21:03 soapoperator

Hi, yeah, it might be that you didn't install it right. Did you run npm install and npm start in the cloned folder? When the server starts it logs - listening on port: 3000 did you see that message?

The default server port is 3000, can you try sending the POST to https://my.adress.com:3000/hook, or did you map port 3000 to 80 and expect this to work?

idoco avatar Mar 16 '17 08:03 idoco

Hi, It seems to be better now. I get not error and a beautiful :

listening on port:3000

Unfortunately when i test POST request to https://my.adress.com:3000/hook, i still get an error:

Error: socket hang up

Maybe an error with the server. I will try to start with forever this week-end.

Thank you for the help.

soapoperator avatar Mar 17 '17 22:03 soapoperator

Hi, Sorry for the delay. Start the app with forever doesn't change anything. I get this error: Error: socket hang up With my test request:

{
   "message":{
      "chat":{
         "id":123,
         "first_name":"test"
      },
      "text":"/start"
   }
}

But as i didn't get the chat.id, isn't it normal?

soapoperator avatar Mar 27 '17 04:03 soapoperator

Yes, I didn't expect forever to fix the issue. Did you also try to use http instead of https?

If you want, you can contact me privately by email ido.mapchat at gmail.com or Telegram @idoco and I can connect to your machine and try to debug it

idoco avatar Mar 27 '17 09:03 idoco

idoco,

Thank you for the reply. With http, i get an 200 OK response without anything else. So i try to re /start the bot. No chat id, nothing.

I will send you a message at telegram.

soapoperator avatar Mar 28 '17 04:03 soapoperator

Hi !!!! please i need help ... i make a git clone https://github.com/idoco/intergram.git later... in the folder intergram i make: [root@tte intergram]# npm install npm WARN package.json [email protected] No repository field. npm WARN cannot run in wd [email protected] npm run build (wd=/var/www/html/a2billing/customer/intergram) [root@tte intergram]#

====================================================== LATER: [root@tte intergram]# npm start

[email protected] start /var/www/html/a2billing/customer/intergram node server.js

/var/www/html/a2billing/customer/intergram/server.js:30 let replyText = reply.text || ""; ^^^^^^^^^ SyntaxError: Unexpected identifier at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:945:3 npm ERR! weird error 8 npm ERR! not ok code 0

=======================================================

When i make this commad by a regular user:

[jose@tte intergram]$ npm install npm WARN package.json [email protected] No repository field.

[email protected] postinstall /var/www/html/a2billing/customer/intergram npm run build

[email protected] build /var/www/html/a2billing/customer/intergram shx mkdir -p dist && shx cp *.html dist && shx cp -r ./media dist && shx cp -r ./css dist && webpack -p

/var/www/html/a2billing/customer/intergram/webpack.config.js:1 (function (exports, require, module, __filename, __dirname) { let path = requi ^^^^ SyntaxError: Unexpected identifier at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at module.exports (/var/www/html/a2billing/customer/intergram/node_modules/webpack/bin/convert-argv.js:80:13) at Object. (/var/www/html/a2billing/customer/intergram/node_modules/webpack/bin/webpack.js:39:40) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) npm ERR! weird error 8 npm ERR! not ok code 0 npm ERR! weird error 1 npm ERR! not ok code 0

**always i have errors with npm

Can you help me??

I test this scenario in another linux machines, and always same error...**

joseh55 avatar May 14 '17 00:05 joseh55

@joseh55 try the script on heroku, its easy install and set .env

amudy17 avatar Aug 08 '18 10:08 amudy17