6

I am trying to build skype bot.

I followed documentation given by skype-sdk but failed to create it using that. Can not get reply from bot.

const fs = require('fs');
const restify = require('restify');
const skype = require('skype-sdk');

const botService = new skype.BotService({
    messaging: {
        botId: 'xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx',
        serverUrl : "https://example.net",
        requestTimeout : 15000,
        appId: 'xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx',
        appSecret: 'xxxxxxxxxxxxxxxxxxxxxxxx'
    }
});

botService.on('contactAdded', (bot, data) => {
    console.log("bot replay");
    bot.reply('Hello ${data.fromDisplayName}!', true);
});

botService.on('personalMessage', (bot, data) => {
    console.log("person replay");
    bot.reply('Hey ${data.from}. Thank you for your message: "${data.content}".', true);
});

const server = restify.createServer();

server.use(skype.ensureHttps(true));
server.use(skype.verifySkypeCert({}));

server.post('/skbot', skype.messagingHandler(botService));
const port = process.env.PORT || 8080;
server.listen(port);
console.log('Listening for incoming requests on port ' + port);

Thanks

nwxdev
  • 4,194
  • 3
  • 16
  • 22
vikrant
  • 141
  • 1
  • 12

2 Answers2

3

In the example provided the bot isn't connecting to a skype server due to wrong server specified:

serverUrl : "https://example.net"

You have to specify a valid skype server:

serverUrl : "https://apis.skype.com"

You also specifying wrong API uri in the server.post (well actualy that depends on your webhook settings, but they weren't provided, so I'm assuming default):

server.post('/skbot', skype.messagingHandler(botService));

You have to use '/v1/chat' for messaging. Try out this tutorial.

enkryptor
  • 1,574
  • 1
  • 17
  • 27
  • Is `appid` and `botid` are same, what about `appSecret` is it the `password` or `privatekey`.. In debug mode I see `skype-sdk.azure-utils Request not received over HTTPS, redirecting to HTTPS endpoint` – Wazy Jun 08 '16 at 10:37
  • it is working for me with ngrok, but not working with https alone, i have apache server running. Is that causing a problem??? – vikrant Jun 08 '16 at 11:48
  • Apache server? For what purpose? What do you mean "not working", what happens exactly? – enkryptor Jun 08 '16 at 17:18
  • I suggest you to isolate the problem and post a new question about it. Try to be more specific and describe all the details. What you are asking now is "I did something, but it is not working, tell me why". – enkryptor Jun 08 '16 at 17:20
1

Build your bot with Microsoft Bot Framework's BotBuilder SDK instead of using the skype-sdk package.

You can build a basic Skype bot using the following example code:

https://github.com/Microsoft/BotBuilder/blob/master/Node/examples/demo-skype/app.js

For a more detailed example of Skype features, check out my Skype bot example on GitHub here:

https://github.com/nwhitmont/botframework-skype-support-dev/blob/master/server.js

nwxdev
  • 4,194
  • 3
  • 16
  • 22