#
# This workflow demonstrates how to use the Question action
# to request user input and confirm it matches the original input.
#
# Note: This workflow doesn't make use of any agents.
#
kind: Workflow
trigger:

  kind: OnConversationStart
  id: workflow_demo
  actions:
  
    # Capture original input
    - kind: SetVariable
      id: set_project
      variable: Local.OriginalInput
      value: =System.LastMessage.Text

    # Request input from user
    - kind: Question
      id: question_confirm
      alwaysPrompt: false
      autoSend: false
      property: Local.ConfirmedInput
      prompt:
        kind: Message
        text:
            - "CONFIRM:"
      entity:
        kind: StringPrebuiltEntity

    # Confirm input
    - kind: ConditionGroup
      id: check_completion
      conditions:

        # Didn't match
        - condition: =Local.OriginalInput <> Local.ConfirmedInput
          id: check_confirm
          actions:

            - kind: SendActivity
              id: sendActivity_mismatch
              activity: |-
                "{Local.ConfirmedInput}" does not match the original input of "{Local.OriginalInput}". Please try again.

            - kind: GotoAction
              id: goto_again
              actionId: question_confirm

      # Confirmed
      elseActions:
        - kind: SendActivity
          id: sendActivity_confirmed
          activity: |-
            You entered:
            {Local.OriginalInput}

            Confirmed input:
            {Local.ConfirmedInput}
