Skip to content

Lab 2 -- Build Workflows Like Scripts

Pre-built workflows make automation quick and easy---no coding required! But since every network is different, automation needs can vary too. That's why Workflows offer hundreds of atomic actions across solutions, giving you the flexibility to customize any workflow or build your own from scratch. Think of it like LEGO® bricks: with hundreds (or even thousands) of pieces, you can assemble your own unique architecture, shaped by your creativity and style.

If a workflow were a script, each atomic action would be like a function from the SDK within that script. In this lab, you'll create a workflow to automate your lab network using the same operations as the Python script from the Meraki Dashboard API Jumpstart Lab.

Script Flowchart

Script Flowchart

  1. Quick overview of the script flow: With a user-provided API key and target organization ID, the script will rename the campus network (box D) and switch device (E), update a switch port setting (F), rename the AP (G) in the same network, and create two SSIDs (H). With the Access Keys, Targets, and global variable configurations from Lab 1, you are ready to continue from step C in the flow chart above.

  2. Navigate to Automation > Workspace, click Create workflow, choose the default Blank Custom Workflow, and then click Continue.

    Create workflow dialog

  3. Name your workflow campus_automation and click Continue.

    Workflow naming

  4. In the Properties panel, expand General and add the following to the Description.

    "This workflow is intended for lab use to automate a Meraki campus network setup, including updating the network name, renaming devices, and configuring a switch port and two SSIDs."

    Information

    It's recommended to provide a detailed description. For instance, include the purpose of the workflow and how it should be used. Include details such as targets used and what steps should be performed. For additional Workflow best practices, please refer to the documentation.

  5. Scroll down the Properties panel, click Variables, then under Local and static variables click + Add variable:

    • Data Type: String
    • Display Name: Target_Network_ID
    • Scope: Local
    • String Type: Text
    • Value: type in None

    Hint

    Initialize Target_Network_ID to None for later comparison in the workflow.

  6. Click Target, configure the Workflow Target as follows:

    • Execute on this target
    • Target Type: Meraki Endpoint
    • Target: Meraki

    Workflow target configuration

  7. In the Activities section on the left-hand side, search for the activity Meraki - Get Organization Networks (Step C), then drag and drop it onto the Workflow Canvas.

    Meraki Get Organization Networks activity

  8. To retrieve organization networks, an organization ID is required, which is why the node on the canvas appears amber, waiting for input. In the Atomic Properties panel, under Input > Input - Organization ID, click the Variable Browser icon icon to launch Variable Browser. Choose Global > LAB_ORG_ID and Save.

    Variable Browser for Organization ID Variable selection

    Variable Browser configuration

    Information

    The Variable Browser lets you explore activity variables, global and environment variables, workflow variables, incident response, and workflow outputs. Learn more about Variable Browser.

  9. Click on the canvas to clear the warning. As a best practice, Validate and Run the workflow to test it before adding more activities.

    Validate and Run

    Successful run

  10. The workflow run should show complete successfully. Click the Meraki -- Get Organization Networks activity and review the Output -- Result, which is an array containing the two networks in your lab organization.

    Get Organization Networks output

  11. Click Modify to continue adding the next activity - find any network whose name contains 'campus' and rename it to Workflows-Campus.

    Modify workflow

    1. In the Activity panel, search Condition Block and drag it onto the canvas dropping it onto the green + just below the Get Organization Networks Atomic.

      Condition Block placement

    2. Rename the activity to Did Get Org Networks succeed?

      Condition Block naming

    3. Rename the first Condition Branch to 200/Success. Delete the second branch, as it won't be need.

      Condition branches

    4. Select the 200/Success branch, under Condition, configure it as follows:

      • Property: Click the Variable Browser icon and select Activities > Meraki -- Get Organization Networks > Output -- Status Code, Save the selection.

      Status Code property

      • Comparison: Equals
      • Value: 200

      Condition configuration

      Information

      When an API request is sent, it's always best practice to verify that the previous call was successful before proceeding with the workflow.

    5. In the left-hand Activity panel, search and drag Read Table from JSON activity to the 200/Success branch (Drag activity here). This activity will convert previous Meraki -- Get Organization Networks atomic output from a JSON string into a table for further processing.

      Read Table from JSON

    6. Under Read Table, configure the Read Table from JSON activity as follows:

      • JSON Path: $.
      • Add two Columns to Read.
      Name Type
      name String
      id String
      • Source JSON: Click the Variable Browser icon and select Activities > Meraki -- Get Organization Networks > Output -- Result

      Read Table from JSON configuration

      Information

      "$." is the JSON Path to select all objects in a JSON data (in our case, the Output -- Result from Meraki -- Get Organization Networks). To learn more, see the document Read Table from JSON/Text/XML.

    7. Click Validate and then Run to quick test the flow. You should see another successful run.

      Successful Read Table run

    8. Click Modify and return to the editing mode. To iterate through all networks in the table, add a For Each activity right after the Read Table from JSON activity.

      For Each activity

    9. Configure the For Each activity as follows:

      • Display Name: Iterate Each Network
      • Source Array: Click the Variable Browser icon and select Activities > Did Get Org Networks succeed? > 200/Success > Read Table from JSON > Output

      For Each configuration

    10. Click Validate, then Run the workflow to quickly test the flow so far.

      Validation success

      Run success

    11. Click the Iterate Each Network activity and examine the two iterations. Each iteration represents an item in the Source Array (in this case, the two networks in the lab organization)

      Iterate Each Network iterations

    12. Return to editing mode, inside the Iterate Each Network loop, drag a Condition Block activity and name it Was Workflow-Campus Found?

      Condition Block in loop

    13. Configure the first condition branch as follows:

      • Display Name: Found
      • Condition > Property: Click the Variable Browser icon and select Activities > Did Get Org Networks succeed? > 200/Success > Iterate Each Network > Source Array > Items > name
      • Condition > Comparison: Equals
      • Condition > Value: type in Workflow-Campus

      Found branch configuration

    14. In the left-hand Activity panel, search and drag a Set Variables activity to the Found branch.

      Set Variables activity

    15. Configure the Set Variables activity as follows:

      • Display Name: Set Campus Network ID
      • Click + Add under Variables to update
      • Variable to update: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID
      • New value: Click the Variable Browser icon and select Activities > Did Get Org Networks succeed? > 200/Success > Iterate Each Network > Source Array > Items > id

      Set Variables configuration

      Information

      Variables enable efficient data management and communication within and between workflows and can be defined as input, output, or local. A single Set Variables activity can set or update more than one variable.

    16. Select the Found branch, click the three dots in the right corner of the card, and then click Duplicate.

      Duplicate branch

    17. Configure the duplicated branch as follows.

      • Display Name: Not found, but another Campus network name
      • Condition > Comparison: Matches regular expression
      • Value: type in (?i)campus

      Regex condition

      Hint

      Using the activity duplicate option can help reduce the repetitive configurations steps.

      AI Assistant Can Help

      Not sure how to write the regular expression? Try using AI Assistant at your fingertips and send the following prompt: Create a regular expression to match any string that contains 'campus' and make it case insensitive.

      AI Assistant prompt

    18. In the Activity panel, search and drag a Meraki - Update Network activity to the Not found, but another Campus network name branch and put it after the Set Campus Network ID activity.

      Note

      In the Activities panel, make sure you select Meraki - Update Network listed under Cisco Meraki > Networks — not a similarly named activity from another category.

      Meraki Update Network activity

    19. Configure the Meraki -- Update Network activity as follows:

      • Input -- Name: type in Workflow-Campus
      • Input -- Network ID to Update: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID

      Update Network configuration

    20. Configure the third branch as follows:

      • Display Name: Not found/Skip
      • Condition > Property: Click the Variable Browser icon and select Activities > Did Get Org Networks succeed? > 200/Success > Iterate Each Network > Source Array > Items > name
      • Condition > Comparison: Matches regular expression
      • Condition > Value: type in (?i)\^(?!.*campus).*

      Not found/Skip configuration

      Hint

      If the full activity name search doesn't work, search again without the "Meraki --"

      Hint

      Lab checkpoint#1: At this stage, your lab workflow should look like the snapshot shown here: Workflow Lab Checkpoint #1

  12. A quick recap of the python script, you are now ready to move to step E, which update the switch device name in the Workflow-Campus network. Add a Condition Block before the flow END.

    Script flowchart step E

    Condition Block before END

    1. Update the Condition Block's Display Name to Was Workflow-Campus Network ID Set?

      Condition Block naming

    2. Delete the second branch.

      Delete branch

    3. Configure the condition branch as follows:

      • Display Name: Yes
      • Condition > Property: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID
      • Condition > Comparison: Not Equals
      • Condition > Value: type in None

      Note

      The value must be entered exactly as "None".

      Yes branch configuration

    4. Add a Meraki - Get Organization Devices atomic activity to the Yes branch and set Organization ID to Global > LAB_ORG_ID.

      Meraki Get Organization Devices

    5. Add a Read Table from JSON activity after the Meraki -- Get Organization Devices activity.

      Read Table from JSON for devices

    6. Configure the Read Table from JSON activity as follows:

      • JSON Path: $.
      • Add the following Columns to Read:
      Name Type
      serial String
      productType String
      networkId String
      • Source JSON: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > Meraki -- Get Organization Devices > Result

      Note

      The columns to read names must be entered the same with those in the table above.

      Read Table configuration

      Columns to read

    7. Add a For Each activity and set the Source Array to Activities > Was Workflow-Campus Network ID Set? > Yes > Read Table from JSON > Output

      For Each devices

      For Each configuration

    8. Within the For Each activity, add a Condition Block and name it Workflow-Campus Network?

      Condition Block Workflow-Campus Network

    9. Configure the first Condition Branch as follows:

      • Display Name: Yes
      • Condition > Property: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > networkId
      • Condition > Comparison: Equals
      • Condition > Value: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID
      • Click + Add condition to create a second condition.
      • Condition > Property: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > productType
      • Condition > Comparison: Equals
      • Condition > Value: type in switch

      Switch condition configuration

      Hint

      When building conditions, you can combine multiple conditions using AND or OR. In this step, ALL of these conditions must be met is selected.

    10. Add a Meraki - Update Device activity to the Yes branch.

      Meraki Update Device

    11. Configure the Meraki - Update Device activity as follows:

      • Input -- Device Serial to Update: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > serial
      • Input -- Name: type in Workflow-Campus-Switch

      Update Device configuration

      Update Device inputs

      Hint

      Since there is only one switch in this network, the workflow keeps things simple by updating the device with a static name. But what if there are multiple switches in the same network? You can append the last 2--3 bytes of each device's MAC address to its name to differentiate them.

    12. In the same branch, add a Meraki - Update Device Switch Port activity.

      Meraki Update Device Switch Port

    13. Configure the Meraki - Update Device Switch Port activity as follows:

      • Input -- Port Id: 2
      • Input - Allowed VLANs: 1-200
      • Input -- Tags: ["wireless", "meetingroom"]
      • Input -- Name: To-AP
      • Input -- Serial: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > serial

      Switch Port configuration Switch Port inputs Switch Port inputs 2

      Switch Port full configuration Switch Port configuration 2

  13. You now are ready to automate the wireless device and configurations.

    Script flowchart wireless

    1. Configure the second Condition Branch as follows:

      • Display Name: No but AP in the Workflow-Campus Network
      • Condition > Property: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > networkId
      • Condition > Comparison: Equals
      • Condition > Value: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID
      • Click + Add condition to create a second condition.
      • Condition > Property: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > productType
      • Condition > Comparison: Equals
      • Condition > Value: type in wireless

      AP condition branch

    2. Drag a new Meraki - Update Device activity into the branch.

      Meraki Update Device for AP

    3. Configure the Meraki - Update Device activity as follows:

      • Input -- Device Serial to Update: Click the Variable Browser icon and select Activities > Was Workflow-Campus Network ID Set? > Yes > For Each > Source Array > Items > serial
      • Input -- Name: type in Workflow-Campus-AP

      Update Device for AP Update Device AP inputs

    4. Add a Meraki - Update Network Wireless SSID activity after the For Each activity.

      Update Network Wireless SSID placement

      Note

      Make sure this activity is out of For Each loop activity. The For Each loop here iterates through all 6 devices in the lab organization, but SSID configurations should be applied at the network level rather than repeated on each device.

    5. Configure Meraki - Update Network Wireless SSID activity as follows:

      • Display Name: Meraki - Update Network Wireless SSID -- Corp
      • Input - Default VLAN ID: 99
      • Input - WPA Encryption Mode: WPA2 only
      • Input -- Enabled: true
      • Input - Network ID: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID
      • Input - SSID Number: 0
      • Input -- Name: type in Workflow-Corp
      • Input - Auth Mode: 8021x-meraki
      • Input - IP Assignment Mode: Bridge mode

      SSID Corp configuration SSID Corp inputs SSID Corp inputs 2 SSID inputsSSID inputs 2 SSID inputs 3SSID inputs 4 SSID inputs 5

      Note

      All the values should be case sensitive.

    6. Add another Meraki - Update Network Wireless SSID.

      Meraki Update Network Wireless SSID Guest

    7. Configure the activity as follows:

      • Display Name: Meraki - Update Network Wireless SSID -- Guest
      • Input -- Enabled: true
      • Input - Network ID: Click the Variable Browser icon and select Workflow > Local > Target_Network_ID
      • Input - SSID Number: 1
      • Input - Encryption Mode: wpa
      • Input -- Name: type in Workflow-Guest
      • Input - Auth Mode: psk
      • Input -- PSK: Global > SSID_PSK

      SSID Guest configurationSSID Guest inputs SSID Guest inputs 2 SSID Guest inputs 3SSID Guest inputs 4SSID Guest inputs 5 SSID Guest inputs 6

      Note

      All the values should be case sensitive. For the Meraki -- Update Network Wireless SSID -- Guest SSID, make sure you set the parameter Input - Encryption Mode instead of Input - WPA Encryption Mode.

      Hint

      Lab checkpoint#2. At this stage, your lab workflow should look like the snapshot shown here: Workflow Lab Checkpoint #2

  14. Ready to test your Lego architect -or explore opportunities to enhance it? Click Validate and then click Run to execute the workflow. Just like in Workflow Lab Checkpoint #3, after a successful run you should see:

    • Success status next to the workflow run
    • All run activities show green headers
    • Two items under Iterate Each Network (representing the two networks in the lab organization)
    • Six items in the For Each loop activity (representing six devices). One should trigger the switch device update branch (YES) and another should trigger the AP branch (No but AP in the Workflow-Campus Network)
    • Updated campus network name, switch and access point device names, switch port (#2) settings, two SSID settings, etc.
    • Finally, confirm and monitor all these changes in Organization > Change Log and Organization > API & Webhooks.

🎉 Congratulations on completing lab 2! 🎉

In this lab, you learned how to automate a Meraki network using the Workflow Editor, assembling atomic actions like LEGO® bricks---without writing code. You practiced leveraging pre-built Meraki atomics, conditions, loops, and variables to control automation logic for tasks such as updating networks and devices, configuring switch ports, and managing wireless SSIDs. Finally, you tested the workflow, verified the changes, and saw how tasks that would normally require custom scripts can instead be accomplished visually and efficiently using Cisco Workflows.