kind: AdaptiveDialog
modelDescription: This topic helps an employee initiate a relocation request, and seek approval. It will ask for the destination city, the destination state, and the intended date of relocation, then initiate an approval request. It should only be invoked when the employee says they want to submit a request to relocate to another office. It should not be invoked when they want information on the process or policy for relocations.
beginDialog:
  kind: OnRecognizedIntent
  id: main
  intent: {}
  actions:
    - kind: Question
      id: question_mjTElT
      interruptionPolicy:
        allowInterruption: true

      alwaysPrompt: false
      variable: Topic.DestinationLocation
      prompt: "{If(Not(IsBlankOrError(Global.ServiceNowUserLocation.result.full_name)), Concatenate(\"I see you currently work out of our \", Global.ServiceNowUserLocation.result.full_name, \" office, according to your user profile in ServiceNow. \"), \"I'm not able to retrieve your current location from your employee profile in ServiceNow. \")}Which office are you interested in relocating to?"
      validation: =Topic.DestinationLocation = 'crb50_hrSelfService.entity.Offices'.HOPQWd || Topic.DestinationLocation = 'crb50_hrSelfService.entity.Offices'.NBvTxt || Topic.DestinationLocation = 'crb50_hrSelfService.entity.Offices'.BKdb7h || Topic.DestinationLocation = 'crb50_hrSelfService.entity.Offices'.qycgWg || Topic.DestinationLocation = 'crb50_hrSelfService.entity.Offices'.RsdpvU
      entity:
        kind: ClosedListEntityReference
        entityId: crb50_hrSelfService.entity.Offices

    - kind: Question
      id: question_erXwir
      interruptionPolicy:
        allowInterruption: true

      alwaysPrompt: true
      variable: Topic.RelocationDate
      prompt: What is your planned date of relocation?
      invalidPrompt: Please specify a planned date of relocation that is in the future.
      validation: =Topic.RelocationDate > Now()
      entity: DatePrebuiltEntity

    - kind: ConditionGroup
      id: conditionGroup_opdo2U
      conditions:
        - id: conditionItem_9q2XU0
          condition: =!IsBlank(Global.ServiceNowUserLocation.result.full_name)
          actions:
            - kind: SetVariable
              id: setVariable_jfjxF0
              variable: Topic.OriginLocation
              value: =Global.ServiceNowUserLocation.result.full_name

      elseActions:
        - kind: Question
          id: question_gwWyCv
          interruptionPolicy:
            allowInterruption: true

          variable: Topic.CurrentOfficeChoice
          prompt: Which office are you currently based out of?
          entity:
            kind: ClosedListEntityReference
            entityId: crb50_hrSelfService.entity.Offices

        - kind: SetVariable
          id: setVariable_5WqSkx
          variable: Topic.OriginLocation
          value: =Text(Topic.CurrentOfficeChoice)

    - kind: ConditionGroup
      id: conditionGroup_fCuOYI
      conditions:
        - id: conditionItem_Phh8iP
          condition: =Topic.OriginLocation = Text(Topic.DestinationLocation)
          actions:
            - kind: SendActivity
              id: sendActivity_NgOTZX
              activity: |-
                From the information I have gathered, your destination office of {Text(Topic.DestinationLocation)} is the same as your current office.
                
                Please feel free to request assistance with something else.

            - kind: BeginDialog
              id: LMfzCN
              dialog: crb50_hrSelfService.topic.ResetConversationVariables

            - kind: CancelAllDialogs
              id: 0lmza9

    - kind: InvokeFlowAction
      id: invokeFlowAction_6uJDoI
      input:
        binding:
          text: =Topic.OriginLocation
          text_1: =Text(Topic.DestinationLocation)

      output:
        binding:
          deltahigh: Topic.DeltaHigh
          deltalow: Topic.DeltaLow

      flowId: 5f7337b0-fa08-f011-bae2-6045bd09634d

    - kind: SetVariable
      id: setVariable_JFcGk4
      variable: Topic.SalaryDelta
      value: =Concatenate(If(Topic.DeltaLow > 0, "+", ""), Text(Topic.DeltaLow), "% to ", If(Topic.DeltaHigh > 0, "+", ""), Text(Topic.DeltaHigh), "%") 

    - kind: Question
      id: question_Tfs7yw
      interruptionPolicy:
        allowInterruption: true

      alwaysPrompt: true
      variable: init:Topic.reasonForMove
      prompt: Are you moving for business or personal reasons?
      entity:
        kind: EmbeddedEntity
        definition:
          kind: ClosedListEntity
          items:
            - id: Business
              displayName: Business

            - id: Personal
              displayName: Personal

    - kind: SendActivity
      id: sendActivity_hkJ0Li
      activity: |-
        Great! Based on the location details you have provided, as well as the existing location information on your HR profile, here are the details and potential changes to your pay.
        
        Would you like to proceed with the relocation request?

    - kind: SetVariable
      id: setVariable_BseVPW
      variable: Topic.reasonCode
      value: =If(Text(Topic.reasonForMove) = "Personal", 770700001, 770700000)

    - kind: AdaptiveCardPrompt
      id: 6IvJ4l
      card: |-
        ={
            type: "AdaptiveCard",
            body: [
                {
                    type: "Container",
                    items: [
                {
                  type: "Container",
                            separator: true,
                            items: [            
                        {
                            type: "ColumnSet",
                            columns: [
                                {
                                    type: "Column",
                                    items: [
                                        {
                                            type: "Image",
                                            url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALAAAACwCAYAAACvt+ReAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAlpSURBVHgB7d1NcFXlGcDx5+QmwWQIJmGkEHC8NK3FwrQwNazKKFKyRHDTFeLSip2xi84Uuqh2oezE6ce4BF25qbTd6VB06qaGae0MHVJHMYx8OMxAoolEuLk5vs8JNwPJ/ci993w95/x/M9GQXCAz/PPmPec95z2erJA/6fdLobRfCvKY+N528aUonvQL0C5fplxLE+6dj2Re3pdy1ylvwJtayW/1Gv7Zk35ROksvuJceIljExz8hpfJL3kDPRL1X1Qw4GHG75n7n3n1BgOQcl1LnS7VG5KoBB6NuV/mMe68oQOL8CTca7642Gncse+nk7e3Ei3Tx3IBaOOPPuDaXfubuXzDyIt2Wj8T3Bjwz9xnxIt004q4dlTnx4hTCnym9SrxIP6945+TCwq/0PwtTBx19ASNKc5t1KrEwAhdKLwpgSWchOL3r3TnfOymALVPu/PDmjmB5GLAnuLRBpxCPC2BRQR7rkA7vxwJY5HvbdQQuCmBT0XPnf30BjOoQwDAChmkEDNMIGKYRMEwjYJhGwDCNgGEaAcM0AoZpBAzTCBimETBMI2CYRsAwjYBhGgHDNAKGaQQM0wgYphEwTCNgmEbAMI2AYRoBwzQChmkEDNMIGKYRMEwjYJhGwDCNgGFap+TMzNinMnX6f/Ll6XNy63I8D2cq9PVI7yNDMrj/UekbGZbujQOCcORmh/by9Ddy9Y/vyLU3/ylJ6t44KOsO7pJ1T/9U0L5cBKzxfnzodZkdvyxpseHwqHvbK2hPLubAOvKmKV519U/vuLd3Be3JfMC33Tw36WlDLUTcvswHrJGkGRG3J/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Qu3F3+j/tkUYC08vwJ6e3a4XlesH6xuBIXzIU7CrvFc6MxkEYab0d5dyVedc9S8sJUYv4AESN1NF5fDlSmDosfrvba4KBuvnyG6QRSoTLyLolXVb2YJxiJbxd2cGCHxLkDtmDOWyVe5TX8/cEpttKL7qWHBIiHm+O6tYlC+XitcCsaBlzh++4sxdel/e7dx93IvN3Nkx8SVu8QDl1Mu6jXNsi89570dZ26+0Ctnm8B+DfLr3FW2OQAAAAASUVORK5CYII=",
                                            altText: "Relocation Summary",
                                            size: "Small",
                                            width: "44px",
                                            height: "44px"
                                        }
                                    ],
                                    width: "44px"
                                },
                                {
                                    type: "Column",
                                    items: [
                                        {
                                            type: "TextBlock",
                                            weight: "Bolder",
                                            text: "Relocation Summary",
                                            wrap: true,
                                            size: "Default"
                                        }
                                    ],
                                    width: "stretch",
                                    verticalContentAlignment: "Center"
                                }
                            ]
                        },
                        {
                            type: "TextBlock",
                            text: "Below are the details you provided:",
                            wrap: true
                        },
                        {
                            type: "TextBlock",
                            text: "**Current Office:** " & Topic.OriginLocation,
                            wrap: true
                        },
                        {
                            type: "TextBlock",
                            text: "**New Office:** " & Topic.DestinationLocation,
                            wrap: true,
                            spacing: "None"
                        },
                        {
                            type: "TextBlock",
                            text: "**Moving Date:** " & Text(Topic.RelocationDate, "MMMM dd, yyyy"),
                            wrap: true,
                            spacing: "None"
                        },
                        {
                            type: "TextBlock",
                            text: "**Salary Adjustment Range:** " & Topic.SalaryDelta,
                            wrap: true,
                            spacing: "None"
                        },
                        {
                        type: "ActionSet",
                        actions: [
                            {
                            type: "Action.Submit",
                            title: "Discard"
                            },
                            {
                            type: "Action.Submit",
                            title: "Proceed",
                            style: "positive"
                            }
                        ]
                        }
                    ]
                    
                }
                    ]
                }
            ],
            '$schema': "http://adaptivecards.io/schemas/adaptive-card.json",
            version: "1.5"
        }
      output:
        binding:
          actionSubmitId: Topic.initiationSelection

      outputType:
        properties:
          actionSubmitId: String

    - kind: ConditionGroup
      id: conditionGroup_1CDAWD
      conditions:
        - id: conditionItem_fZ3FLB
          condition: =Topic.initiationSelection = "Proceed"
          actions:
            - kind: InvokeFlowAction
              id: invokeFlowAction_XpsYuS
              input:
                binding:
                  email: =Global.ServiceNowUser.email
                  number: =Topic.reasonCode
                  text: =Global.ServiceNowUser.title
                  text_1: =Text(Topic.DestinationLocation)
                  text_2: =Global.ServiceNowUser.sys_id
                  text_3: =Topic.OriginLocation
                  text_4: =Env.cto_ServiceNowInstanceID
                  text_5: =Text(Topic.RelocationDate)
                  text_6: =Topic.SalaryDelta

              output:
                binding:
                  details: Topic.Details
                  success: Topic.Success

              flowId: bc73338c-c208-f011-bae2-6045bd02b60d

            - kind: SendActivity
              id: sendActivity_Gp2oWB
              activity: An approval request has been sent to your HR representative. You will be notified when the status of your relocation request is updated.

            - kind: BeginDialog
              id: MVbb2x
              dialog: crb50_hrSelfService.topic.ResetConversationVariables

            - kind: CancelAllDialogs
              id: nrYICq

      elseActions:
        - kind: SendActivity
          id: sendActivity_XfEpJ8
          activity: The request has been cancelled.

        - kind: BeginDialog
          id: KAAChs
          dialog: crb50_hrSelfService.topic.ResetConversationVariables

        - kind: CancelAllDialogs
          id: N83iIh

inputType:
  properties:
    DestinationLocation:
      displayName: DestinationLocation
      type:
        kind: ClosedListOptionSet
        schemaName: crb50_hrSelfService.entity.Offices

    OriginLocation:
      displayName: OriginLocation
      type: String

    reasonForMove:
      displayName: reasonForMove
      type:
        kind: EmbeddedOptionSet
        dialogSchemaName: crb50_hrSelfService.topic.RelocationInitiation
        triggerId: main
        actionId: question_Tfs7yw

    RelocationDate:
      displayName: RelocationDate
      type: Date

outputType: {}