Esempio n. 1
0
        private SpeechletResponse GetOnLaunchAsyncResult(Session session)
        {
            // called by OnLaunchAsync - when the user invokes your skill without an intent
            // called by OnIntentAsync if you forget to map an intent to an action

            return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse()
            {
                cardText = "I didn't understand your request.  Please try again"
            }, true));
        }
Esempio n. 2
0
        private SpeechletResponse GetOnLaunchAsyncResult(Session session)
        {
            // called by OnLaunchAsync - when the user invokes your skill without an intent
            // called by OnIntentAsync if you forget to map an intent to an action

            return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse()
            {
                cardText = "Thanks for giving us a try"
            }, true));
        }
 private SpeechletResponse InvalidApplicationId(Session session)
 {
     // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
     // code to include the correct AppId, return a visual and vocal error and do no more
     // Update the AppId variable in AlexaConstants.cs to resolve this issue
     return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse()
     {
         cardText = "Yeah, so an invalid Application ID was received from Alexa. Update that with a real token and maybe we'll talk. Maybe..."
     }, true));
 }
        private SpeechletResponse InvalidApplicationId(Session session)
        {
            // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
            // code to include the correct AppId, return a visual and vocal error and do no more
            // Update the AppId variable in AlexaConstants.cs to resolve this issue

            return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse()
            {
                cardText = "An invalid Application ID was received from Alexa.  Please update your Visual Studio project " +
                           "to include the correct value and then re-deploy your Azure project."
            }, true));
        }
        private SpeechletResponse GetOnLaunchAsyncResult(Session session)
        {
            // called by OnLaunchAsync - when the user invokes your skill without an intent
            // called by OnIntentAsync if you forget to map an intent to an action
            Trace.TraceInformation("In GetOnLaunchAsyncResult, about to send botframework \'Hello\'");
            string resp = SendToBotFramework(session.SessionId, "hello");

            return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse()
            {
                cardText = resp
            }, false));
        }
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
//        public override Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        {
            // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
            // code to include the correct AppId, return a visual and vocal error and do no more
            // Update the AppId variable in AlexaConstants.cs to resolve this issue
            if (AlexaUtils.IsRequestInvalid(session))
            {
                return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }
            // this function is invoked when Amazon matches what the user said to
            // one of your defined intents.  now you will need to handle
            // the request

            // intentRequest.Intent.Name contains the name of the intent
            // intentRequest.Intent.Slots.* contains slot values if you're using them
            // session.User.AccessToken contains the Oauth 2.0 access token if the user has linked to your auth system

            // Get intent from the request object.
            Intent intent     = intentRequest.Intent;
            string intentName = (intent != null) ? intent.Name : null;

            // If there's no match between the intent passed and what we support, (i.e. you forgot to implement
            // a handler for the intent), default the user to the standard OnLaunch request

            // you'll probably be calling a web service to handle your intent
            // this is a good place to create an httpClient that can be recycled across REST API requests
            // don't be evil and create a ton of them unnecessarily, as httpClient doesn't clean up after itself
            var httpClient = new HttpClient();

            switch (intentName)
            {
            // call the Transport for London (TFL) API and get status
            case ("AzureIntent"):
                return(await WebService.ApiRequest.GetResults(session, httpClient));

            //return Task.FromResult<SpeechletResponse>(Tfl.Status.GetResults(session, httpClient));

            // add your own intent handler

            // case ("YourCustomIntent"):
            //   return await YourCustomIntentClass(session, whateverYouNeedToPass);
            //   invalid pattern with change // return Task.FromResult<SpeechletResponse>(YourCustomIntentClass(session, whateverYouNeedToPass));

            // did you forget to implement an intent?
            // just send the user to the intent-less utterance

            default:
                return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));

                //return Task.FromResult<SpeechletResponse>(GetOnLaunchAsyncResult(session));
            }
        }
 public override async Task <SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session)
 {
     // this function is invoked when the user invokes your skill without an intent
     // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
     // code to include the correct AppId, return a visual and vocal error and do no more
     // Update the AppId variable in AlexaConstants.cs to resolve this issue
     if (AlexaUtils.IsRequestInvalid(session))
     {
         return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
     }
     return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));
 }
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        //        public override Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        {
            // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
            // code to include the correct AppId, return a visual and vocal error and do no more
            // Update the AppId variable in AlexaConstants.cs to resolve this issue

            if (AlexaUtils.IsRequestInvalid(session))
            {
                return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }

            // this function is invoked when Amazon matches what the user said to
            // one of your defined intents.  now you will need to handle
            // the request

            // intentRequest.Intent.Name contains the name of the intent
            // intentRequest.Intent.Slots.* contains slot values if you're using them
            // session.User.AccessToken contains the Oauth 2.0 access token if the user has linked to your auth system

            // Get intent from the request object.
            Intent intent     = intentRequest.Intent;
            string intentName = (intent != null) ? intent.Name : null;

            // If there's no match between the intent passed and what we support, (i.e. you forgot to implement
            // a handler for the intent), default the user to the standard OnLaunch request

            // you'll probably be calling a web service to handle your intent
            // this is a good place to create an httpClient that can be recycled across REST API requests
            // don't be evil and create a ton of them unnecessarily, as httpClient doesn't clean up after itself

            var httpClient = new HttpClient();

            switch (intentName)
            {
            case ("ExchangeCuIntent"):
                return(await Exchange.Status.GetResults(session, httpClient));

            case ("ExchangeCeoStatus"):
                return(await Exchange.Status.GetCeoResults(session, httpClient));

            // Open implementations (https://github.com/Apoc70/ExchangeSpeechAssistant/issues/1)

            //case ("ExchangeStatusIntent"):
            //    return await Exchange.Status.GetGeneralStatusResults(session, httpClient);

            //case ("ExchangeCorruptIndexIntent"):
            //    return await Exchange.Status.GetCorruptIndexResults(session, httpClient);

            default:
                return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));
            }
        }
        //#endif

        public override Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session)
        {
            // this function is invoked when a user begins a session with your skill
            // this is a chance to load user data at the start of a session
            // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
            // code to include the correct AppId, return a visual and vocal error and do no more
            // Update the AppId variable in AlexaConstants.cs to resolve this issue

            if (AlexaUtils.IsRequestInvalid(session))
            {
                return(Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }
            // to-do - up to you
            // return some sort of Task per function definition
            return(Task.Delay(0));
        }
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        //        public override Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        {
            Trace.TraceInformation("AlexaSpeechletAsync called");

            // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
            // code to include the correct AppId, return a visual and vocal error and do no more
            // Update the AppId variable in AlexaConstants.cs to resolve this issue

            if (AlexaUtils.IsRequestInvalid(session))
            {
                Trace.TraceInformation("AlexaSpeechletAsync InvalidApplication");
                return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }

            // this function is invoked when Amazon matches what the user said to
            // one of your defined intents.  now you will need to handle
            // the request

            // intentRequest.Intent.Name contains the name of the intent
            // intentRequest.Intent.Slots.* contains slot values if you're using them
            // session.User.AccessToken contains the Oauth 2.0 access token if the user has linked to your auth system

            // Get intent from the request object.
            Intent intent     = intentRequest.Intent;
            string intentName = (intent != null) ? intent.Name : null;

            // If there's no match between the intent passed and what we support, (i.e. you forgot to implement
            // a handler for the intent), default the user to the standard OnLaunch request

            // you'll probably be calling a web service to handle your intent
            // this is a good place to create an httpClient that can be recycled across REST API requests
            // don't be evil and create a ton of them unnecessarily, as httpClient doesn't clean up after itself

            var httpClient = new HttpClient();

            Trace.TraceInformation("AlexaSpeechletAsync called with intentName " + intentName);
            switch (intentName)
            {
            case "CatchAllIntent":
                try
                {
                    string resp = SendToBotFramework(session.SessionId, intentRequest.Intent.Slots["Search"].Value);

                    return(await Task.FromResult <SpeechletResponse>(AlexaUtils.BuildSpeechletResponse(
                                                                         new AlexaUtils.SimpleIntentResponse()
                    {
                        cardText = resp
                    }, true)));
                } catch (Exception ex)
                {
                    return(await Task.FromResult <SpeechletResponse>(AlexaUtils.BuildSpeechletResponse(
                                                                         new AlexaUtils.SimpleIntentResponse()
                    {
                        cardText = ex.ToString()
                    }, true)));
                }

            case "AMAZON.FallbackIntent":
                return(await Task.FromResult <SpeechletResponse>(AlexaUtils.BuildSpeechletResponse(
                                                                     new AlexaUtils.SimpleIntentResponse()
                {
                    cardText = "Decider received the Fallback Intent"
                }, true)));


            // add your own intent handler

            // case ("YourCustomIntent"):
            //   return await YourCustomIntentClass(session, whateverYouNeedToPass);
            //   invalid pattern with change // return Task.FromResult<SpeechletResponse>(YourCustomIntentClass(session, whateverYouNeedToPass));

            // did you forget to implement an intent?
            // just send the user to the intent-less utterance

            default:
                return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));
            }
        }
