Exemple #1
0
        public SpeechletResponse DialogConfirmSlot(Slot slotToElicit, OutputSpeech outputSpeech)
        {
            var intentRequest = (RequestEnvelope.Request as IntentRequest);

            if (intentRequest == null)
            {
                throw new SpeechletException("IntentRequest required");
            }

            if (slotToElicit == null)
            {
                throw new ArgumentNullException(nameof(slotToElicit));
            }
            if (outputSpeech == null)
            {
                throw new ArgumentNullException(nameof(outputSpeech));
            }

            var response = new SpeechletResponse()
            {
                OutputSpeech = outputSpeech,
                Directives   = new List <Directive>()
                {
                    new DialogConfirmSlotDirective()
                    {
                        SlotToConfirm = slotToElicit.Name,
                        UpdatedIntent = intentRequest.Intent
                    }
                },
                ShouldEndSession = false
            };

            return(response);
        }
Exemple #2
0
 /// <summary>
 /// Ask for Permissions
 /// </summary>
 /// <param name="permissionType"></param>
 /// <returns>The SpeechletResponse</returns>
 public SpeechletResponse AskForPermissionsConsentCard(OutputSpeech outputSpeech, params PermissionTypeEnum[] permissionType)
 {
     return(new SpeechletResponse()
     {
         OutputSpeech = outputSpeech,
         Card = new AskForPermissionsConsentCard(permissionType),
         //do not send
         ShouldEndSession = null
     });
 }
Exemple #3
0
        private static AlexaResponse GetPlainTextResponse(string text, bool endSession)
        {
            OutputSpeech speech = new OutputSpeech()
            {
                Type = "PlainText",
                Text = text
            };

            return(new AlexaResponse()
            {
                Version = "1.0",
                Response = new ResponseBody()
                {
                    OutputSpeech = speech,
                    ShouldEndSession = endSession
                },
            });
        }
Exemple #4
0
        /// <summary>
        /// Create a SpeechletResponse to send Alexa a command to stream the audio file identified by the specified audioItem.
        /// Use the playBehavior parameter to determine whether the stream begins playing immediately,
        /// or is added to the queue.
        /// </summary>
        /// <param name="stream">Representing the audio stream to play</param>
        /// <param name="playbehavior">Describes playback behavior.</param>
        /// <param name="outputSpeech"></param>
        /// <returns>The SpeechletResponse</returns>
        public SpeechletResponse AudioPlayer_Play(AudioStream stream, OutputSpeech outputSpeech, PlayBehaviorEnum playbehavior = PlayBehaviorEnum.REPLACE_ALL)
        {
            var response = new SpeechletResponse()
            {
                Directives = new List <Directive>()
                {
                    new AudioPlayerPlayDirective()
                    {
                        PlayBehavior = playbehavior,
                        AudioItem    = new AudioItem()
                        {
                            Stream = stream
                        }
                    }
                },
                OutputSpeech     = outputSpeech,
                ShouldEndSession = true
            };

            return(response);
        }
Exemple #5
0
        /// <summary>
        /// Sends Alexa a command to confirm the all the information the user has provided for the intent before the skill takes action.
        /// Provide a prompt to ask the user for confirmation in an OutputSpeech object in the response. Be sure to repeat back all the values the user needs to confirm in the prompt.
        /// If your skill does not meet the requirements to use the Dialog directives, returning Dialog.ConfirmIntent causes an error
        /// </summary>
        /// <returns></returns>
        public SpeechletResponse DialogConfirmIntent(OutputSpeech outputSpeech)
        {
            var intentRequest = (RequestEnvelope.Request as IntentRequest);

            if (intentRequest == null)
            {
                throw new SpeechletException("IntentRequest required");
            }

            var response = new SpeechletResponse()
            {
                Directives = new List <Directive>()
                {
                    new DialogConfirmIntentDirective()
                    {
                        //UpdatedIntent = intentRequest.Intent
                    }
                },
                OutputSpeech     = outputSpeech,
                ShouldEndSession = false
            };

            return(response);
        }
Exemple #6
0
 public Response()
 {
     OutputSpeech     = new OutputSpeech();
     ShouldEndSession = false;
 }
 public ISpeechletResponseBuilder Say(OutputSpeech outputSpeech)
 {
     response.OutputSpeech = outputSpeech;
     return(this);
 }
Exemple #8
0
        public AlexaResponse GetBalance(AlexaRequest alexaReq)
        {
            AlexaResponse alexaResp = new AlexaResponse();
            OutputSpeech  speech    = OutputMsgMaps.speechMap[Converters.BALANCE_ENQUIRY_SPEECH];
            Dictionary <string, object> sessionAttr = alexaReq?.session?.attributes;

            if (sessionAttr == null)
            {
                sessionAttr = new Dictionary <string, object>();
            }
            try
            {
                string deviceId = alexaReq?.session?.user.userId;
                if (string.IsNullOrEmpty(deviceId))
                {
                }
                //get user details from DB
                UserDetails user = DataLogic.GetUserDetails(deviceId);
                if (user == null)
                {
                }
                List <UserBankAccount> accounts = TransactionProcessor.GetBalance(user.PhoneNumber);
                if (accounts == null)
                {
                }
                else if (accounts.Count == 0)
                {
                }
                else if (accounts.Count == 1)
                {
                    speech.text = $"<speak><s><emphasis level=\"moderate\">yay!</emphasis></s> <say-as interpret-as=\"cardinal\"> {accounts[0].AccountBalance} </ say -as> naira is left in your account</ speak > ";

                    if (sessionAttr.ContainsKey(SessionAttributes.BALANCE))
                    {
                        sessionAttr[SessionAttributes.BALANCE] = accounts[0].AccountBalance;
                    }
                    else
                    {
                        sessionAttr.Add(SessionAttributes.BALANCE, accounts[0].AccountBalance);
                    }

                    if (sessionAttr.ContainsKey(SessionAttributes.ACCOUNT_NUMBER))
                    {
                        sessionAttr[SessionAttributes.PHONE_NUMBER] = accounts[0].PhoneNumber;
                    }
                    else
                    {
                        sessionAttr.Add(SessionAttributes.PHONE_NUMBER, accounts[0].PhoneNumber);
                    }
                    if (sessionAttr.ContainsKey(SessionAttributes.ACCOUNT_NUMBER))
                    {
                        sessionAttr[SessionAttributes.ACCOUNT_NUMBER] = accounts[0].AccountNumber;
                    }
                    else
                    {
                        sessionAttr.Add(SessionAttributes.ACCOUNT_NUMBER, accounts[0].AccountNumber);
                    }
                }
                else
                {
                    int    number  = accounts.Count;
                    string numWord = Converters.numberWordsMap.ContainsKey(number) ? Converters.numberWordsMap[number] : number.ToString();
                    string text    = $"{numWord} accounts found. and the balances are ";
                    for (int i = 0; i < accounts.Count; i++)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(alexaResp);
        }