Deploying your bot locally

Gupshup allows you to write the bot code outside Gupshup's Bot Builder tool in any programming language of your choice.You can then associate a callback to the bot on Gupshup's platform.This callback will be the location of your bot code on the server where you have hosted the code. Whenever the bot is called by the user, Gupshup will send the relevant details to your bot through the callback URL using which you can respond back to the user.

If you are building your bot and are using Gupshup's callback URL feature you can test your bot locally. To do this we recommend this nifty tool developed by @inconshreveable called ngrok. This tool allows you to test your bot locally and provide a secure, public-facing URL that you can use as your callback URL. Here's a quick guide on how you can start host botcode using ngrok.

Download ngrok from here and follow the instructions to install it.
Now we shall create a secure URL to your localhost. Type `ngrok http 1500` in your Terminal. You will see an ngrok window like this.

Ports 1-1024 are restricted so use any port number > 1024.

Ngrok has thus created a secure public-facing URL (http://b3a3b4d7.ngrok.io in this instance) to localhost:1500, that you can access from anywhere. Type this URL in your browser and you will see the 'Hello World' message from server.js.

Paste this URL as your callback URL in your Gupshup dashboard.

Your ngrok window will also inspect and display the HTTP requests.

That is how you can test your bot locally using ngrok. Once you're done testing, you can host this file on your production server.