Search code examples
c#azurebotframeworkskype-for-business

How to get other than "conversationUpdate" and "endOfConversation" from MS Bot Framework, Skype For Business


While we did not find solution to our previous question about registration of our bot to Skype for Business channel (hereinafter SfB) we attempted to create brand new bot and perform new registration to SfB channel for brand new user. There was no error during the creation and registration process.

At the moment we can read incoming Activity in debug mode when attached by Visutal Studio 2017 (Cloud Explorer>Attach Debugger) to bot deployed at Azure but we observe only Activities of Type: "conversationUpdate" or "endOfConversation" each time we send a message to our bot via SfB.

UPDATE

The bot was created and registered using an account that is linked to Azure and MSDN subscription however the account is not part of our Azure Active Directory. The sender and bot account used by SfB are part of our Azure Active Directory.

If I create dedicated Azure Active Directory from Azure portal owned by the account that also owns the bot itself then the comminication via SfB works for accounts created in this dedicated Azure Active Directory.

END UPDATE

What logs or settings at Azure or SfB can we check now to make the communication finally working? Are there any special requirements to user that represents the bot that might need to be doublechecked? Are there any additional security settings for the bot if its owner has no rights to Azure Active Directory where bots audience users are defined?

See example of serialized json activities:

{
  "type": "conversationUpdate",
  "id": "6d5f79c9-9a89-4606-92cb-9ead49405865",
  "timestamp": "2017-12-01T14:13:53.3958935Z",
  "serviceUrl": "https://webpooldb40r04.infra.lync.com/platformservice/.../botframework",
  "channelId": "skypeforbusiness",
  "from": { "id": "sip:[email protected]", "name": "LastName, Me" },
  "conversation": { "isGroup": true, "id": "YzkxZDQ2MmQjc2lwOmFmZmJib3RAYmx1ZWxpbmtz..." },
  "recipient": { "id": "sip:[email protected]", "name": "sip:[email protected]" },
  "membersAdded": [],
  "membersRemoved": [ { "id": "sip:[email protected]", "name": "LastName, Me" } ],
  "attachments": [],
  "entities": []
}

and

{
  "type": "endOfConversation",
  "id": "4b485bcf-59c8-446f-9d56-74dda973db25",
  "timestamp": "2017-12-01T14:13:53.4115031Z",
  "serviceUrl": "https://webpooldb40r04.infra.lync.com/platformservice/.../botframework",
  "channelId": "skypeforbusiness",
  "from": { "id": "sip:[email protected]" },
  "conversation": { "isGroup": true, "id": "YzkxZDQ2MmQjc2lwOmFmZmJib3RAYmx1ZWxpbmtz..." },
  "recipient": { "id": "sip:[email protected]", "name": "sip:[email protected]" },
  "membersAdded": [],
  "membersRemoved": [],
  "attachments": [],
  "entities": []
}

Remarks:

1) Bot is registered for more than a week.

2) Our controller contains as few code as possible to avoid any problem that might influence our tests:

    public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
    {
        if (activity != null)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                var reply = activity.CreateReply("Reply");
                using (var client = new ConnectorClient(new Uri(reply.ServiceUrl)))
                {
                    await connectorClient.Conversations.ReplyToActivityAsync(reply);
                }
            }
        }

        return Request.CreateResponse(HttpStatusCode.OK);
    }

3) Responses are correctly being generated for WebChat channel: WebChat sample text and response

4) In bot Analytics we see incoming messages and users for both WebChat and SfBenter image description here

5) If we attempt to respond to Activity of Type "conversationUpdate" or "endOfConversation" anyway then we observe:

{"Conversation does not exist"} Microsoft.Rest.HttpOperationException

6) If we try to execute code that creates new conversation then we get:

{"BVD operation failed with 404"} Microsoft.Rest.HttpOperationException

Points 5) and 6) are rather expected and are appended merely for illustration


Solution

  • Currently, S4B Bots can only communicate to users in the same domain. Reason is security as bots can identify the identity of the users they are interacting with (user identity is not hashed), and need Tenant Administrator steps before end users can use a bot in a tenant.

    Therefore the federation/cross-tenant scenario is not currently supported.

    In most cases, it is recommended to create a bot “instance” in each AAD "domain".