Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skype bot built with skype-sdk in Node.js is not running correctly?

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

like image 367
vikrant Avatar asked Jun 03 '16 11:06

vikrant


2 Answers

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.

like image 138
enkryptor Avatar answered Oct 22 '22 20:10

enkryptor


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

like image 38
nwxdev Avatar answered Oct 22 '22 19:10

nwxdev