kind: AdaptiveDialog
modelDescription: This topic should be invoked when users ask to understand what the impact to compensation, salary, or benefits would be if relocating to another office.
beginDialog:
  kind: OnRecognizedIntent
  id: main
  intent: {}
  actions:
    - kind: Question
      id: question_JTXGRB
      interruptionPolicy:
        allowInterruption: true

      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?"
      defaultValueResponse: Please provide a destination office that is different from your current office.
      validation: =!IsBlank(Topic.DestinationLocation) && Topic.OriginLocation <> Text(Topic.DestinationLocation)
      entity:
        kind: ClosedListEntityReference
        entityId: crb50_hrSelfService.entity.Offices

    - kind: SetVariable
      id: setVariable_3Q60El
      variable: Topic.OriginLocation
      value: "=\"\""

    - kind: ConditionGroup
      id: conditionGroup_IDujk3
      conditions:
        - id: conditionItem_IKofpH
          condition: =!IsBlank(Global.ServiceNowUserLocation.result.full_name)
          actions:
            - kind: SetVariable
              id: setVariable_rMVWtr
              variable: Topic.OriginLocation
              value: =Global.ServiceNowUserLocation.result.full_name

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

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

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

    - kind: ConditionGroup
      id: conditionGroup_t3XwU6
      conditions:
        - id: conditionItem_VaYr81
          condition: =Topic.OriginLocation = Text(Topic.DestinationLocation)
          actions:
            - kind: SendActivity
              id: sendActivity_EYgz9o
              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: iRNE7w
              dialog: crb50_hrSelfService.topic.ResetConversationVariables

            - kind: CancelAllDialogs
              id: llgpgX

    - kind: InvokeFlowAction
      id: invokeFlowAction_iaIZDi
      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_VygW4I
      variable: Topic.SalaryDeltaText
      value: =Concatenate(If(Topic.DeltaLow > 0, "+", ""), Text(Topic.DeltaLow), "% to ", If(Topic.DeltaHigh > 0, "+", ""), Text(Topic.DeltaHigh), "%") 

    - kind: SendActivity
      id: sendActivity_km6btv
      activity: "{Concatenate(\"Based on cost of living adjustments between the \", Topic.OriginLocation, \" office and the \", Text(Topic.DestinationLocation), \" office, your salary would be likely to be adjusted by \", Topic.SalaryDeltaText)}"

    - kind: BeginDialog
      id: NJPnlC
      input:
        binding:
          KBtoSearch: =Env.cto_ServiceNowBenefitsKBID
          Query: =Concatenate("summarize the differences in benefits between employees in the ", Topic.OriginLocation, " versus employees in the ", Text(Topic.DestinationLocation), " office")
          RecordLimit: 2

      dialog: crb50_hrSelfService.topic.ServiceNowKnowledgeSearch
      output:
        binding:
          Answer: Topic.Answer

    - kind: ConditionGroup
      id: conditionGroup_mcEDAG
      conditions:
        - id: conditionItem_xC3NIT
          condition: =IsBlank(Topic.Answer)
          actions:
            - kind: SendActivity
              id: sendActivity_4pc65U
              activity: I'm not able to find details on the differences in benefits for this move. I recommend discussing potential benefit changes with your HR Representative.

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

      variable: init:Topic.ProceedToSubmit
      prompt: "{Concatenate(\"Would you like to proceed with initiating a request to relocate to the \", Text(Topic.DestinationLocation), \", based on this guidance?\")}"
      entity: BooleanPrebuiltEntity

    - kind: ConditionGroup
      id: conditionGroup_39QbxR
      conditions:
        - id: conditionItem_vouS8u
          condition: =Topic.ProceedToSubmit = true
          actions:
            - kind: BeginDialog
              id: ww7nN0
              input:
                binding:
                  DestinationLocation: =Topic.DestinationLocation
                  OriginLocation: =Topic.OriginLocation

              dialog: crb50_hrSelfService.topic.RelocationInitiation

            - kind: CancelAllDialogs
              id: tcp450

      elseActions:
        - kind: SendActivity
          id: sendActivity_eNfphr
          activity: Alright, let me know if I can be of any further assistance.

        - kind: BeginDialog
          id: 2ZPZaG
          dialog: crb50_hrSelfService.topic.ResetConversationVariables

        - kind: CancelAllDialogs
          id: wU3Mpg

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

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

    OriginLocation:
      displayName: OriginLocation
      type: String