Skip to main content
Skip table of contents

Send Messages | Send Interactivity Examples

LAST UPDATED: NOV 19, 2024

PRECONDITIONS

  1. A Slack application has been configured to establish a connection with D3 vSOC. See Configuring Slack to Work with D3 SOAR and Configuring D3 SOAR to Work with Slack.

  2. The Slack application has been added to Slack channels. See Application Integration.

  3. Interactivity has been enabled. See Enabling Interactivity.

Send Messages

ALERT

Starting November 2024, D3 recommends using the Send Interactivity command, which automatically manages action_id. This automation addresses known API limitations, identifies finalized user actions, and notifies users on Slack when the D3 playbook task will no longer process subsequent submissions of the same interactive message. The Send Interactivity command eliminates the requirement for clients to understand and manually insert the <<D3_Identifier>> placeholder value for the Message Blocks input parameter, thereby reducing human errors and downstream complications.

Example 1 - Checkbox and Radio Button Submission (Channel)
  1. Set up the Send Messages command to send a message with checkbox and radio button elements. See step 4 of Application Integration for instructions on obtaining Channel IDs and User IDs. For this example, the Channel ID for a channel called demo is used.

Frame 110 (1)-20241116-001802.png

The below Jinja template is used to dynamically select the appropriate JSON block for Slack based on the specified conditions.

CODE
{{ PlaybookData | jsonpath('$.["Multiple Choice JSON"].inputData.Template') 
    or PlaybookData | jsonpath('$.["Approve/Decline JSON"].inputData.Template') 
    or PlaybookData | jsonpath('$.["Text Input Box JSON"].inputData.Template') }}

