Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/9ee926b2f6bef58347c8d4abc57b13d2 to your computer and use it in GitHub Desktop.
Save elbruno/9ee926b2f6bef58347c8d4abc57b13d2 to your computer and use it in GitHub Desktop.
AlexaSkillBrunoEventsAlexaSkillBrunoEvents.cs
namespace AlexaSkillBrunoEvents.Alexa
{
public class AlexaSkillBrunoEvents : SpeechletAsync
{
public override Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session)
{
return Task.FromResult(CompileResponse("Launch Event for Bruno Events"));
}
public async override Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
{
var message = new StringBuilder();
message.Append($"Intent called {intentRequest.Intent}.");
if (intentRequest.Intent.Slots.Count > 0)
{
message.Append($" Slots used. ");
foreach (var intentSlot in intentRequest.Intent.Slots)
message.Append($"{intentSlot.Key} ");
}
var response = CompileResponse(message.ToString());
return await Task.FromResult(response);
}
public override Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session)
{
return Task.FromResult(0);
}
public override Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session)
{
return Task.FromResult(0);
}
public static SpeechletResponse CompileResponse(string output)
{
var response = new SpeechletResponse
{
OutputSpeech = new PlainTextOutputSpeech { Text = output },
ShouldEndSession = true
};
return response;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment