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

Invalid conversation ID in teamsChannelId after update to v3.5.3

Open AlexanderKovalev opened this issue 9 years ago • 10 comments

After updating to v3.5.3 receiving error: "Invalid conversation ID in teamsChannelId" in code (CreateDirectConversationAsync part):

var connector = new ConnectorClient(new Uri(serviceUrl), new MicrosoftAppCredentials()); var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);

AlexanderKovalev avatar Feb 17 '17 16:02 AlexanderKovalev

Are you sure it's related to the release? I'm getting the same in 3.5.2 but I'm not completely sure yet whether it's not me own fault.

jsiegmund avatar Feb 19 '17 13:02 jsiegmund

I think yes, because it worked before 3.5.2. After update to 3.5.2 and 3.5.3 it started to generate this error

AlexanderKovalev avatar Feb 19 '17 19:02 AlexanderKovalev

Same issue over here. 3.5.3. Not sure when I updated but code used to work a few days ago.

Edit I started with 3.5.1 to3.5.3:All versions have the same problem now.

(bUsers is an object with userinfo from a database)

userAccount = new ChannelAccount(bUsers.UserId, bUsers.UserName);
var botAccount = new ChannelAccount("default-user", "User");

MicrosoftAppCredentials.TrustServiceUrl(bUsers.ServiceUrl);
                MicrosoftAppCredentials creds = new MicrosoftAppCredentials("MyAppId",
                    "MyAppPwd");
                var connector = new ConnectorClient(new Uri(bUsers.ServiceUrl), creds);
                var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount,userAccount);
                var message = Activity.CreateMessageActivity();
                message.From = botAccount;
                message.Recipient = userAccount;
                message.Conversation = new ConversationAccount(id: conversationId.Id);
                message.Text = "Hello from " + context.Activity.From.Name;
                message.Locale = "en-Us";`
await connector.Conversations.SendToConversationAsync((Activity) message);

rjoosen avatar Feb 19 '17 19:02 rjoosen

It's probably something server side as that "teamsChannelId" property doesn't exist in the repo. The channel stuff is being done server side somewhere so that might have changed. For 3.5.2., the following code is working for me, but that needs an existing conversation Id to reply to:

var userAccount = new ChannelAccount(cookie.Address.UserId);
var botAccount = new ChannelAccount(cookie.Address.BotId);

Activity activity = cookie.GetMessage();

// need to trust the service URL because otherwise the bot connector authentication will fail
MicrosoftAppCredentials.TrustServiceUrl(cookie.Address.ServiceUrl);

// construct the reply to send back to the user
IMessageActivity messageToSend = Activity.CreateMessageActivity();
messageToSend.ChannelId = cookie.Address.ChannelId;
messageToSend.From = botAccount;
messageToSend.Recipient = userAccount;
messageToSend.Conversation = new ConversationAccount(id: cookie.Address.ConversationId);
messageToSend.Text = replyText;
messageToSend.Locale = "en-Us";
messageToSend.ServiceUrl = cookie.Address.ServiceUrl;

await connector.Conversations.SendToConversationAsync((Activity)messageToSend);

jsiegmund avatar Feb 20 '17 06:02 jsiegmund

That seems to work, with some minor modifications: (Only with Skype contacts by the way)

var userAccount = new ChannelAccount(bUsers.UserId);
            var botAccount = new ChannelAccount(context.Activity.From.Id);
            MicrosoftAppCredentials creds = new MicrosoftAppCredentials(AppKey, AppPwd); ;
            var connector = new ConnectorClient(new Uri(bUsers.ServiceUrl), creds);

            // need to trust the service URL because otherwise the bot connector authentication will fail
            MicrosoftAppCredentials.TrustServiceUrl(bUsers.ServiceUrl);

            // construct the reply to send back to the user
            IMessageActivity messageToSend = Activity.CreateMessageActivity();
            messageToSend.ChannelId = context.Activity.ChannelId;
            messageToSend.From = botAccount;
            messageToSend.Recipient = userAccount;
            //messageToSend.Conversation = new ConversationAccount(id: context.Activity.Conversation.Id);
            messageToSend.Conversation = new ConversationAccount(id: bUsers.ConversationId);
            messageToSend.Text = "Hello";
            messageToSend.Locale = "en-Us";
            messageToSend.ServiceUrl = bUsers.ServiceUrl;

            await connector.Conversations.SendToConversationAsync((Activity)messageToSend);

rjoosen avatar Feb 20 '17 11:02 rjoosen

Working for me, but tested only for Skype, not sure if it works for any other channels

AlexanderKovalev avatar Feb 21 '17 08:02 AlexanderKovalev

Closing this as fixed.

Stevenic avatar Feb 23 '17 01:02 Stevenic

Why closed? Did "CreateDirectConversationAsync" fixed as well?

AlexanderKovalev avatar Feb 23 '17 08:02 AlexanderKovalev

Sorry... I thought this was a node issue. Assigned the right dev to it.

Stevenic avatar Feb 23 '17 22:02 Stevenic

@AlexanderKovalev @rjoosen @jsiegmund This issue was due to a configuration change on the backend that was fixed on Wed, 02/22/2017. It is not related to the client implementation or SDK update.

konstlut avatar Feb 27 '17 09:02 konstlut