{#
{% set choice = PlaybookData | jsonpath('$.["Determine Selected Slack Message Type"].outputData.Choice')%}

{% if "Multiple Choice" in choice %}
{{ PlaybookData | jsonpath('$.["Multiple Choice JSON"].inputData')}}
{% elif "Approve/Decline" in choice %}
{{ PlaybookData | jsonpath('$.["Approve/Decline JSON"].inputData')}}
{% elif "Text Input Box" in choice %}
{{ PlaybookData | jsonpath('$.["Text Input Box JSON"].inputData')}}
{% endif %}
#}

For this example, the focus will be on the JSON block for Multiple Choice JSON. The complete code for Multiple Choice JSON is as follows:

JSON
[
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "*Your task response requires you to complete the below form and submit your choices.*"
        }
    },
    {
        "type": "divider"
    },
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Choose one or more actions to submit:"
        }
    },
    {
        "type": "actions",
        "elements": [
            {
                "type": "checkboxes",
                "options": [
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Activity Confirmed*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*Add your detailed description here for this option*"
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Add User to Watchlist*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Block IP Address on Firewall*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Lock The User's Account*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    },
    {
        "type": "divider"
    },
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Pick one action to submit:"
        }
    },
    {
        "type": "actions",
        "elements": [
            {
                "type": "radio_buttons",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Activity Confirmed",
                            "emoji": true
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Add User to Watchlist",
                            "emoji": true
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Block IP Address on Firewall",
                            "emoji": true
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Lock The User's Account",
                            "emoji": true
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    },
    {
        "type": "divider"
    },
    {
        "type": "actions",
        "elements": [
            {
                "type": "button",
                "text": {
                    "type": "plain_text",
                    "text": "Submit Your Response",
                    "emoji": true
                },
                "value": "sample",
                "action_id": "<<D3_IDentifier>>"
            }
        ]
    }
]
  1. Test run the playbook. The Send Messages command will appear in a paused state.

  2. Observe the message in the channel.

    Frame 111 (1)-20241116-001936.png

    Breakdown of the Message

    Frame 112 (2)-20241116-001952.png

    a.

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "*Your task response requires you to complete the below form and submit your choices.*"
        }
    }

    b.

    JSON
    {
        "type": "divider"
    }

    c.

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Choose one or more actions to submit:"
        }
    }

    d.

    JSON
    {
        "type": "actions",
        "elements": [
            {
                "type": "checkboxes",
                "options": [
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Activity Confirmed*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*Add your detailed description here for this option*"
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Add User to Watchlist*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Block IP Address on Firewall*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Lock The User's Account*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    }

    e.

    JSON
    {
        "type": "divider"
    }

    f.

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Pick one action to submit:"
        }
    }

    g.

    JSON
    {
        "type": "actions",
        "elements": [
            {
                "type": "radio_buttons",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Activity Confirmed",
                            "emoji": true
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Add User to Watchlist",
                            "emoji": true
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Block IP Address on Firewall",
                            "emoji": true
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Lock The User's Account",
                            "emoji": true
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    }

    h.

    JSON
    {
        "type": "divider"
    }

    i.

    JSON
    {
        "type": "actions",
        "elements": [
            {
                "type": "button",
                "text": {
                    "type": "plain_text",
                    "text": "Submit Your Response",
                    "emoji": true
                },
                "value": "sample",
                "action_id": "<<D3_IDentifier>>"
            }
        ]
    }
  1. Select checkbox options and one radio button option. For this example, choose the first and forth checkbox options, Activity Confirmed and Lock The User's Account respectively, and the second radio button option, Add User to Watchlist.

    app.slack.com_client_T07UE0K4FM0_C0804E39L7R (5) 1-20241116-002003.png
  2. Click on the Submit Your Response button.

  3. Click on the icon of the Send Messages playbook task.

    Frame 113 (3)-20241116-002022.png
  4. Navigate to the Context Data tab and scroll down to the "state" field. This field contains the submitted responses from the Slack interactive components.

    Frame 114 (2)-20241116-002034.png
  5. Observe the selected options. The Activity Confirmed and Lock The User’s Account checkbox options will be displayed.

    Frame 115 (1)-20241116-002046.png

    The Add User to Watchlist radio option will also be displayed.

    Frame 116 (2)-20241116-002101.png

READER NOTE

The specific action ID value is derived from the <<D3_IDentifier>> placeholder within the block code of the submit button. D3 is phasing out the use of this placeholder to prevent significant downstream complications. D3 recommends using the Send Interactivity command.

Frame 117 (1)-20241116-002117.png

Send Interactivity

Example 1 - Checkbox and Radio Button Submission (Channel ID)
  1. Set up the Send Interactivity command to send a message with checkbox and radio button elements. See step 4 of Application Integration for instructions on obtaining Channel IDs and User IDs. For this example, the Channel ID for a channel named "demo" is used.

Frame 118 (1)-20241116-002143.png

The below Jinja template is used to dynamically select the appropriate JSON block for Slack based on the specified conditions.

CODE
{{ PlaybookData | jsonpath('$.["Multiple Choice JSON"].inputData.Template') 
    or PlaybookData | jsonpath('$.["Approve/Decline JSON"].inputData.Template') 
    or PlaybookData | jsonpath('$.["Text Input Box JSON"].inputData.Template') }}

{#
{% set choice = PlaybookData | jsonpath('$.["Determine Selected Slack Message Type"].outputData.Choice')%}

{% if "Multiple Choice" in choice %}
{{ PlaybookData | jsonpath('$.["Multiple Choice JSON"].inputData')}}
{% elif "Approve/Decline" in choice %}
{{ PlaybookData | jsonpath('$.["Approve/Decline JSON"].inputData')}}
{% elif "Text Input Box" in choice %}
{{ PlaybookData | jsonpath('$.["Text Input Box JSON"].inputData')}}
{% endif %}
#}

For this example, the focus will be on the JSON block within the Multiple Choice JSON formatter. Its content is as follows:

JSON
[
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "*Your task response requires you to complete the below form and submit your choices.*"
        }
    },
    {
        "type": "divider"
    },
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Choose one or more actions to submit:"
        }
    },
    {
        "type": "actions",
        "elements": [
            {
                "type": "checkboxes",
                "options": [
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Activity Confirmed*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*Add your detailed description here for this option*"
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Add User to Watchlist*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Block IP Address on Firewall*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Lock The User's Account*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    },
    {
        "type": "divider"
    },
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Pick one action to submit:"
        }
    },
    {
        "type": "actions",
        "elements": [
            {
                "type": "radio_buttons",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Activity Confirmed",
                            "emoji": true
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Add User to Watchlist",
                            "emoji": true
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Block IP Address on Firewall",
                            "emoji": true
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Lock The User's Account",
                            "emoji": true
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    }
]
  1. Test run the playbook. The Send Messages command will appear in a paused state.

  1. Navigate to the Slack channel.

    Frame 150 (2)-20241119-010139.png
  2. Observe the message in the channel.
    Breakdown of the Message

    Frame 148 (1)-20241119-002916.png

    a.

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "*Your task response requires you to complete the below form and submit your choices.*"
        }
    }

    b.

    JSON
    {
        "type": "divider"
    }

    c.

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Choose one or more actions to submit:"
        }
    }

    d.

    JSON
    {
        "type": "actions",
        "elements": [
            {
                "type": "checkboxes",
                "options": [
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Activity Confirmed*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*Add your detailed description here for this option*"
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Add User to Watchlist*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Block IP Address on Firewall*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "mrkdwn",
                            "text": "*Lock The User's Account*"
                        },
                        "description": {
                            "type": "mrkdwn",
                            "text": "*this is mrkdwn text*"
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    }

    e.

    JSON
    {
        "type": "divider"
    }

    f.

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Pick one action to submit:"
        }
    }

    g.

    JSON
    {
        "type": "actions",
        "elements": [
            {
                "type": "radio_buttons",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Activity Confirmed",
                            "emoji": true
                        },
                        "value": "value-0"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Add User to Watchlist",
                            "emoji": true
                        },
                        "value": "value-1"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Block IP Address on Firewall",
                            "emoji": true
                        },
                        "value": "value-2"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Lock The User's Account",
                            "emoji": true
                        },
                        "value": "value-3"
                    }
                ]
            }
        ]
    }

    h. This section is automatically generated.

  1. Select checkbox options and one radio button option. For this example, choose the second and third checkbox options, Add User to Watchlist and Block IP Address on Firewall respectively, and the forth radio button option, Lock The User’s Account.

    app.slack.com_client_T07UE0K4FM0_C0804E39L7R (20) 1-20241119-000521.png
  2. Click on the Submit Your Response button, then click on the Submit button in the popup.

    app.slack.com_client_T07UE0K4FM0_C0804E39L7R (8) 1 (1)-20241119-003523.png

    A message will be displayed indicating the user who submitted the form, the submission time in UTC, and a notice that no further submissions for this message will be processed by D3's playbook task.

    Frame 119 (1)-20241116-002308.png
  3. Click on the icon of the Send Interactivity playbook task.

    Frame 120 (2)-20241116-002329.png
  4. Navigate to the Context Data tab and scroll down to the "state" field. This field contains the submitted responses from the Slack interactive components.

    Frame 149 (1)-20241119-004959.png
  5. Observe the selected options. The Add User to Watchlist and Block IP Address on Firewall checkbox options will be displayed.

    Frame 122 (2)-20241116-002351.png

    The Lock The User’s Account radio option will also be displayed.

    Frame 123 (1)-20241116-002402.png
