ringcentral / ringcentral-chatbot-js

RingCentral Chatbot Framework for JavaScript
MIT License
10 stars 7 forks source link

Improved bot framework initialization process #11

Open byrnereese opened 5 years ago

byrnereese commented 5 years ago

Right now bots are initialized by running a sequence of commands. Perhaps upon initial server start-up, the framework could detect the current status of various resources and display some useful data to the user. Consider for a moment the following developer experience via the console:

$ node -r dotenv/config express.js Server starting... OK. Listening at http://localhost:3000 Checking https://11ddce98.ngrok.io/... Server not responding... if you are running a proxy, please verify it is running. Aborting...

User starts ngrok. Then...

$ node -r dotenv/config express.js Server starting... OK. Listening at http://localhost:3000 Checking https://11ddce98.ngrok.io/... OK Checking database... Database does not appear configured. Please run the following command: curl -X PUT -u admin:admin https://11ddce98.ngrok.io/admin/setup-database Startup pending. Waiting for database...

User runs the command in another window, and returns to see this output...

Received request: PUT /admin/setup-database Setting up database... OK Checking database... OK Startup complete. Ready for requests...

What is nice about this process is that the user can effectively abandon the README once the server has started. The console will guide them through the rest of the process.

A few more thoughts below...

Database Initialization

In the example above, the user is prompted to curl a URL to setup the database. I wonder, can we setup some logical defaults in the .env-sample, then trigger the database setup process automatically? Consider this...

$ node -r dotenv/config express.js Server starting... OK. Listening at http://localhost:3000 Checking https://11ddce98.ngrok.io/... OK Checking database... Database does not appear configured. Initializing... OK Checking database... OK Startup complete. Waiting for requests...

Other setup steps

Also... can we detect if a bot has been added to glip? If so, that would be a great prompt as well. Not sure if this flow makes sense, but maybe...

$ node -r dotenv/config express.js Server starting... OK. Listening at http://localhost:3000 Checking https://11ddce98.ngrok.io/... OK Checking database... OK Refreshing webhook subscriptions... No active subscriptions. Have you added the bot to Glip? Please visit the following URL and click "Add to Glip": https://developer.ringcentral.com/my-account.html#/application-bot/RC3yW__oRHqmxdoDNrwQDw~FOiT8gUsSBqTVEHP7nQTfw

tylerlong commented 5 years ago

Great ideas!

I also had an idea here: https://github.com/ringcentral/ringcentral-chatbot-js/issues/5 Copy wordpress installation process and provide developer with a page to configure and setup. This way user doesn't even need to create .env file. Because every configuration is entered on the setup webpage. Let me know what do you think of this.