Dialog

When executing or configuring commands on some devices, it is possible that a prompt message appears that requires a response. Blitz handles such prompts using the ‘reply’ field in the action snippet for the relevant command.

The ‘reply’ field is a list of reponse dictionaries. Each response dictionary has the following keys:

  • ‘pattern’: The regex pattern to match the prompt message.

  • ‘action’: The action to take when the prompt is matched.

  • ‘loop_continue’: A boolean that indicates whether to continue matching the prompt.

  • ‘continue_timer’: A boolean that indicates whether to reset the timer for continuing matches.

Creating a dialog

LAMP provides the dialog command to handle replies to prompts that appear during the execution of a command.

Dialogs are stored separately for each OS. The dialog command only modifies the dialog for the active device’s OS.

Adding a reply

Add a reply to the dialog for the active device’s OS using the dialog add-reply command.

Arguments for dialog add-reply (in order):

  • name: The name of the reply. Used to identify the reply.

  • pattern: The regex pattern to match the prompt message.

  • action: The action to take when the prompt is matched. The action can be one of the following:

    • password: Prompt for a password.

    • sendline: Send a line of characters.

  • action_arg: An optional argument for the action. The argument can be the following:

    • For password action: No argument is required.

    • For sendline action: The characters to send.

    If no argument is provided, LAMP prompts the user to enter the action argument interactively.

  • --loop-continue: Optional argument to indicate whether to continue matching the prompt.

  • --continue-timer: Optional argument to indicate whether to reset the timer for continuing matches.

Example:

(lamp-h2) dialog add-reply connect "Are you sure you want to continue connecting" sendline yes
2025-09-06 13:56:47: %LAMP-INFO: +..............................................................................+
2025-09-06 13:56:47: %LAMP-INFO: :          Added reply 'connect' to dialog for OS 'ios' successfully           :
2025-09-06 13:56:47: %LAMP-INFO: +..............................................................................+

Removing a reply

To remove a reply from the dialog for the active device’s OS, use the dialog remove-reply command and provide the name of the reply.

Example:

(lamp-h2) dialog remove-reply connect
2025-09-06 13:57:03: %LAMP-INFO: +..............................................................................+
2025-09-06 13:57:03: %LAMP-INFO: :        Removed reply 'connect' from dialog for OS 'ios' successfully         :
2025-09-06 13:57:03: %LAMP-INFO: +..............................................................................+

Listing replies

List all replies in the dialog for the active device’s OS using the dialog list-reply command.

Example:

(lamp-h2) dialog list-reply
                                            Dialog replies
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Name     ┃ Pattern                                      ┃ Action        ┃ Loop continue ┃ Continue timer ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ connect  │ Are you sure you want to continue connecting │ sendline(yes) │ True          │ False          │
│ password │ assword:                                     │ password      │ True          │ False          │
│ passcode │ Passcode or option                           │ sendline(1)   │ True          │ False          │
│ delete   │ Do you want to delete                        │ sendline      │ True          │ False          │
└──────────┴──────────────────────────────────────────────┴───────────────┴───────────────┴────────────────┘

Using dialog

execute

LAMP automatically uses the added dialog replies when executing a command via execute and fills the ‘reply’ field in the autogenerated Blitz action snippet with the corresponding replies sent to the device.

Example:

(lamp-h2) dialog add-reply reset Reset sendline yes
2025-09-06 14:07:26: %LAMP-INFO: +..............................................................................+
2025-09-06 14:07:26: %LAMP-INFO: :           Added reply 'reset' to dialog for OS 'ios' successfully            :
2025-09-06 14:07:26: %LAMP-INFO: +..............................................................................+
(lamp-h2) execute clear ospfv3 process
2025-09-06 14:07:33: %LAMP-INFO: +..............................................................................+
2025-09-06 14:07:33: %LAMP-INFO: :                  Execute 'clear ospfv3 process' on 'host2'                   :
2025-09-06 14:07:33: %LAMP-INFO: +..............................................................................+

host2#

2025-09-06 14:07:33,905: %UNICON-INFO: +++ host2(alias=h2) with via 'a': executing command 'clear ospfv3 process' +++
clear ospfv3 process
Reset selected OSPFv3 processes? [no]: yes
host2#
(lamp-h2) list 1
- execute:
    device: host2
    command: clear ospfv3 process
    reply:
        - pattern: Reset
        action: sendline(yes)
        loop_continue: true
        continue_timer: false
