Comments (20)
Hi Alberto, congrats on making first steps as programmer! Seems like you missing something in the config.js
file. Make sure that all ' or " have the matching symbol (to close it).
from google_sheet_reader_bot.
Thank you emirn for your quick answer!
I've just checked what you asked me but it seems all okay:
module.exports = {
'TelegramProductionURL': 'https://guilizzoni.herokuapp.com', // do not forget trailing "/" !!
'TelegramToken': '12345-sometoken', // Telegram token
'googleSheetKey': 'https://docs.google.com/spreadsheets/d/SOMEKEYHERE/pubhtml', // the key of the google sheet (should be public!), extract key from the google sheet doc public url
"confTimeZone": "Europe/Berlin" // time zone of the conference in the form like "Europe/Berlin", see http://momentjs.com/timezone/
}
Thank you again
Alberto
from google_sheet_reader_bot.
Alberto, thank you for the code sample.
Important: for security purposes I've edited your reply and changed your google sheet key and Telegram token with sample text.
I would regenerate Telegram bot key anyway to avoid issues with the security (if someone saw your telegram secret key then she/he can use your bot instead of you. You should keep this key (token) private.
Your code seems to be OK except that you should change
https://guilizzoni.herokuapp.com
to https://guilizzoni.herokuapp.com/
(with /
symbol at the end)
from google_sheet_reader_bot.
You may also try this (if you are running the bot on Cloud9):
Change
bot = new Bot(config.TelegramToken, { polling: true });
to this (it will set the webhook callback address to your cloud9 ip address
bot = new Bot(config.TelegramToken, { polling: true }); bot.setWebHook("https://" + process.env.IP + ":" + process.env.PORT + "/" + bot.token );
from google_sheet_reader_bot.
As you said me, I've just corrected:
and I changed file "bot.js" in this way:
if(process.env.NODE_ENV === 'production') {
bot = new Bot(config.TelegramToken);
bot.setWebHook(config.TelegramProductionURL + bot.token);
}
else {
bot = new Bot(config.TelegramToken, { polling: true }); bot.setWebHook("https://" + process.env.IP + ":" + process.env.PORT + "/" + bot.token );
}
But these are the results in the terminal window:
Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443"}
at /home/ubuntu/workspace/node_modules/node-telegram-bot-api/src/telegram.js:136:15
at tryCatcher (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues as _onImmediate
at processImmediate as _immediateCallback
Unhandled rejection Error: 409 {"ok":false,"error_code":409,"description":"Conflict: terminated by other long poll or web hook"
at /home/ubuntu/workspace/node_modules/node-telegram-bot-api/src/telegramPolling.js:72:15
at tryCatcher (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/ubuntu/workspace/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues as _onImmediate
at processImmediate as _immediateCallback}
from google_sheet_reader_bot.
Have you tried to deploy it to Heroku? Cloud9 has the limitations on the ports used to run the node.js app as it is intended for dev purposes only. So please try to deply to Heroku, is it working there?
from google_sheet_reader_bot.
I'm sorry but I don't know how to deploy it to Heroku
from google_sheet_reader_bot.
Hi,
thank you for all your assistance!
Today I’ve just tried to deploy the app to Heroku. I say you again that I’m not a programmer, so I’ve tried to do these things that I saw on Heroku website:
- I installed “Heroku toolbelt”
- I logged in my account
- in Heroku web page I connected my app “mat-ban” to my repository in Github “albo94/google_sheet_reader_bot”
- in my repository in Github I copied “config.js.example” into “config.js” and I changed the parameters you explained me in the guide (telegram key, google key,…)
- I went to Heroku console and I wrote “git add .” , “git commit -am "make it better” and “git push heroku master”
Now I don’t know what else I’ve to do to run my application
Thank you for your time and help
Alberto
from google_sheet_reader_bot.
Hi Alberto, great! Deploying to heroku is really next big step!
Seems like you did all things right. Once you called git push heroku master
it should be deployed and run automatically.
Check the status of the app using the heroku logs command heroku logs -t
and it will show live logs from your node.js
app (the telegram bot is just a node.js app that responds to requests from Telegram network).
from google_sheet_reader_bot.
Try to run
heroku logs -t
and then try to send something to your bot. So the Telegram bot will talk to your app and you should be able to see errors in the log (will be displayed in the console in live mode)
from google_sheet_reader_bot.
Unfortunately I always obtain the same error:
2016-08-20T14:43:41.809346+00:00 heroku[router]: at=info method=POST path="/240357515:AAHAre71NZtGulhKW7jXk_Svxk--GSp6tH4" host=mat-ban.herokuapp.com request_id=dcd34792-8c9a-4d2c-8d65-cf4f6bfcb449 fwd="149.154.167.229" dyno=web.1 connect=0ms service=59ms status=200 bytes=196
2016-08-20T14:43:41.947157+00:00 app[web.1]: Error: null
2016-08-20T14:43:41.947192+00:00 app[web.1]: Status code: 400
from google_sheet_reader_bot.
you need to debug your code. stop heroku app.
then run cloud9 app using menu Run - Debug
Set the breakpoint (click on the left near the line where it should stop) right after the line with bot started..
Then it will stop on this line and you may go line by line using Run - Step Over from menu.
The issue is that it is not clear which line causes this error message (Error: null
)
from google_sheet_reader_bot.
I selected show debugger at break
and I run it
but I haven't found the line with bot started
so I didn't set the breakpoint
is bot started
in "bot.js"?
from google_sheet_reader_bot.
Hi Emirn,
I’m sorry but I think I haven’t understood some of your previous steps:
(referring to your initial simple guide)
- I create Google Sheet with data (OK!)
- I publish it to web and I obtain a key (OK!)
- I create an app on Heroku called “ban20”; now I’ve some doubts: 1) I just have to create the app and nothing else, or I’ve to connect the app with my repository in Github “albo94/google_sheet_reader_bot”? 2) Do I need to deploy it to Heroku or not? (The first time I’ve done it, I’ve just created the app and nothing else..is it ok?)
- I create an account in c9.io and I create a Node.js workspace called again “ban20”; now, in the process of creation, I put in an option field called “Clone from Git” the string “[email protected]:albo94/google_sheet_reader_bot.git”…..is it ok?
- I create a new telegram bot with BotFather and I obtain a telegram key (OK!)
- in Cloud9 website, I copy config.js.example into config.js and I replace my keys (OK!)
- in a terminal windows in Cloud9 website, I write these commands:
nam install
,git add .
,git commit -m “initial version”
,git push
- always in the same terminal windows (in Cloud9 website), I write the last command
node .
- I open the telegram bot and I write Hi
I write you all "my" detailed guide because maybe I haven't understood something and I commit a banal error because it seems strange to me that I've so many problems following your guide.
Thank you again for all your help!
Alberto
from google_sheet_reader_bot.
All seems to be right and that is why can't advise any particular thing except placing debugger
command into the code (like this) so node.js will stop the console where you may type n
to go line by line and find where it causes the crash.
about Heroku and Cloud9: you may run the app on Cloud9 but it is for development purposes. For production you should deploy to Heroku (it hosts the production server app).
from google_sheet_reader_bot.
you don't have to connect Heroku to Github because Heroku itself is the Git. For some developers who store the code in Github this connection makes autosync of the code from Github to Heroku.
Actually you may use Heroku to store the code too using git
(it just don't have issues, discussion and interface to edit files on web)
from google_sheet_reader_bot.
Referring to your second message, I deleted the connection between Github and Heroku and I deployed again to Heroku. When I write git push heroic master
, the result is:
error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/ban20.git'
now I try to do what you explained me in the first message
thank you
from google_sheet_reader_bot.
now I put the debugger
in the bot.js
file and it seems all right (from beginning to end)
I'm so sorry but which file is my source code?
from google_sheet_reader_bot.
sorry for delays - need to try to reproduce it! Don't have any ideas - I suggest you to find JS developer who could check your code live.
I've checked the telegram bot which is running on Heroku based on this code and it is all works fine still but maybe something was changed in the npm packages used and so on
from google_sheet_reader_bot.
thank you again for all your help and your time
i'll try another way
thanks
alberto
from google_sheet_reader_bot.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google_sheet_reader_bot.