The IDE Bot Builder tool takes care of the complete bot lifecycle. The bot lifecycle also includes local testing and debugging.
The IDE Bot Builder provides an option to test the bot locally before deploying it onto the server and it also provides an option to add specific logs to debug the code. Let's look at both these one by one to understand how they work and how they can be utilized in the bot building process.
1.Terminal - Console where you can enter text or git commands to execute.
2.Logs - Tools for logging and debugging. There are two ways you can use logs for debugging 1] Bot Logs(Local Logs) and 2] Prod Logs(Production Logs)
The terminal is an interface, where you can type and execute commands.It can be much faster to complete some tasks using a Terminal. You can execute file system as well as git commands. You can also install third party node modules using NPM via terminal.Let us show how to use git commands via terminal to commit and push your bot code.
IDE Bot Builder comes with in-built Git functionality. This is the Git server hosted by Gupshup and can only be used by developers registered on Gupshup platform. You can perform basic Git functions like commit, create branches, pull/push etc.There are two ways to use git inside IDE.
Using Terminal
As we have stated earlier that you can use terminal to execute git commands. We will see how to use git commands to execute commit/push your bot project code. So before we start, we highly recommend you to get familiar with Git version control system. Let's get started.
1] Let's add all files to the staging area before commit, to add all files enter git add .
command at terminal.
2] After we have added all files to the staging area you can enter git commit -m 'First commit'
command to commit your code.
3] After you've committed your code, now it's time to push your code to the master branch.Enter git push origin master
at terminal to push your code to remote master branch.
You have successfully pushed your bot code to remote master branch.
There are two ways you can use logs functionality to debug your bot code.
Bot logs is very useful.You will have Bot logs option in IDE itself where you can quickly debug your bot code.
To log any statements you can use context.console.log
.You can see your logs statement at Bot logs tab in IDE.
The 'Logs' tab contains the logs of your bot. These logs are very helpful in understanding the user and bot conversation as everything gets logged. Even DB operations or HTTP calls gets logged, thus making it easier for developers to find any flaw in the hosted code.
These logs are only created when the bot is accessed from one of the supported messaging channels.
You can choose the number of results to display from the dropdown on the left-hand side.
You can also choose the duration between which you need the logs for by selecting the option on the right-hand side but only 500 logs can be displayed at a given point of time.
That's it for this tutorial.