Genesys Cloud - Main

 View Only

Sign Up

  • 1.  Nested 'if' Statement

    Posted 30 days ago

    Hi,

    Need help with a nested 'if' statement.

    I'm attempting to use two different variables to define which audio / tts prompt to announce. The following works perfectly:

    (If(Flow.bcpEmergencyGroupStatus==false, ToAudio(FindUserPrompt("TTS_Prompt_File"), ToAudio(FindUserPrompt(".Wav_Prompt_File")))

    but I'd like to add in another variable to the statement, i.e. using two values to determine which audio to use - example statement:

    If(Flow.bcpEmergencyGroupStatus==false, If(Flow.chosenLanguage=="en", ToAudio(FindUserPrompt("TTS_Prompt_File"), ToAudio(FindUserPrompt(".Wav_Prompt_File"))))

    and I'm not sure if my statement is incorrect or if it's not possible to use two variables within a 'if' statement against the 'play audio' node.

    Thanks,


    #Unsure/Other

    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------


  • 2.  RE: Nested 'if' Statement
    Best Answer

    Posted 30 days ago
    Edited by Jason Kleitz 30 days ago

    Hi Neil,

    Using the If statemant, you'll also need to define the audio for bcpEmergencyGroupStatus == true:

    If(Task.bcpEmergencyGroupStatus == false, If(Task.chosenLanguage == "en", ToAudioTTS("Audio 1"), ToAudio(FindUserPrompt("Audio 2"))), ToAudioTTS("True Audio Value"))

    If you need just using two or more validations combined, is there some options you can use like ternary expression:

    (Task.bcpEmergencyGroupStatus == false AND Task.chosenLanguage =="en") ? ToAudioTTS("Audio 1") : ToAudio(FindUserPrompt("Audio 2"))






    ------------------------------
    Debora Lopes
    ------------------------------



  • 3.  RE: Nested 'if' Statement

    Posted 30 days ago

    Thank you - appreciated.

    Using the second statement worded perfectly - learnt something new.

    Regards,



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 4.  RE: Nested 'if' Statement

    Posted 29 days ago

    Morning Debora,

    Sorry, but I've attempted to use the first 'if' statement in a test against a 'play audio' node and if seems that a boolean - audio isn't accepted. I've replaced the variables with actuals which relates to an in-queue flow callback offer prompt (example). Prior to this prompt I lookup against a data table for the TTS wording - hence the TTS variables for 'task.callbackOffer' and there are three fields (which donate different language wording) which is why I include 'OfferL1, OfferL2'.

    The variable Flow.chosenLanguage' relates to callers language (DTMF IVR) higher up in the inbound call flow and based on this output depends a which TTS language wording is used (task.callbackOffer = en, task.callbackOfferL1 = dk etc...).

    I was looking to add a additional 'if' statement into my query based on emergency group status (which I understand following a data action node API call) so if the status is 'false' then the correct TTS wording variable is used, but if its 'true then a .wav prompt file is played.

    I've made the variable 'Flow.bcpEmergencyGroupStatus' to a string prior to engaging this 'play audio' node to try and address the issue, but it didn't work.

    Hope this makes sense, and it is most like my statement that is incorrect.

    If(Flow.bcpEmergencyGroupStatus=="false", If(Flow.chosenLanguage==Task.promptLanguageD, ToAudioTTS(Task.callbackOffer), If(Flow.chosenLanguage==Task.promptLanguageL1, ToAudioTTS(Task.callbackOfferL1), If(Flow.chosenLanguage==Task.promptLanguageL2, ToAudioTTS(Task.callbackOfferL2), ToAudio(FindUserPrompt("brand_CallbackOffer"))))))

    Regards,



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 5.  RE: Nested 'if' Statement

    Posted 30 days ago

    Hi Neil,

    There is no reason why you can't. Some observations / questions though...

    1. What do you want to happen if Flow.bcpEmergencyGroupStatusis true? I think you're missing part of the statement? Or do you only want to use TTS_Prompt_File is Flow.bcpEmergencyGroupStatus==false is false AND chosenLanguage=="en"?
    2. I'm not a fan of reverse logic like this. It makes it harder to wrap your head around what's happening.
    3. Assuming Flow.bcpEmergencyGroupStatus==false is a boolean, you don't need the "==false"(if you reverse your logic 😉)



    ------------------------------
    Paul Simpson
    Views expressed are my own and do not necessarily reflect those of my employer.
    ------------------------------



  • 6.  RE: Nested 'if' Statement

    Posted 30 days ago

    Thanks for the quick response - appreciated.

    My statement my be incorrect, but if both variables are 'true' then the TTS prompt should be used, but if neither are 'true', i.e. false then the .wav file is to be played.

    Hope this helps.

    Thanks, 



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 7.  RE: Nested 'if' Statement

    Posted 29 days ago

    Hi @Neil Jones,

    I think your IF statement is not complete as you are missing the ELSE part. The Architect IF statement is like IF(statement true, then do this, else do this), but I can't see the else part on the very first IF statement;

    If(Flow.bcpEmergencyGroupStatus=="false",
          If(Flow.chosenLanguage==Task.promptLanguageD,
                ToAudioTTS(Task.callbackOffer),
                If(Flow.chosenLanguage==Task.promptLanguageL1,
                      ToAudioTTS(Task.callbackOfferL1),
                      If(Flow.chosenLanguage==Task.promptLanguageL2,
                            ToAudioTTS(Task.callbackOfferL2),
                            ToAudio(FindUserPrompt("brand_CallbackOffer"))

                      )

                 )

           )

    )

    In the above there is no ELSE for the first IF. I have marked the missing part of the code in RED.


    If(Flow.bcpEmergencyGroupStatus=="false",


          If(Flow.chosenLanguage==Task.promptLanguageD,
                ToAudioTTS(Task.callbackOffer),
                If(Flow.chosenLanguage==Task.promptLanguageL1,
                      ToAudioTTS(Task.callbackOfferL1),
                      If(Flow.chosenLanguage==Task.promptLanguageL2,
                            ToAudioTTS(Task.callbackOfferL2),
                            ToAudio(FindUserPrompt("brand_CallbackOffer"))

                      )

                 )

           )

    ),

    (

    THIS IS THE ELSE PART FOR FIRST IF

    )

    )



    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------



  • 8.  RE: Nested 'if' Statement

    Posted 29 days ago

    Thanks you.

    Believe this is now correct...

    If(Flow.bcpEmergencyGroupStatus=="false", If(Flow.chosenLanguage==Task.promptLanguageD, ToAudioTTS(Task.callbackOffer), If(Flow.chosenLanguage==Task.promptLanguageL1, ToAudioTTS(Task.callbackOfferL1), If(Flow.chosenLanguage==Task.promptLanguageL2, ToAudioTTS(Task.callbackOfferL2), ToAudioTTS(Task.callbackOffer)))), ToAudio(FindUserPrompt("Novasol_CallbackOffer")))



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 9.  RE: Nested 'if' Statement

    Posted 29 days ago

    Yes looks better now and you also have no error anymore. Hope you have found answer for your original question.



    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------



  • 10.  RE: Nested 'if' Statement

    Posted 29 days ago

    Hi Neil!

    Just a tip, you can change the Flow.bcpEmergencyGroupStatus=="false"  to !Flow.bcpEmergencyGroupStatus.



    ------------------------------
    Debora Lopes
    ------------------------------