Proactive Bot on Skype
Hello guys! was anyone able to get a proactive bot written in node.js, work with Skype?
Here is what works for me: A proactive bot (node.js) on a dev system is able to send messages to my emulator.
I am trying to get this bot working such that the bot can start a conversation with me when triggered to do so.
Here is how I have written it
bot.beginDialog({
to: {
address: "User1",
channelId: "emulator" ,
id: "2c1c7fa3",
isBot: false
},
from: {
address: "notificationbot",
channelId: "emulator",
id: "notificationbot",
isBot: true
}
}, '/beginconv');
And here is the handler
bot.add('/beginconv', function (session) {
session.endDialog("I'm sending you a proactive message!");
});
PS: I have already gone through the existing issues and they discuss the emulator and sms. I am doubtful about this thing working with Skype or Slack
Please help.
Not a 100% sure, but I guess you mean you are not getting any response from your bot when sending it a message from Skype. If so, welcome to the club.
My bot works with the emulator and the web chat tool, however nothing happens on FB and Skype. Had gone through all suggestions and nothing helped. I have a handler like this:
bot.on('Message', function (message: any) { console.log(message.text); });
and a simple handler like this:
bot.add('/', function (session) {
session.send('Hello World');
});
It's simply not getting hit. Triple checked the webhook address, so that's not the issue.
p.s. Server's running on Azure.
@MiroValchev I think these are two different things.
I am able to get replies on skype if I send a message to my bot from skype.
My issue is when I write a notification bot which proactively talks to a user, without requiring the user to send a message to the bot. Which means a bot initiated conversation on skype.
Hi,
I am closing this issue as I got things working. Putting my solution here, in case someone else comes up with the same problem :)
bot.beginDialog({
to: {
address: "8:live:officialdharam",
channelId: "skype" ,
id: "2c1c7fa3",
isBot: false
},
from: {
address: "notificationbot",
channelId: "skype",
id: "notificationbot",
isBot: true
}
}, '/beginconv');
Just notice that the key is to give the right To address. It is tricky to get the right To address. But here is the way I found it.
I used a bot which was working with skype. I made log statements like below:
console.log("FROM : "+JSON.stringify(session.message.from));
to which I got a response as below:
FROM : {"name":"8:live:officialdharam","channelId":"skype","address":"8:live:officialdharam","id":"7JitRpa2At5","isBot":false}
Pick up the value in the address field to specify as the To Address for the proactive bot.
Hi! In your case, it may work with skype! Does it work with the emulator ?
yes it works on emulator, but you have to get that right. The publicly hosted bot will not work on Emulator. You have to run a local bot on the same machine where the emulator is running.
Also, while instantiating the bot you dont need appId and secretkey for this case. Something like
var bot = new builder.BotConnectorBot();
Also, here is the begin dialog :
bot.beginDialog({
to: { "address": "User1", "channelId": "emulator" , "id": "7JitRpa2At5", "isBot": false},
from: { "address": "testbot", "channelId": "emulator", "id": "testbot", "isBot": true},
text: "Notify Usecase"
}, '/');
I purposefully change the name to testbot for running local.
TIP: Just make sure when you get the notification on the emulator, the bot URL is localhost and not the public URL of the bot.
Thanks for your answer! It doesn't work, and of course, all that run on the same machine :) Maybe something I do wrong? Here my code :
var locbot = new builder.BotConnectorBot();
locbot.configure({endpoint: "http://localhost:9000"});
var server = restify.createServer();
server.get('/api/test', function (req, res, next) {
locbot.beginDialog({
text: 'Hello',
to: {channelId: "emulator", address:"User1", id:"617d3bf8", isBot:false},
from: { channelId:"emulator", address:"mybotaddress", id:"mybotid", isBot:true}
}, '/');
res.send(200, 'ok');
return next();
})
locbot.add('/', function (session) {
console.log('test');
session.endDialog('hello2');
console.log('test2');
});
server.listen(process.env.port || 3002, function () {
console.log('%s listening to %s', server.name, server.url);
});
So if I go to http://localhost:3002/api/test on a browser, server answers me and "ok" can be seen as response, with status code 200, but nothing changes on the emulator and 'Hello' or 'Hello2' doesn't appear. Do you see something wrong ?
I think you didn't follow my previous comment completely. Anyways! your code is perfectly right and it works on my system.
Here are the steps to follow to successfully run it on your system:
- - Download the zip from here.
- - Unzip it and navigate to the unzipped directory on command window and run
npm installfirst - - Once the command completes, run
node app.js - - Open up emulator, supply URL
http://localhost:3002/and in the AppId field typemybotid - - Open the browser and navigate to the address
http://localhost:3002/api/test - - You can see the
hello2in the emulator
Ok! Thanks again for your answer.
I follow all your steps and it doesn't work anymore.
The only difference is that I use emulator on MacOSX (with the command mono BFEmulator.exe) and maybe, in that way, proactive dialog doesn't work.
Maybe someone at Microsoft can say more about that ?
Is there any Git reference to create a proactive bot ?
I tried following the steps provided but i don't get any message on the emulator.I can see the logs on the command prompt.What should i provide as the Microsoft App id and Microsoft App password in the emulator?
@vikapur may be this will helpful https://github.com/Microsoft/BotBuilder/issues/2311 Note :solution for node js with slack
The topic is open? I want to help you. My bot work perfectly with proactive messages on skype, web chat and emulator.
This issue is closed. Please open a new issue if you have a question or problem. Thx! 💯
Hi @officialdharam
within the code bot.beginDialog({
to: {
address: "User1",
channelId: "emulator" ,
id: "2c1c7fa3",
isBot: false
},
...
I'm wondering, what is id 2c1c7fa3 here? and how you find it?
@yourNameIsGood could you please post the complete JSON you are asking about. There is multiple ID fields and I want to give you the correct information.
Here is an example of the JSON:
{
"type": "message",
"id": "bf3cc9a2f5de...",
"timestamp": "2016-10-19T20:17:52.2891902Z",
"serviceUrl": "https://smba.trafficmanager.net/apis",
"channelId": "channel's name/id",
"from": {
"id": "1234abcd",
"name": "user's name"
},
"conversation": {
"id": "abcd1234",
"name": "conversation's name"
},
"recipient": {
"id": "12345678",
"name": "bot's name"
},
"text": "Haircut on Saturday"
}
@JasonSowers
I'll try to ask the question again.
Here quotes from @officialdharam 's comment
My issue is when I write a notification bot which proactively talks to a user, without requiring the user to send a message to the bot. Which means a bot initiated conversation on skype.
I wanna do the same thing: start a conversation by the bot before a skype user talking to the bot.
And my question is: How to find the skype user's id, so the bot sends that message to the user who is the recipient?