Bots are artificially intelligent programs that can do many useful things like search for news, summarize web pages, play games, and more. You can start chatting with a bot just like you chat with friends – simply click on the bot and start typing.Microsoft released its skype bot sdk which works great and its fun to have one of your own. As of now we can build skype bot in either C# or nodejs. These SDKs provide features such as dialogs and built-in prompts that make interacting with users much simpler. Lets get started building a simple bot for skype using nodejs.
- Install node js if you haven’t installed it in your pc yet (http://nodejs.org/).
- Create a folder (skypebot).
- Now navigate to the folder from command prompt, then type npm init, A new package.json file will be created.
- Now create a new file and name it as index.js
- Now open command prompt type and enter npm install restify –save ( installs restify in the skypebot directory and save it in the dependencies list).
- After it finishes installing, Now type and enter: npm install –save botbuilder.
- After finishing installation please make sure your package.json looks as below.
- Now add the below code to your index.js file
- Change appId & appPassword with your own appId and appPassword.
- Here’s how to get your appId and appPassword.
- First login into your Microsoft account.(Click Here), and click on Register Bot. Fill the required details and select your bot image.
- For APP ID and Password click on create Microsoft APP ID and password.
- Now you have your appId, To generate app Password click on generate a password to continue by copying the appId and password.
- Paste your appId in the bot creation page and you can fill rest of the fields except Messaging endpoint field for which you may need a https message endpoint to listen for requests.
- You can paste your https endpoint of your server if you have hosted it on any public servers and also You can create one for free which will run locally on your system using tool called ngrok.
- You can get the installation steps for ngrok from here.
- After running your ngrok on port 8080 you will get a https link from the command line of ngrok. Make sure you don’t close the ngrok after creating address cause then the endpoint address will not listen to any request and you have to create new address with ngrok again.
- Now paste this address into endpoint field by clicking edit on your bot and add “api/messages” in the end.
- Now you have this link, Use this link to add your bot to your skype contacts for testing the bot as shown below
- Now after creation after the bot you have to start your server running, to do that go back to your index.js file and update your appId and password which you configured above.
- Now go back to command prompt and type ‘ node app.js ‘ and hit enter to start your application.
- After application starts, Open your skype account and message the bot your previously added to your skype contacts.
Now you have your own skype bot up and running.