Salesforce Skype Bot

Introduction

In this blog, I am going to explain the step by step how to set up a skype bot with salesforce by using node js,jsforce, and botbuilder.

Setup Node Js Project

1. Create an empty folder to start the node js project.
2. Create a new package.json file and paste the below code into the package.json file 

3. Run npm install from the command promote to load all the node modules from the package.json
4.Now create a new file and name it as app.js and paste this code into app.js file.

 

5.Change appId & appPassword with your own appId and appPassword for chatbot and Salesforce username and password to get data from the salesforce.To get App Id and password follow below steps.

6.First login into your Microsoft account.

7.Goto this link: Click Here and complete sign in process 

8.Click on Register a bot and create a new bot.

9.Click create  button to register your bot Register an existing bot built using Bot Builder SDK

10.Now fill in your required details, select your bot image as shown below

11.Click on Create Microsoft App ID and password and then click on generate app Password to continue 

12.Now You got your App ID and Password and update them in code.

13.Now you need to add https messaging endpoint to listen for requests.

14.You can create one for free that will run locally on your system using the tool called ngrok and Download ngrok from here  Click Here .You will get a zip file, Extract that zip file into any folder and then open the file named ngrok.exe

15.Type and enter : ngrok http 8080

16.Now copy the https address 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.

17.Now paste this address into endpoint field and add api/messages” in the end as shown below on Bot Registration configuration sections.

 

18.Click on the register and save the bot.
19.Now go back to command prompt and type ‘ node app.js ‘ to start your node js application.
20.After the application starts you can test from the test section on the application.

Then type /help to start the bot conversion as shown below.

As shown in the above image you can post to chatter from the skype chatbot. once you test your application you can push the skype and use it.

Understand the Code

You can register the bot chat connect from the below code and it is going to Create chat connector for communicating with the Bot Framework Service

And most important think how we are going to establish the conversation as the communication between a bot and a user through one or more dialogs. A dialog, at its most basic level, is a reusable module that performs an operation or collects information from a user. the below code shows how to start the dialog

You can refer more details on dialogs  below links

https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-quickstart

https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-overview

 

 

Tags: