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

2

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

Ac answered 3/6, 2016 at 11:27 Comment(6)
developer.microsoft.com/en-us/skype/bots followed this documentationAc
Seems like decent tutorials. What makes you think answers here would be better?Procurance
I mean, why did you fail following the tutorial? What was wrong with the tutorial, what answers should we give to you?Procurance
can not get reply from botAc
We have no idea why it happens without any additional information, unfortunately.Procurance
Does the server actually sends something to the bot? Consider using console.log for debugging.Procurance
P
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.

Procurance answered 7/6, 2016 at 13:3 Comment(4)
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 endpointGhana
it is working for me with ngrok, but not working with https alone, i have apache server running. Is that causing a problem???Ac
Apache server? For what purpose? What do you mean "not working", what happens exactly?Procurance
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".Procurance
F
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

Footstall answered 2/1, 2018 at 22:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.