(lamp-h2)

The following example shows what happens when no action argument is provided to the sendline action. In this case, LAMP will prompt the user to enter the argument interactively:

(lamp-h2) dialog add-reply reset Reset sendline
2025-09-06 14:10:46: %LAMP-INFO: +..............................................................................+
2025-09-06 14:10:46: %LAMP-INFO: :           Added reply 'reset' to dialog for OS 'ios' successfully            :
2025-09-06 14:10:46: %LAMP-INFO: +..............................................................................+
(lamp-h2) execute clear ospfv3 process
2025-09-06 14:10:50: %LAMP-INFO: +..............................................................................+
2025-09-06 14:10:50: %LAMP-INFO: :                  Execute 'clear ospfv3 process' on 'host2'                   :
2025-09-06 14:10:50: %LAMP-INFO: +..............................................................................+

2025-09-06 14:10:50,321: %UNICON-INFO: +++ host2(alias=h2) with via 'a': executing command 'clear ospfv3 process' +++
clear ospfv3 process
Reset selected OSPFv3 processes? [no]:
Enter text to send:  y
y
host2#
(lamp-h2) list 1
- execute:
    device: host2
    command: clear ospfv3 process
    reply:
        - pattern: Reset
        action: sendline(y)
        loop_continue: true
        continue_timer: false
(lamp-h2)

Dialog replies also work in ‘exec-prompt’ mode. Below is an example:

(lamp-h2) dialog add-reply reset "Reset selected OSPFv3 processes" sendline yes
2025-09-10 10:12:37: %LAMP-INFO: +..............................................................................+
2025-09-10 10:12:37: %LAMP-INFO: :           Added reply 'reset' to dialog for OS 'ios' successfully            :
2025-09-10 10:12:37: %LAMP-INFO: +..............................................................................+
(lamp-h2) execute
host2# clear ospfv3 process

2025-09-10 10:12:41,655: %UNICON-INFO: +++ host2(alias=h2) with via 'a': executing command 'clear ospfv3 process' +++
clear ospfv3 process
Reset selected OSPFv3 processes? [no]: yes
host2#
host2# clear ospfv3 process

2025-09-10 10:12:42,757: %UNICON-INFO: +++ host2(alias=h2) with via 'a': executing command 'clear ospfv3 process' +++
clear ospfv3 process
Reset selected OSPFv3 processes? [no]: yes
host2#
host2# lamp
(lamp-h2) list 1
- execute:
    device: host2
    command: |-
        clear ospfv3 process
        clear ospfv3 process
    reply:
        - pattern: Reset selected OSPFv3 processes
        action: sendline(yes)
        loop_continue: true
        continue_timer: false

configure

Dialog replies work with configure command as well. However, dialog replies are currently not supported for ‘config-prompt’ mode.

Example using configure command:

(lamp-h2) dialog add-reply key_delete "Continue with master key deletion" sendline yes
2025-09-10 11:09:39: %LAMP-INFO: +..............................................................................+
2025-09-10 11:09:39: %LAMP-INFO: :         Added reply 'key_delete' to dialog for OS 'ios' successfully         :
2025-09-10 11:09:39: %LAMP-INFO: +..............................................................................+
(lamp-h2) configure key config-key password-encrypt abcdefgh + no key config-key password-encrypt
2025-09-10 11:09:53: %LAMP-INFO: +..............................................................................+
2025-09-10 11:09:53: %LAMP-INFO: :  Configure ['key config-key password-encrypt abcdefgh', 'no key config-key   :
2025-09-10 11:09:53: %LAMP-INFO: :                        password-encrypt'] on 'host2'                         :
2025-09-10 11:09:53: %LAMP-INFO: +..............................................................................+

2025-09-10 11:09:53,114: %UNICON-INFO: +++ host2(alias=h2) with via 'a': configure +++
config term
Enter configuration commands, one per line.  End with CNTL/Z.
host2(config)#key config-key password-encrypt abcdefgh
host2(config)#no key config-key password-encrypt
WARNING: All type 6 encrypted keys will become unusable
Continue with master key deletion ? [yes/no]: yes
host2(config)#end
host2#
(lamp-h2) list 1
- configure:
    device: host2
    command:
        - key config-key password-encrypt abcdefgh
        - no key config-key password-encrypt
    reply:
        - pattern: Continue with master key deletion
        action: sendline(yes)
        loop_continue: true
        continue_timer: false