This tutorial assumes you've already completed the steps in the prerequisites section.
Run an existing application¶
Download source code¶
git clone https://github.com/onem-developer/nodejs-onem-todo
We first need to go to the project directory and install the dependencies.
cd nodejs-onem-todo npm install
Your directory should look like:
1 2 3
$ ls api config.js package.json README.md app.js node_modules package-lock.json static
Start the server¶
The above command will run the server locally at http://127.0.0.1:8000.
If you try to access that link you will get a
403 error forbidden response, which is totally fine, since the server is looking into the HTTP headers for specific information sent by ONEm platform.
Expose the server publicly¶
Since our server is now running on your local interface, ONEm platform cannot reach it. But we can work around this by using
Open a new terminal, go to the folder where your ngrok is and start it up on
./ngrok http 8000
The above command will start ngrok tool, which is basically creating a VPN tunnel so our webserver can be publicly reachable.
The output should be something like:
Session Status online Session Expires 7 hours, 59 minutes Update update available (version 2.3.34, Ctrl-U to update) Version 2.3.30 Region United States (us) Web Interface http://127.0.0.1:4040 Forwarding http://5d283db8.ngrok.io -> http://localhost:8000 Forwarding https://5d283db8.ngrok.io -> http://localhost:8000
The last line says that a public URL (https://5d283db8.ngrok.io) has been generated for you, which forwards all the received requests to your computer's server (http://localhost:8000).
Copy the generated URL from your console as we will need it in the next step.
Register the application¶
To register your application open ONEm Developer Portal and register for a free account.
Once that is done, you will have an option to create an app. Hit that button and place the URL generated by
ngrok as the callback URL.
That is it. We can now access the application by placing a hashtag in front of the name.
In the developer portal there is a
Test Client section. This is a phone simulator from where you can test the app.
Head on to the test client and send
#name-of-your-app. At this point ONEm will request the callback URL we've set previously, so if you check the
ngrok logs you will see the request there.
HTTP Requests ------------- GET / 200 OK
In the test client you can see the below response:
#TODO MENU A New todo B Done(0) Todo(0) --Reply A-B
The name of your app will be different, as chosen in the developer portal.
The above SMS response is rendered based on the HTTP JSON response returned by our
Tweak the application¶