[Question] Any example code for Skype For Business bit to initiate a new conversation (nodejs)
System Information (Required)
- SDK Language: node.js
Issue Description
Looking for example to have Skype for Business bot to initiate a new conversation with user.
try this code snippet and see if it works for you:
bot.on('conversationUpdate', function (message) {
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id == message.address.bot.id) {
var reply = new builder.Message()
.address(message.address)
.text("Welcome to my page");
bot.send(reply);
} else {
var address = Object.create(message.address);
address.user = identity;
var reply = new builder.Message()
.address(address)
.text("Hello %s I\'m botty McBotface", identity.name);
bot.send(reply);
}
});
}
});
You can also find many example bot projects demonstrating various features of the Node SDK here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node
The example code does not work. message.membersAdded only contains the bot itself.
I was hoping to find example as in Skype For Business] Outbound Bot doesn't work. #3023
#3023
Make sure Skype for business bot sip is of the same domain as the user you're trying to reach with outbound. In other words, the bot is created as a user in your Active Directory tenant, and needs other measures to reach outside domain.
Example code:
let address = {
"channelId": "skypeforbusiness",
"user": {
"id": <id of the user you want to message (sip:[email protected])>,
},
"bot": {
"id": "sip:[email protected]",
"name": "sip:[email protected]"
},
"serviceUrl": "https://api.skypeforbusiness.com/platformservice/botframework"
}
sendProactiveMessage(address, "Tyler")
bot.id and bot.name are the same, and should be the sip address you created when making S4B channel endpoint ( -Uri )
const sendProactiveMessage = (addr, user) => {
bot.send(new builder.Message().address(addr).text(`${user} is trying to reach you!`));
}
Thanks @teachtyler.
It does work!!! However it only work occasionally and when it works, after click reply on the notification, there is no text message shown.
Every time there is error message from botbuilder(include when notification is shown): ERROR: ChatConnector: startConversation - error starting conversation. Error: Request to 'https://api.skypeforbusiness.com/platformservice/botframework/v3/conversations' failed: [500] Internal Server Error at Request._callback (/opt/SA_PlatformHandlers/node_modules/botbuilder/lib/bots/ChatConnector.js:512:46)
or
RROR: ChatConnector: startConversation - error starting conversation. Error: Failed to start conversation: no conversation ID returned. at /home/pk/node_modules/botbuilder/lib/bots/ChatConnector.js:205:35
Hi @ceopk , I am getting the same error. I tried intercepting the options, url and credentials bot framework uses in the backend to communicate with S4B, then tried replicating the request on post man, I still got the same error. Not even once it send any notification or message to the intended user.

Please suggest a fix.