Enabling Notifications

You can enable notifications when you create new API versions, to notify the existing subscribers (via email) that a new version of the API is available. If you want to send a different type of notification, you can extend the org.wso2.carbon.apimgt.impl.notification.Notifier abstract class based on your requirements.

Follow the instructions below to enable notifications for new API versions:

  1. Add the email server configurations to the <API-M_HOME>/repository/conf/deployment.toml file as follows:

    [apim.notification]
    from_address = "[email protected]"
    username = "[email protected]"
    password = "xxxxxx"
    signature = "do not reply"
    hostname = "smtp.gmail.com"
    port = "587"
    enable_start_tls = true
    enable_authentication = true
    Property Description
    from_address The email address you use to send emails.
    username The email address used to authenticate the mail server. This can be the same email address as the from_address.
    password Password used to authenticate the mail server.
    signature Signature of the sender account.

    For more information, see Enable Notifications.

  2. Sign in to the Management Console.

    https://<hostname>:9443/carbon

    Example: https://localhost:9443/carbon

  3. Click Main > Resource > Browse.

    Browser option

  4. Enter /_system/config/apimgt/applicationdata/tenant-conf.json, click Go, and click Edit as Text.

  5. Set the NotificationsEnabled property to true as shown below:

    "NotificationsEnabled":"true",
      "Notifications":[{
        "Type":"new_api_version",
        "Notifiers" :[{
          "Class":"org.wso2.carbon.apimgt.impl.notification.NewAPIVersionEmailNotifier",
          "ClaimsRetrieverImplClass":"org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever",
          "Title": "Version $2 of $1 Released",
          "Template": " <html> <body> <h3 style=\"color:Black;\">We’re happy to announce the arrival of the next major version $2 of $1 API which is now available in Our Developer Portal.</h3><a href=\"https://localhost:9443/devportal\">Click here to Visit WSO2 API Developer Portal</a></body></html>" 
        }]
      }]

    A notification type can have multiple notifier classes that help send multiple notifications. In this case, the notifications are sent via e-mail but it could be a SMS notification. Each notifier has a class attribute containing the full class path. The following properties should be set for the default NewAPIVersionEmailNotifier class:

    Property Description
    Class The full class path of the notifier class.
    ClaimsRetrieverImplClass

    Subscriber email addresses are extracted from user claims. The default pack uses the org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever class to read the claim values from the user store.

    Claims

    A claim is a piece of information about a particular subject. It can be anything that the subject is owned by or associated with, such as name, group, preferences, etc. For information on how to add new claim mappings, see Configuring Claims.

    Title The subject of the email.
    Template The template of the email body. This can be string values or a valid registry path to a template file.

    The following strings are replaced with API specific values in the Title and Template properties.

    $1 - API name

    $2 - New API version

    Note

    If you create the subscriber via the Management Console, you need to add the subscriber's email in the subscriber user profile. You can find the user profile when you list the users in the management console.

    Note

    If you are using a Google mail account, note that Google has restricted third-party apps and apps with lower security levels from sending emails by default. Therefore, you need to configure your account to disable this restriction. For more information on Setting up Gmail, see Creating Users using the Ask Password Option.

Top