This is a really important message about something. It could be about anything we deem important enough to tell everyone. It might have links to places, but shouldn't have any images or non-text content. Messages shouldn't be longer than two lines on normal sized layouts.
Genesys Cloud Developer CenterGenesys Cloud Developer Center
Browser storage is disabled

Your theme selection will not be remembered when you refresh the page. Please enable browser storage in the Account Switcher above to allow this setting to be remembered.

Removed from toolbox

Lesson 2 - Task with Decision action

Now we will go ahead and create an inbound call flow with a startup task instead of a menu. This flow looks to see what number was called for an inbound flow and if it's "+16504661100" it sets a site name variable to "Genesys Daly City", if it's "+13178723000" it sets "Genesys Indianapolis" and if it's anything else it sets the site string variable to "Genesys".

It will then use that site name in the initial greeting for the flow and present the caller with a menu.

Here is the flow YAML:

Copied
inboundCall:
  name: My Flow
  defaultLanguage: en-us  
  startUpRef: /inboundCall/tasks/task[myStartingTask]
  initialGreeting:
    exp: Append("Hello and welcome to ", Flow.siteName, ".")
  menus:
    - menu:  
        name: Main Menu
        audio:
          tts: You are at the Main Menu, press 9 to disconnect.
        refId: mainMenu
        choices:
          - menuDisconnect:
              name: Disconnect
              dtmf: digit_9
  tasks:
    - task:
        name: Starting Task
        refId: myStartingTask
        actions:          
          - updateData:
              name: Set up flow variables
              statements:
                - string:
                    variable: Flow.calledNumber
                    value:
                      exp:
                        If(IsSet(ToPhoneNumber(Call.CalledAddress)) and IsSet(ToPhoneNumber(Call.CalledAddress).e164),
                          ToPhoneNumber(Call.CalledAddress).e164,
                          ""
                        )  
                - string:
                    variable: Flow.siteName
                    value:
                      exp:
                        If(Flow.calledNumber == "+16504661100", "Genesys Daly City",
                          If(Flow.calledNumber == "+13178723000", "Genesys Indianapolis",
                            ""
                          )
                        )          
          - decision:
              name: Is site name blank?
              condition:
                exp: IsNotSetOrEmpty(Flow.siteName)
              outputs:
                yes:
                  actions:
                    - updateData:
                        name: Set site name to "Genesys"
                        statements:
                          - string:
                              variable: Flow.siteName
                              value:
                                lit: Genesys
          - jumpToMenu:
              name: Go to the main menu
              targetMenuRef: /inboundCall/menus/menu[mainMenu]

For flow types that allow tasks, notice how we added a tasks array and then added a task to it above. The task has a name of 'Starting Task'. While we will talk about this later, notice how we put a reference id of 'myStartingTask' on this task. That makes it something that can be referenced by other parts of the flow. Up at the top of the flow the startUpRef property points to this task.

Then since a task is an action container, it has an actions array where we added additional logic to set up a string value in a Flow.siteName variable. While we could have put the "Genesys" default value in the Update Data action itself, we added a decision action to check to see if Flow.siteName was blank. This shows an action with outputs. Notice how outputs is an array. You can then add a yes output to the array and since an output is an action container similar to a task, add an actions array and then add actions to it. This is just like Architect's UI but now you're doing it in YAML.


Tutorial Main | Previous Lesson | Next Lesson


Archy - Ver. 2.33.1, generated on January 3, 2025