botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Skype for Business] Conversation initialization issue

Open Sowz opened this issue 9 years ago • 9 comments

System Information (Required)

  • SDK Language: .NET/C#
  • SDK Version: 3.8.4
  • Development Environment: AZURE_APP_SERVICE / LOCALHOST

Issue Description

When I start a new conversation with my Skype for Business Bot, in the first message sent by Skype the "from id" is in the following form "mysupport@.onmicrosoft.com". Then, in the second message, the "from id" is "sip:mysupport@.onmicrosoft.com" with the "sip" tag added. The issue is that my Bot consider both messages as 2 differents conversations.

Code Example

[Serializable]
public class RootDialog : IDialog<object>
{
    public async Task StartAsync(IDialogContext context)
    {
        context.Wait(MessageReceivedAsync);
    }
    public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
    {
        IMessageActivity activity = await result;
        await context.PostAsync(context.Activity.From.Id);
        context.Wait(MessageReceivedAsync);
    }
}

Steps to Reproduce the Issue

  1. Create a simple Bot and add the Skype for Business channel
  2. Start a new conversation
  3. Send 2 messages
  4. Each message will have 2 differents "from id"

Expected Behavior

The Skype for Business conversation should always send the sip of the user.

Actual Results

The following screenshot shows the "from id" sent by Skype: 2017-07-11_17h00_40

The first request sent by Skype (id is a guid and from id without sip): 2017-07-11_16h48_32

The second request sent by Skype (id is a now a integer and from id with sip): 2017-07-11_16h48_41

Sowz avatar Jul 11 '17 15:07 Sowz

I am facing exactly the same issue in "Skype for Business" for windows. As a workaround currently I am ignoring the first message and continuing conversation with the second message onwards.

Interestingly this issue is not happening in "Skype for Business" for mac or for mobile (Tested in android). In mac and android the first message itself starts the session and the user remain in same session. But in windows the first message starts a session but the second message starts a completely different session. (The userData in session object is different for both messages).

May be because "from id" is different in both cases (in first message "from id" doesn't starts with "sip:" but in second message it starts with "sip:" ) the botframework is considering them two different users and so the userData object in session is different for both messages.

kr-ankit avatar Jul 12 '17 09:07 kr-ankit

I stumbled upon this post and found it exactly matching the issue that I am facing too.

A) For a completely new conversation initiated from Skype for Business channel, the bot framework seems to treat only the second message sent to it as a starting point and the first message sent to it goes a waste.

B) In other words, technically, it executes the RootDialog.StartAsync() twice even if the RootDialog.StartAsync() method has a Dialog state suspension written viz.: context.Wait(MessageReceived) to handle the second message called. The second message also gets handled by RootDialog.StartAsync() rather than getting directly handled by MessageReceived().

C) This issue is not at all reproducible on the Emulator and it seems to be only Skype for Business specific.

D) As a result of all this, an Introductory conversational message sent by the bot (For Example - "Welcome User. I am Syna, and what can i do for you today?") lands up getting sent twice to the user.

BreakPointAtLine0 avatar Aug 15 '17 19:08 BreakPointAtLine0

I had the same issue. Worked around for now with the following in the messages controller

        public async Task<HttpResponseMessage> Post([FromBody]Activity activity, CancellationToken token)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                if(activity.ChannelId == "skypeforbusiness")
                {
                    activity.From.Id = activity.From.Id.Replace("sip:", "");
                }

lee-borlace avatar Aug 20 '17 03:08 lee-borlace

@leeroy79: Thanks for posting the fix.

BreakPointAtLine0 avatar Sep 02 '17 11:09 BreakPointAtLine0

+1

sureshgururajan avatar Sep 11 '17 21:09 sureshgururajan

Another ugly behavior cause by this issues that drove me crazy for many days until I find this thread, if the first message of the conversation make your bot to trigger a prompt dialog, the answer from the user won't goes to the ResumeAfter method of the prompt dialog.

There should exist an open issue explaining this, this post is closed but the issue remains.

Thanks for sharing this!

elier avatar Nov 29 '17 20:11 elier

@elier reopened, someone should consider posting a stack overflow question/answer for this

JasonSowers avatar Nov 29 '17 22:11 JasonSowers

I am facing the same issue on iOS, Android, Mac but not Windows and not able to make my bot live on production. This is making a heavy impact on my product. Guys, can you please resolve this?

rohankulkarni21 avatar Jan 10 '18 06:01 rohankulkarni21

Thank you for opening an issue against the Bot Framework SDK v3. As part of the Bot Framework v4 release, we’ve moved all v3 work to a new repo located at https://github.com/microsoft/botbuilder-v3. We will continue to support and offer maintenance updates to v3 via this new repo.

From now on, https://github.com/microsoft/botbuilder repo will be used as hub, with pointers to all the different SDK languages, tools and samples repos.

As part of this restructuring, we are closing all tickets in this repo.

For defects or feature requests, please create a new issue in the new Bot Framework v3 repo found here: https://github.com/microsoft/botbuilder-v3/issues

For Azure Bot Service Channel specific defects or feature requests (e.g. Facebook, Twilio, Teams, Slack, etc.), please create a new issue in the new Bot Framework Channel repo found here: https://github.com/microsoft/botframework-services/issues

For product behavior, how-to, or general understanding questions, please use Stackoverflow. https://stackoverflow.com/search?q=bot+framework

Thank you.

The Bot Framework Team

benbrown avatar Oct 01 '18 16:10 benbrown