Example 2 - Input Box Text Submission (Channel ID)
  1. Set up the Send Interactivity command to send a message with checkbox and radio button elements. See step 4 of Application Integration for instructions on obtaining Channel IDs and User IDs. For this example, the Channel ID for a channel named "demo" is used.

    Frame 110 (1)-20241116-001802.png

    For this example, the focus will be on the JSON block within the Text Input Box JSON formatter. Its content is as follows:

    JSON
    [
        {
            "type": "input",
            "element": {
                "type": "plain_text_input",
                "multiline": true
            },
            "label": {
                "type": "plain_text",
                "text": "Your comment",
                "emoji": true
            }
        }
    ]
  1. Test run the playbook. The Send Interactivity command will appear in a paused state.

  2. Navigate to the Slack channel.

    Frame 150 (2)-20241119-010139.png
  3. Enter a message in the text area.

    Frame 129 (1)-20241116-002557.png
  4. Click on the Submit Your Response button, then click on the Submit button in the popup.

    app.slack.com_client_T07UE0K4FM0_C0804E39L7R (14) 1-20241116-002611.png

    A message will be displayed indicating the user who submitted the form, the submission time in UTC, and a notice that no further submissions for this message will be processed by D3's playbook task.

    Frame 119 (1)-20241116-002308.png
  5. Click on the icon of the Send Interactivity playbook task.

    Frame 130 (1)-20241116-002626.png
  6. Navigate to the Context Data tab and scroll down to the "state" field. This field contains the submitted responses from the Slack interactive components.

    Frame 139 (1)-20241116-002638.png
