コード例 #1
0
 private SpeechletResponse InvalidApplicationId(Session session)
 {
     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));
 }
コード例 #2
0
 private SpeechletResponse GetOnLaunchAsyncResult(Session session)
 {
     return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse
     {
         cardText = "",
         ssmlString = "<speak>Voice bot<break time=\"0.2s\" />obviously</speak>"
     }, true));
 }
コード例 #3
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 = "Oh hello. How are you doing? Good? Great. Nobody cares. F**k of!"
     }, true));
 }
コード例 #4
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));
        }
コード例 #5
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));
        }
コード例 #6
0
 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));
 }
コード例 #7
0
        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));
        }
コード例 #8
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
            Trace.TraceInformation("In GetOnLaunchAsyncResult, about to send botframework \'Hello\'");
            string resp = SendToBotFramework(session.SessionId, "hello");

            return(AlexaUtils.BuildSpeechletResponse(new AlexaUtils.SimpleIntentResponse()
            {
                cardText = resp
            }, false));
        }
コード例 #9
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)));
            }
        }