我的问题是关于..
我创建了一种定制的Alexa技能,希望向用户提供以下功能:
有办法吗?
这是示例代码
if (null!= intentRequest.Intent.Slots[AlexaConstants.facilityQuery].Value && !"".Equals(intentRequest.Intent.Slots[AlexaConstants.facilityQuery].Value))
{
if (!"".Equals(getResolution(input, AlexaConstants.facilityQuery)))
{
HighwayEventsController apitransit = new HighwayEventsController();
log.LogLine(JsonConvert.SerializeObject(intentRequest));
var facilityQuery = getResolution(input, AlexaConstants.facilityQuery);
string highwayOutput = apitransit.GetHighwayEventsData(facilityQuery);
//(innerResponse as SsmlOutputSpeech).Ssml = $"<speak>{apitransit.GetHighwayEventsData(facilityQuery)}<break time='1s'/> {otherFacilityMsg}</speak>";
intentRequest.Intent.Slots[AlexaConstants.facilityQuery].Value = "";
intentRequest.Intent.Slots[AlexaConstants.choice].Value = "by name";
response.Response.Directives.Add(getDialogDirective(input, AlexaConstants.HighwayEventIntent, AlexaConstants.next));
response.Response.Reprompt = getReprompt("say next for next event, or say go to main menu or say stop for exit");
string pattern = @"Event \d+";
string[] result = Regex.Split(highwayOutput, pattern);
string speak = result.Length > 0 ? result[0] + "Event 1 " + result[1] : highwayOutput;
innerResponse = new SsmlOutputSpeech();
(innerResponse as SsmlOutputSpeech).Ssml = $"<speak>{speak}<break time='500ms'/> say next for next event, or say go to main menu or say stop for exit</speak>";
Dictionary<string, object> events = new Dictionary<string, object>();
for (int i = 2; i < result.Length; i++)
{
events.Add("Event " + i, "Event " + i + " " + result[i]);
}
events.Add("currentVal", 2);
events.Add("TotalEvents", result.Length - 1);
response.SessionAttributes = events;
}
else
{
response.Response.Directives.Add(getDialogDirective(input, AlexaConstants.HighwayEventIntent, AlexaConstants.facilityQuery));
innerResponse = new PlainTextOutputSpeech();
(innerResponse as PlainTextOutputSpeech).Text = "Invalid Facility. please Provide facility name";
}
}