Example 3 - Date and Time Submission (User ID)
  1. Set up the Send Interactivity command to send a message with checkbox and radio button elements. See step 4 of Application Integration for instructions on obtaining Channel IDs and User IDs. For this example, a User ID is used.

    Frame 135 (1)-20241116-002837.png

    For this example, the focus will be on a single Send Interactivity task. Its content is as follows:

    JSON
    [
        {
            "type": "actions",
            "elements": [
                {
                    "type": "datepicker",
                    "initial_date": "2024-11-15",
                    "placeholder": {
                        "type": "plain_text",
                        "text": "Select a date",
                        "emoji": true
                    }
                },
                {
                    "type": "timepicker",
                    "initial_time": "13:37",
                    "placeholder": {
                        "type": "plain_text",
                        "text": "Select time",
                        "emoji": true
                    }
                }
            ]
        }
    ]
  1. Instruct the user to navigate to the direct Slack message under the Apps accordion.

    Frame 134 (1)-20241116-002904.png
  2. Select a date and time, then click on the Submit your response button.

    Frame 136 (1)-20241116-002920.png

    A message will be displayed indicating the user who submitted the form, the submission time in UTC, and a notice that no further submissions for this message will be processed by D3's playbook task.

  1. Click on the icon of the Send Interactivity playbook task.

    Frame 137 (1)-20241116-002930.png
  2. Navigate to the Context Data tab and scroll down to the "state" field. This field contains the submitted responses from the Slack interactive components.

    Frame 138 (1)-20241116-002945.png
Example 4 - User Selection (User ID)
  1. Set up the Send Interactivity command to send a message with checkbox and radio button elements. See step 4 of Application Integration for instructions on obtaining Channel IDs and User IDs. For this example, a User ID is used.

    Frame 140 (1)-20241116-003049.png

    For this example, the focus will be on a single Send Interactivity task. The input for its Message Blocks parameter is as follows:

    JSON
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Select a user:"
        },
        "accessory": {
            "type": "users_select",
            "placeholder": {
                "type": "plain_text",
                "text": "Select a user",
                "emoji": true
            }
        }
    }
  1. Instruct the user to navigate to the direct Slack message under the Apps accordion.

    Frame 141 (1)-20241116-003107.png
  2. Select a user (Slackbot for this example), then click on the Submit your response button.

    Frame 145 (1)-20241116-003203.png

    A message will be displayed indicating the user who submitted the form, the submission time in UTC, and a notice that no further submissions for this message will be processed by D3's playbook task.

    Frame 151 (1)-20241119-013447.png
  1. Click on the icon of the Send Interactivity playbook task.

    Frame 137 (1)-20241116-002930.png
  2. Navigate to the Context Data tab and scroll down to the "state" field. This field contains the submitted responses from the Slack. The Slackbot user (USLACKBOT) will be recorded.

    Frame 144 (2)-20241116-003231.png
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.