Saturday, July 2, 2016

Create Skype bot in Java - Part 2

Registeration in Skype Bot Platform

In Create Skype bot in Java - Part 1, we have seen how get ready a bot server which can be accessed by Skype bot platform. In this section let use explore how to register our bot server webhook ( the url through which our bot server will receive messages.)

a) Visit the page https://developer.microsoft.com/en-us/skype/bots/manage ( You need to have outlook account)




b) Click the "Create a new bot" button
Provide the details like name, description and choose a pic for your bot.


c) Now you have to "Microsoft Application ID". This is required to authenticate our bot. To generate the one, click the link avalable there or here
https://apps.dev.microsoft.com/Login?ru=https%3a%2f%2fapps.dev.microsoft.com%2f
d) In this page click the "Add an app" button. once you provide the name and click ok, it will generate the application id as shown below. Not it down.




Once you click the Add an app button,the next screen will be available.



e) Also generate the new password and store it separately.
f) Click save and come back to bot registration page.
g) Provide the application id you noted it down in step "d"
h) Provide the webhook url. This is our bot server listening point and it should be https url. In our case, it is the ngrok URL which is listening for incoming messages.


e) Save the details.Now our app has been registered in skype bot platform

f) Once the bot is registered in skype platform, you can view the details of your bot as below.



 g) Notice the URL, '"Add bot to Skype". Open that url in browser, it will add the bot as contact to our skype account.
h) Once the bot contact is added, you can view the bot in the contact list. The bot will always be displayed online as shown below.







Time to Test :)

1) Start you bot application in eclipse. ( We created this in part-1 of this series)
2) Start ngrok as explained in part-1. If the 'https' tunnel url ( Webhook url) is changed , update the new url in skype bot platform. Refer to step h.
3) Goto your skype application and send some message to your Bot.

 

4) It will be displayed in our bot application console.


Received Message:[{"id":"0","content":"Hi Bot","activity":"message","from":"8:vijay_test_id","fromDisplayName":"vijay D","to":"28:be5a8935-f4d5-4a4e-8aac-5f4eed464083","time":"2016-07-02T07:56:43.369Z"}]


Received Message:[{"id":"0","content":"How are you ?","activity":"message","from":"8:vijay_test_id","fromDisplayName":"vijay D","to":"28:be5a8935-f4d5-4a4e-8aac-5f4eed464083","time":"2016-07-02T07:59:08.351Z"}]