• Log inStart now

NerdGraph tutorial: applied intelligence channels

In addition to managing your applied intelligence notification channels in the UI, you can use our NerdGraph API.

Tip

For help getting started with NerdGraph, see Introduction to NerdGraph.

List and filter channels

The channels query allows you to paginate through all of your channels per account. It also allows some filtering functionality.

Create a channel

In order to create a channel, different inputs must be supplied for each channel type. Each channel is connected to a destination. For information on destinations, see the NerdGraph tutorial on destinations.

The best practice is to use the channelSchema endpoint to see which fields must be sent under properties like so:

{
  actor {
    account(id: YOUR_ACCOUNT_ID) {
      aiNotifications {
        channelSchema(
          channelType: CHANNEL_TYPE,
          destinationId: YOUR_DESTINATION_ID,
          product:  YOUR_PRODUCT,
          constraints: []
        ) {
          schema {
              fields {
                mandatory
                label
                key
                component
              }
            }
            result
          }
        }
      }
    }
  }

Update a channel

When you update a channel, note that you don't need to supply all of the attributes on the channel. For example, if you only want to update the name, that's the only attribute you need to update, as shown here:

mutation {
  aiNotificationsUpdateChannel(accountId: YOUR_ACCOUNT_ID, channelId: YOUR_CHANNEL_ID, channel: {
    name: "Updated channel Name"
  }) {
    channel {
      id
      name
    }
  }
}

Testing a channel

You can test channels via the NerdGraph API. This can be done before or after creating the channel.

mutation {
  aiNotificationsTestChannel(accountId: YOUR_ACCOUNT_ID, channel: {
    type: PAGERDUTY_SERVICE_INTEGRATION,
    name: "Channel Name",
    properties: [
      {
        key: "summary",
        value: YOUR_PAGE_SUMMARY
      }
    ]
  }) {
    error {
      details
    }
    details
    result
  }
}
mutation {
  aiNotificationsTestChannelById(accountId: YOUR_ACCOUNT_ID, channelId: YOUR_CHANNEL_ID) {
    error {
      details
    }
    details
    result
  }
}

Delete a channel

You can delete channels via the NerdGraph API.

mutation {
  aiNotificationsDeleteChannel(accountId: YOUR_ACCOUNT_ID, channelId: YOUR_CHANNEL_ID) {
    ids
    error {
      details
    }
  }
}
Copyright © 2022 New Relic Inc.