Example: Using condition filtering with a Slack Request node
Discovery connector request nodes provide a condition filtering capability, which you can use during retrieve or update actions. This topic provides a worked example of how to use condition filtering with a Slack Request node.
Before you begin
You must install IBM® App Connect Enterprise 12.0.11.0 or later to use condition filtering.
Video: Using the new Slack Request node in IBM App Connect Enterprise.
About this task
IBM App Connect Enterprise communicates synchronously with Slack through the Slack Request node, which is available on Windows, AIX, and Linux® systems.
You can use the Slack Request node to connect to Slack and perform actions on objects in the Slack system.
The additional configuration that is required for condition filtering is described in step 6.
For more information about configuring the Slack Request node, see Slack Request node.
Procedure
- In the IBM App Connect
Enterprise Toolkit, create a message flow that contains a
Slack Request node. For example, the following message flow
contains an HTTPInput node, a Slack Request node, and an HTTPReply node.
- Select the Slack Request node in the flow to show the node properties in the editor.
- On the Basic tab, click Launch Connector
Discovery. A panel is displayed in which you specify the name of the policy project and vault details to be used during connector discovery.
- Specify the details of the policy project and vault to be
used during connector discovery:
- In the Policy Project field, specify the policy project that is
used to store the policies that are created during connector discovery. Alternatively, you can create a new policy project by clicking New and then specifying the name of the new policy project. Then click Finish.
- Specify the vault to be used during connector discovery. By default, credentials that
are used during connector discovery are stored in an external directory vault, which is
an App Connect Enterprise vault that can be used by any integration server.
Alternatively, you can store the credentials in an integration server vault, which is created in the
integration server's work directory and can be used only by that specific integration server. To specify the vault to be used for storing the credentials, complete the steps in the Using the Connector Discovery wizard section of one of the following topics:
- In the Vault key field, enter the vault key that is used to access the credentials stored in the vault. The vault key must be at least 8 characters in length.
- Optional: By default, the specified vault location and vault key are saved as preferences in the Toolkit so that the values are preset when you launch Connector Discovery. If you do not want the preferences to be saved, deselect Save in vault preferences.
- In the Policy Project field, specify the policy project that is
used to store the policies that are created during connector discovery.
- Click Launch Connector Discovery to start the Connector Discovery
wizard for the Slack connector. The Connector Discovery window is displayed. If existing Slack connections (accounts) are available, a list of those connections is displayed. If there are no existing connections, the status of the Slack connector is shown as
Not connected
.- If one or more Slack connections (accounts) are
available, complete the following steps:
- Select the connection (account) that you want to use by clicking on it.
- Click the required object type and then select the action that you want to perform on the object. For example, click Channels and then Retrieve channels.
- If there are no existing connections (accounts), complete the following steps:
- Click the required object type and then select the action that you want to perform on that object. For example, to retrieve messages from Slack, click Channels and then Retrieve channels .
- Click Connect.
A window is displayed in which you enter the basic access token to be used to authenticate IBM App Connect Enterprise with your Slack account. If you do not have an access token, you can find information about how to obtain one in How to use IBM App Connect with Slack in the IBM App Connect Enterprise as a Service documentation.
- Click Connect.
The credential is then stored in the vault, and the other connection details are saved in the Slack policy.
- If one or more Slack connections (accounts) are
available, complete the following steps:
- In the wizard, set the required connector properties and any
optional connector properties that you want to use during connector discovery:
- Set the required connector properties in the wizard.
- Optional: You can add conditions for the retrieval of the data, by clicking Add condition and then selecting the property that you want to filter on. For example, to retrieve channels with a specified name, select Channel name from the drop-down menu.
- Optional: If you added conditions in step 6.b for
Retrieve or Update actions, you can optionally use Condition Filtering by completing the following
steps:
- Exit the Connector Discovery wizard by clicking the X in the upper-right corner of the window.
- In the Properties view of the input node for your message flow, select the Basic tab. In the Path suffix for URL field, enter a value for the path suffix, for example /slack. (In this worked example, the input node is an HTTPInput node.)
- In the Properties view of the input node for your message flow, select the Input message parsing tab. In the Message domain field, select JSON : For JavaScript Object Notation messages from the drop-down menu.
- Create a blank JSON schema as described in Creating a JSON schema file. Populate the JSON file with entries that relate to the action that you are performing
in Connector Discovery. For example, slack.schema.json:
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "ChannelName": { "type": "string" }, "filterByChannelName": { "type": "boolean" } }, "required": [ "ChannelName", "filterByChannelName" ] }
For more information about creating JSON schemas, see json-schema.org.
- In the Properties view of the Slack Request node, select the Request tab. Click Add to open the Add Map inputs entry wizard.
- Complete the following fields:
- Input name: Choose a unique name for the Map Inputs table, for example HTTP_Input.
- Input location: Click Browse and select $InputRoot/JSON/Data from the XPath Expression Builder.
- Schema location: Click Browse to open the JSON Schema Selection wizard, select the schema that you created in step 6.c.iv and click OK.
- Schema root: The location in the schema file that describes the message structure. This value is only required if the JSON schema is not at the root of the schema document.
- Click OK to save the entries.
- Click Launch Connector Discovery to start the Connector Discovery wizard for the Slack connector.
- If you have not clicked Add condition, click it now and then select the property that you want to filter on. The option Enable condition filtering becomes visible in the Map options menu.
- In the Connector Discovery wizard, click Map options menu and select Enable condition filtering.The text "Filter mode" is displayed next to the Map options menu control.
- Place the cursor in the input field, delete any existing text, and click Insert a
mapping to open the Available mappings table.
The mappings in the Available mappings table are derived from the JSON schema that you created in step 6.c.iv and referenced from the Slack Request node in step 6.c.vi.
- In the Available mappings table, click Map inputs / HTTP_Input
/ Object /ChannelName
The text SampleChannelName is displayed under the input field. (This is the data that is associated with the mapping ChannelName and it is derived from the JSON schema that you created in step 6.c.iv.) The only if: field is displayed. The drop-down menu has the options True, False, and Custom.
- From the drop-down menu in the only if: field, select Custom.
- Delete any text from the only if: field and click Insert a mapping.
- In the Available mappings wizard, click Map inputs /
HTTP_Input / Object /filterByChannelName .
The text True is displayed under the only if: field. (This is the data that is associated with the mapping filterByChannelName and it is derived from the JSON schema that you created in step 6.c.iv.)
Optionally, you can populate the fields manually by typing in the required values. For example, you can type the value mychannel in ChannelName.
Optionally, you can edit the data that is associated with a mapping by completing the following steps:- Place the cursor in the input field, delete any existing text, and click Insert a mapping to open the Available mappings table
- Select a mapping from the Available mappings table, for example Map inputs / HTTP_Input / Object /ChannelName.
- In the "Retrieve channels" section, click the pencil icon to view available mappings and edit your sample data. The table "Map inputs and sample data" is displayed.
- In the table, select the mapping ChannelName and change the data SampleChannelName to mychannel. The text "mychannel" will be displayed after the field that you selected.
- Close the Map inputs and sample data table by clicking the X in the upper-right corner of the table.
- You can also set properties that specify the maximum number of records to retrieve and the action to be taken if that limit is exceeded.
- When you have finished specifying the properties in the Connector Discovery wizard, click
Save. The values of the properties that you set in the wizard are returned to the Slack Request node in the IBM App Connect Enterprise Toolkit.
- When you have finished discovery and saved the property values, exit the Connector Discovery wizard by clicking the X in the upper-right corner of the window.
- Return to editing the Slack Request node in the IBM App Connect
Enterprise Toolkit. The connector properties that were set in the Connector Discovery wizard (in step 6 ) are now visible on the Slack Request node. The Basic tab shows the values of the Action and Object properties that you set in the wizard. For example, if you selected Channel > Retrieve channels in the wizard, the following properties will be visible on the Basic tab of the node:
- Action -
RETRIEVEALL
- Object -
channel
The values of the Action and Object properties are displayed in read-only format. If you want to change these values, you can do so by clicking Launch Connector Discovery again and setting new values in the Connector Discovery wizard. You can modify other properties by clicking Edit next to the property.
The Schema base name property specifies the base name of the schema files that describe the format of the request and response messages that are sent and received from the Slack connector. The schema base name is set automatically the first time that you run discovery for the node, and it is based on the current flow name and node name. If you set this property manually before running discovery for the first time, the value that you set will be used. If you rename the schemas after discovery, you must edit this property so that it matches the schema base name that is used by the renamed schemas in the project. If you change this property after discovery, you must either rename the schema names to match or run discovery again.
Depending on the action that was selected during discovery, the Connector Discovery wizard generates either a request schema and a response schema, or a response schema only. A request schema is generated only if the selected action and object require a request message. The generated request schema is used for validation of the request message. If the action was
RETRIEVE
orDELETE
, only the response schema is returned by the connector.The generated schema files are added to the project and can be used by a Mapping node for transforming input or output data. The full filename of the schema is derived from the schema base name, suffixed with either response.schema.json or request.schema.json. You can open the schema by clicking Open request schema or Open response schema.
- Action -
- Check that the property settings on the Slack Request node are correct and then save the message flow.
- On the Connection tab of the Slack Request node, the Policy property
shows the name of the policy that contains the details of the security identity to be used for the
connection. The policy has a type of
Slack
. - Optional: Set the Timeout property on the Connection tab to specify the time (in seconds) that the node waits for Slack to process the operation.
- The Filter tab of the Slack Request node contains properties that control the way in
which the message flow selects data. The initial values of these properties are taken from the
property values that were set for the Slack connector in
the Connector Discovery wizard, including the filter options properties and any conditions that were
specified (as described in step 6 ). If you subsequently return to the Connector Discovery wizard and change the values of any
properties (by adding new conditions, for example) those updates are reflected in the properties set
on the node.
The Filter Options properties control which objects are to be operated upon when the Slack Request node executes. The Filter Limit properties control the maximum number of items to be retrieved and the action to be taken if the limit is exceeded.
You can modify the values by clicking Edit next to the value that you want to modify in the Filter Options section, and by changing the property values that have been set in the Filter Limit section.
The property values can be either text values or ESQL or XPATH expressions that are resolved from the contents of the message that is passed to the Slack Request node as it executes.
- On the Request tab, set the Data location property to specify the location in the incoming message tree that contains the object data to be created in Slack. This data forms the request that is sent from the Slack Request node to the Slack system.
- On the Result tab, set the Output data location property to specify the location in the output message tree that will contain the data of the record that is created in Slack.
- By default, request messages are validated against the request schema that was generated during connector discovery. You can turn off request validation or change the validation settings by using the Validation properties of the Slack Request node.
- Save the message flow.