Generating driven pages

Z ChatOps server can generate a driven URL by the sitemap configuration and the normalized field in the configuration file, and then notify the client to switch page to the new URL that is found by the sitemap configuration.

About this task

In Z ChatOps, sitemap is a mapping relationship between keywords of Z ChatOps and page URLs of the integrating web app.

Procedure

  1. Prepare the sitemap configuration.
    Edit the sitemap.yaml file in the directory that you created in 5 in the following format:
    # Licensed material - Property of IBM
    # © Copyright IBM Corporation 2023.
    # This file controls one sitemap of the chat window server for IBM Z ChatOps
    
    # Configure the urlSet
    urlSet:
      - url:
          loc: https://your_host_name/lparDetail?lparName=${zos.lparName}
          keywords:
            - lpar/status/detail
          description: lpar detail page
    Fields of URLs:
    loc
    Specifies the target URL. You can use ${VALUE} to provide parameters for the URL.
    keywords
    A string array to provide keywords.
    description
    The description of current URL item.
    You can find the normalized fields in the $ZCHATOPS_HOME/config/webChat/normalized-field.yaml file.
  2. Add an event listener for the chat window dom. For example,
    chatwindow.addEventListener('webChatNotification', (data: any) => {
                        const eventData = data.detail;
                        if (eventData.type === 'page-switch') {
                            navigate(eventData.payload.path);
                        }
                    });
    The event type is 'webChatNotification'

    The parameter of the callback is a CustomEvent. For more information about CustomEvent, see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.

    If the data.detail.type === "page-switch", you can get the new URL with data.detail.payload.path. Then you can use navigate or use location.href = ‘new url’ to lunch new page.

    navigate is a function that can switch page of your integrating web app.