@@ -14,11 +14,11 @@ internal class ChatSession : IDisposable
14
14
private const string PROD_ACCESS_URL = "https://copilotweb.production.portalrp.azure.com/api/access?api-version=2024-09-01" ;
15
15
private const string TEST_ACCESS_URL = "https://copilotweb.canary.production.portalrp.azure.com/api/access?api-version=2024-09-01" ;
16
16
private const string DL_TOKEN_URL = "https://copilotweb.production.portalrp.azure.com/api/conversations/start?api-version=2024-11-15" ;
17
- private const string CONVERSATION_URL = "https://directline.botframework.com/v3/directline/conversations" ;
18
17
19
18
internal bool UserAuthorized { get ; private set ; }
20
19
21
20
private string _streamUrl ;
21
+ private string _dlBaseUrl ;
22
22
private string _conversationId ;
23
23
private string _conversationUrl ;
24
24
private UserDirectLineToken _directLineToken ;
@@ -101,6 +101,7 @@ internal async Task<string> RefreshAsync(IStatusContext context, bool force, Can
101
101
private void Reset ( )
102
102
{
103
103
_streamUrl = null ;
104
+ _dlBaseUrl = null ;
104
105
_conversationId = null ;
105
106
_conversationUrl = null ;
106
107
_directLineToken = null ;
@@ -180,12 +181,14 @@ private async Task GetInitialDLTokenAsync(CancellationToken cancellationToken)
180
181
181
182
using Stream stream = await response . Content . ReadAsStreamAsync ( cancellationToken ) ;
182
183
var dlToken = JsonSerializer . Deserialize < DirectLineToken > ( stream , Utils . JsonOptions ) ;
183
- _directLineToken = new UserDirectLineToken ( dlToken . DirectLine . Token , dlToken . DirectLine . TokenExpiryTimeInSeconds ) ;
184
+
185
+ _dlBaseUrl = dlToken . DirectLine . Endpoint ;
186
+ _directLineToken = new UserDirectLineToken ( dlToken . DirectLine . Token , dlToken . DirectLine . TokenExpiryTimeInSeconds , _dlBaseUrl ) ;
184
187
}
185
188
186
189
private async Task < string > OpenConversationAsync ( CancellationToken cancellationToken )
187
190
{
188
- HttpRequestMessage request = new ( HttpMethod . Post , CONVERSATION_URL ) ;
191
+ HttpRequestMessage request = new ( HttpMethod . Post , $ " { _dlBaseUrl } /conversations" ) ;
189
192
request . Headers . Authorization = new AuthenticationHeaderValue ( "Bearer" , _directLineToken . Token ) ;
190
193
191
194
HttpResponseMessage response = await _httpClient . SendAsync ( request , cancellationToken ) ;
@@ -195,8 +198,8 @@ private async Task<string> OpenConversationAsync(CancellationToken cancellationT
195
198
SessionPayload spl = JsonSerializer . Deserialize < SessionPayload > ( content , Utils . JsonOptions ) ;
196
199
197
200
_conversationId = spl . ConversationId ;
198
- _conversationUrl = $ "{ CONVERSATION_URL } /{ _conversationId } /activities";
199
- _directLineToken = new UserDirectLineToken ( spl . Token , spl . ExpiresIn ) ;
201
+ _conversationUrl = $ "{ _dlBaseUrl } /conversations /{ _conversationId } /activities";
202
+ _directLineToken = new UserDirectLineToken ( spl . Token , spl . ExpiresIn , _dlBaseUrl ) ;
200
203
_streamUrl = spl . StreamUrl ;
201
204
_copilotReceiver = await AzureCopilotReceiver . CreateAsync ( _streamUrl ) ;
202
205
0 commit comments