Esempio n. 11
0
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        //        public override Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session)
        {
            // if the inbound request doesn't include your Alexa Skills AppId or you haven't updated your
            // code to include the correct AppId, return a visual and vocal error and do no more
            // Update the AppId variable in AlexaConstants.cs to resolve this issue

            if (AlexaUtils.IsRequestInvalid(session))
            {
                return(await Task.FromResult <SpeechletResponse>(InvalidApplicationId(session)));
            }

            // this function is invoked when Amazon matches what the user said to
            // one of your defined intents.  now you will need to handle
            // the request

            // intentRequest.Intent.Name contains the name of the intent
            // intentRequest.Intent.Slots.* contains slot values if you're using them
            // session.User.AccessToken contains the Oauth 2.0 access token if the user has linked to your auth system

            // Get intent from the request object.
            Intent intent     = intentRequest.Intent;
            string intentName = (intent != null) ? intent.Name : null;

            // If there's no match between the intent passed and what we support, (i.e. you forgot to implement
            // a handler for the intent), default the user to the standard OnLaunch request

            // you'll probably be calling a web service to handle your intent
            // this is a good place to create an httpClient that can be recycled across REST API requests
            // don't be evil and create a ton of them unnecessarily, as httpClient doesn't clean up after itself

            var httpClient = new HttpClient();

            switch (intentName)
            {
            // call the Transport for London (TFL) API and get status

            case ("TflStatusIntent"):
                return(await Tfl.Status.GetResults(session, httpClient));

            //return Task.FromResult<SpeechletResponse>(Tfl.Status.GetResults(session, httpClient));

            // Advanced: call the Outlook API and read the number of unread emails and subject and sender of the first five
            // you will need to register for a Client ID with Microsoft and configure your skill for Oauth
            // uncomment the code below when you're ready

            // See README.md in the Outlook folder

            //case ("OutlookUnreadIntent"):
            //    return await Outlook.Mail.GetUnreadEmailCount(session, httpClient);
            //return Task.FromResult<SpeechletResponse>(Outlook.Mail.GetUnreadEmailCount(session, httpClient));

            // If you're feeling lucky - this intent reads your Outlook calendar
            // You need to first successfully configure the email skill that's above

            // Add these scopes to the Alexa Config Portal
            // https://outlook.office.com/calendars.read
            // https://outlook.office.com/mailboxsettings.readwrite
            //
            // if you were an early adopter of Azure4Alexa, you'll need to update the IntentSchema and Sample Utterances
            // in the Alexa Config Portal.  Copy and Paste again the contents of Outlook/Registration/AlexaIntentSchema.json and
            // Outlook/Registration/AlexaSampleUtterances.txt into the Alexa Config Portal under "Interaction Model" for your
            // skill

            // nezt uncomment the case statement below

            // then unlink/link your skill and sign in again

            //case ("OutlookCalendarIntent"):
            //    return await Outlook.Calendar.GetOutlookEventCount(session, httpClient);

            // If you're feeling really lucky:
            // call the Microsoft Groove Music API using pre-created intents provided by Alexa

            //case ("AMAZON.ChooseAction<object@MusicCreativeWork>"):
            //    return await Groove.Music.PlayGrooveMusic(session, httpClient, intentRequest);

            // pre-created intents provided by Alexa don't work (well) with playlists, so we
            // created this one below to handle things

            //case ("PlaylistPlay"):
            //    return await Groove.Music.PlayGroovePlaylist(session, httpClient, intentRequest);

            // add your own intent handler

            // case ("YourCustomIntent"):
            //   return await YourCustomIntentClass(session, whateverYouNeedToPass);
            //   invalid pattern with change // return Task.FromResult<SpeechletResponse>(YourCustomIntentClass(session, whateverYouNeedToPass));

            // did you forget to implement an intent?
            // just send the user to the intent-less utterance

            default:
                return(await Task.FromResult <SpeechletResponse>(GetOnLaunchAsyncResult(session)));
            }
        }