What is the difference between IActivity.ServiceUrl and IActivity.ChannelId in .Bot Builder .NET SDK? I am trying to initiate a new conversation from bot by having a UserId (stored from previous conversations) and a channelId (also stored) by using CreateConversationAsync. This requires an ConversationParameters instance, which in turn requires an Activity instance. An activity, though, has both these properties. Is it enough to set a ChannelId there without using ServiceUrl? The reason I'm asking this is because ServiceUrl can be changed (which happened for Skype channel), so there's no point in storing it for a long period of time.
Thanks a lot
Hi @shigasumi,
Please take a look at the Bot Framework IDs guide and let me know if you need additional help.
Thanks a lot for the link, @RobStand.
I guess the title of the issue was a bit misleading (I've edited it a bit). The problem is, I still don't understand whether ChannelId can server as the only other necessary primitive (in addition to UserId) to start a conversation - it seems there's no way to get an instance of ConnectorClient other than having a ServiceUrl. If this is true, what's the purpose of ChannelId? How it is supposed to be used (except "serving as namespaces for other IDs").
Thanks again!
Hi @shigasumi, I'll chat with the team and get back to you.
Hi @shigasumi, the values are simply different.
The Service URL is the endpoint where you send your responses.
The channel ID is the namespace for other IDs, and is used to identify which channel you're talking to. (Channels differ in the way they behave, and the channel ID is the way you identify them.)
You may have more than one Service URL per channel. This can happen when a channel has multiple deployments/tenants/geographies.
You may have more than one channel per Service URL. This can happen when channels are hosted on the same backend infrastructure.
You may have more than one Service URL per channel. This can happen when a channel has multiple deployments/tenants/geographies.
You may have more than one channel per Service URL. This can happen when channels are hosted on the same backend infrastructure.
@dandriscoll this is very interesting. I wish there was an API to get Service URL by channel ID, and Conversation ID. I'm working on the case when we use hard-coded Service URL and store Conversation ID in DB and we are sending messages to those chats. I was looking into https://github.com/MicrosoftDX/botFramework-proactiveMessages but I would dare to say that it's just a joke (storing Service URL in global variable once you get private message from the bot).
So goal right now to make this work without hard-coded Service URL values. The problem is following. Imagine you want to send a message to Conversation ID that was inactive for a month and you know that it's skype (Channel ID). Do you use Service URL value that you just got from another conversation in skype? Do you use the value you got for this particular Conversation 30 days ago? Or you use just hard-coded skype.botframework.com?
So far the message that I quoted is the only information that I found regulating Service URL values, but it means that you can't actually trust in Services URL data at all. And the only solution "just wait (potentially another 30 days) until you get the message from this Conversation ID and use its Service URL.".
p.s. I just found a similar request in https://github.com/Microsoft/BotBuilder/issues/2021 difference in my request in that I guess I want I want "Ability to resolve ServiceUrl by Channel ID + Conversation ID" (and potentially Message ID for replies?).
From there I see the solution
so we're recommending you use Resumption Cookie or Address for now.
for how long it is safe to assume Resumption Cookie or Address values to be valid? What do I do once those are no longer valid?
@JLarky Does the bot has the ability to send a message to user after 30 days?
I go this error message within 24hours.
System.UnauthorizedAccessException: Authorization for Microsoft App ID c860c43a-44fe-47ae-8534-ebecfb84aac7 failed with status code Unauthorized and reason phrase 'Unauthorized' ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.Bot.Connector.JwtTokenRefresher.<SendAsync>d__2.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.Bot.Connector.JwtTokenRefresher.<SendAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Bot.Connector.Conversations.<SendToConversationWithHttpMessagesAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.<SendToConversationAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
@willportnoy Please help.
@alokraj68 token that you get from /common/oauth2/v2.0/token from your app id and secret is only good for some limited time, but you can get new one at any time. Topic we are discussing here is about ServiceUrl and ConversationId, not the token
@JLarky Thank you. I wanted to clarify the line you wrote "Do you use the value you got for this particular Conversation 30 days ago? "
Is it possible in such way from bot side to refresh this token without a user message?
@alokraj68 we have logic in JwtTokenRefresher to refresh the oauth token on demand, usually when sending a message back to the connector or state service.
@willportnoy Then I would lie to report it has some issues, I get authorization error with the same token at times, while it works after I send a message from the user to bot, that is manually refreshing.
@alokraj68 we've improved the oauth refreshing logic to refresh oauth tokens on both 401 and 403 because some channels were incorrectly reporting a 403 instead of just a 401.
Most helpful comment
@dandriscoll this is very interesting. I wish there was an API to get Service URL by channel ID, and Conversation ID. I'm working on the case when we use hard-coded Service URL and store Conversation ID in DB and we are sending messages to those chats. I was looking into https://github.com/MicrosoftDX/botFramework-proactiveMessages but I would dare to say that it's just a joke (storing Service URL in global variable once you get private message from the bot).
So goal right now to make this work without hard-coded Service URL values. The problem is following. Imagine you want to send a message to Conversation ID that was inactive for a month and you know that it's skype (Channel ID). Do you use Service URL value that you just got from another conversation in skype? Do you use the value you got for this particular Conversation 30 days ago? Or you use just hard-coded skype.botframework.com?
So far the message that I quoted is the only information that I found regulating Service URL values, but it means that you can't actually trust in Services URL data at all. And the only solution "just wait (potentially another 30 days) until you get the message from this Conversation ID and use its Service URL.".