microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.48k stars 2.44k forks source link

[Skype for Business] Proactive messages not delivered if SFB window is closed #3636

Closed tangochris closed 6 years ago

tangochris commented 6 years ago

Bot Info

This issue applies to all SFB bots built on the Tangowork platform, but we'll provide the bot info for one of our test environments:

Issue Description

We are implementing a Skype for Business chatbot at the head office of an 80,000-employee organization.

If a proactive message is sent while SFB is closed, or even if the current conversation window inside SFB is closed, it will never be delivered.

Our proactive message code works fine in Facebook Messenger, Skype, Slack, SMS, and Teams. It's only Skype for Business that has an issue.

Code Example

Our code looks like his:

// subscribeAddressHandler.js

const address = session.message.address;
addresses.push(address);

// sendProactiveHandler.js

const connector = new ChatConnector();
new UniversalBot(connector).beginDialog(address, '/default');

Addresses look like this:

{   
  "id": "2",   
  "channelId": "skypeforbusiness",   
  "user": {     
     "id": "sip:some@example.co",
     "name": "Foo"
   },  
   "conversation": {
      "isGroup": true,
      "id": "ZTFmMWYwM2Yjc2lwOmRlbW9AdGFuZ293b3JrLm9ubWljcm9zb2Z0LmNvbQ=="
   },   
  "bot": {
     "id": "sip:demo@example.onmicrosoft.com",
     "name": "foobar"
   },   
  "serviceUrl": "https://webpoolbl20r04.infra.lync.com/platformservice/tgt-3e269d45c99c53b8a53d91bd8610020f/botframework" 
}

Reproduction Steps

  1. Send a proactive message to Skype For Business while conversation window is closed, or while SFB is closed

Expected Behavior

  1. We expect the message to to be visible for the user when they re-open Skype for Business, or when they reopen the conversation window with the bot.

Actual Results

The SFB user never receives the message.

On the bot side we see an error when the proactive message is sent while the conversation window is closed:

Error: Request to 'https://webpoolbl20r04.infra.lync.com/platformservice/tgt-3e269d45c99c53b8a53d91bd8610020f/botframework/v3/conversations/YjJmZTQ4ZTQjc2lwOmRlbW9AdGFuZ293b3JrLm9ubWljcm9zb2Z0LmNvbQ%3D%3D/activities' failed: [500] Internal Server Error
        at Request._callback (/botbuilder/node_modules/botbuilder/lib/bots/ChatConnector.js:512:46)
        at Request.self.callback (/botbuilder/node_modules/request/request.js:186:22)
        at emitTwo (events.js:106:13)
        at Request.emit (events.js:191:7)
        at Request.<anonymous> (/botbuilder/node_modules/request/request.js:1163:10)
        at emitOne (events.js:96:13)
        at Request.emit (events.js:188:7)
        at IncomingMessage.<anonymous> (/botbuilder/node_modules/request/request.js:1085:12)
        at IncomingMessage.g (events.js:292:16)
        at emitNone (events.js:91:20)
        at IncomingMessage.emit (events.js:185:7)
        at endReadableNT (_stream_readable.js:974:12)
        at _combinedTickCallback (internal/process/next_tick.js:74:11)
        at process._tickDomainCallback (internal/process/next_tick.js:122:9)

We've tried omitting the conversation part of the address, and this works fine in other messengers. However, in SFB, if we omit the conversation part of the address and send a proactive message to SFB:

Because our proactive messages work fine on other channels, we believe this is a bug with botbuilder's integration with Skype for Business. But if it's not a bug, we'd be grateful for some advice on what we're doing wrong.

JasonSowers commented 6 years ago

This seems like the expected behavior to me, but will ping the S4B team and see what they have to say.

tangochris commented 6 years ago

@JasonSowers If you sent me an email, would you expect it to be delivered, even if I didn't have my email client open at the time? Of course. That's the situation we're talking about. Unless we are having an active conversation, SFB messages disappear as if they had never been sent.

JasonSowers commented 6 years ago

Totally get what you are saying, just my guess that teams doesn't behave like that.

wictorwilen commented 6 years ago

I'm seeing the same behavior, which is not expected, as other clients doesn't behave this way.

v46 commented 6 years ago

This is blocking us as well. The underlying service error seems to be the following:

{ Error:
   { Code: 'ServiceError',
     Message: 'A 480 (Temporarily Unavailable) response was received from 
     the network and the operation failed. See the exception details for more information.' 
  }
}
JasonSowers commented 6 years ago

@intranetchris @wictorwilen @v46 All channels are independent of bot framework, even the internal channels like Skype, Skype for Business and MS Teams. If one or more channels behave a specific way, this does not mean all channels behave like that. All channels have their own independent features. This is a question for Skype for Business as the behavior of channels themselves is well outside of the scope of the Bot Framework SDK. In turn, this is well outside the scope of this forum. If Skype for Business does not accept messages on the user's behalf while they are not logged in, there is nothing that can be done within the SDK to change that. If a channel does not behave the way you would like, you need to get in contact with the channel and ask them if they can put your feature request on their roadmap. The bot framework SDK just connects to the channels it does not enforce how they behave.