Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 6dae291

Browse files
xieofxieryanisgrig
authored andcommitted
POI returns no route for not covered areas (#1960) (#1993)
1 parent 66277aa commit 6dae291

File tree

9 files changed

+29
-3
lines changed

9 files changed

+29
-3
lines changed

skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/RouteDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public async Task<DialogTurnResult> RouteToFindPointOfInterestBeforeRouteDialog(
241241

242242
if (cards.Count() == 0)
243243
{
244-
var replyMessage = ResponseManager.GetResponse(POISharedResponses.NoLocationsFound);
244+
var replyMessage = ResponseManager.GetResponse(POISharedResponses.NoRouteFound);
245245
await sc.Context.SendActivityAsync(replyMessage);
246246
}
247247
else if (cards.Count() == 1)

skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class POISharedResponses : IResponseIdCollection
2525
public const string NoLocationsFound = "NoLocationsFound";
2626
public const string MultipleRoutesFound = "MultipleRoutesFound";
2727
public const string SingleRouteFound = "SingleRouteFound";
28+
public const string NoRouteFound = "NoRouteFound";
2829
public const string PointOfInterestSelection = "PointOfInterestSelection";
2930
public const string CurrentLocationMultipleSelection = "CurrentLocationMultipleSelection";
3031
public const string CurrentLocationSingleSelection = "CurrentLocationSingleSelection";

skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@
216216
],
217217
"inputHint": "expectingInput"
218218
},
219+
"NoRouteFound": {
220+
"replies": [
221+
{
222+
"text": "Sorry, I didn't find any route.",
223+
"speak": "Sorry, I didn't find any route."
224+
}
225+
],
226+
"inputHint": "acceptingInput"
227+
},
219228
"PointOfInterestSelection": {
220229
"replies": [
221230
{

skills/src/csharp/pointofinterestskill/pointofinterestskill/Responses/Shared/POISharedResponses.zh.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@
226226
],
227227
"inputHint": "expectingInput"
228228
},
229+
"NoRouteFound": {
230+
"inputHint": "acceptingInput",
231+
"replies": [
232+
{
233+
"text": "对不起,我找不到任何路线。",
234+
"speak": "对不起,我找不到任何路线。"
235+
}
236+
]
237+
},
229238
"CurrentLocationSingleSelection": {
230239
"replies": [
231240
{

skills/src/csharp/pointofinterestskill/pointofinterestskill/Services/AzureMapsGeoSpatialService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,16 @@ void AddPoint(double longitude, double latitude)
265265
/// <returns>RouteDirections.</returns>
266266
private async Task<RouteDirections> GetRouteDirectionsAsync(string url)
267267
{
268-
var response = await httpClient.GetStringAsync(url);
268+
var response = await httpClient.GetAsync(url);
269+
270+
var apiResponse = new RouteDirections();
269271

270-
var apiResponse = JsonConvert.DeserializeObject<RouteDirections>(response);
272+
// TODO when it returns 400 for uncovered areas, we return no route instead. For other unsuccessful codes, exception is thrown as usual
273+
if (response.StatusCode != System.Net.HttpStatusCode.BadRequest)
274+
{
275+
response = response.EnsureSuccessStatusCode();
276+
apiResponse = JsonConvert.DeserializeObject<RouteDirections>(await response.Content.ReadAsStringAsync());
277+
}
271278

272279
apiResponse.Provider = PointOfInterestModel.AzureMaps;
273280

0 commit comments

Comments
 (0)