📀Configuration

Learn about custom bots configuration structure

Configuration structure

Every custom bot configuration consists of:

  • Declaration at the top saying what type of event should trigger the bot ("trigger")

  • Preconditions block that states what conditions must be met by the event before it's forwarded to the condition blocks. It also gives special meaning to some of the conditions used here.

  • At least one condition block ("if") followed by the actions block ("then") that states what actions should be executed when the given condition is met

Example bot that sends a message to some Discord channel whenever HellCats NFT is sold:

trigger: "sale"

preconditions:
    marketplace.chain == "Polygon"
    and collection.address == "0x09421f533497331e1075fdca2a16e9ce3f52312b"

if:
    true
then:
    discord.send({
        webhook: "<Discord Webhook integration ID>",
        template: "<Discord Embed message template ID>"
    })

Trigger

Declares on what type of event your bot should trigger. The following values are available:

  • listing

  • sale

Preconditions block

Here you can declare what conditions should be met by the event before it's forwarded to condition blocks. Some conditions that you put here have some special meaning:

  • "collection.address" - once your bot is started our monitors will start tracking this collection(s) on every marketplace we support.

  • "collection.name" - if your collection is a custom OpenSea collection, you'll need to enter its slug here so our monitor can start tracking it.

So by the rule of thumb:

When monitoring listings/sales of a single or more collections you should always put those conditions in a preconditions block to be sure that they are monitored.

Because of that you cannot use "not", "or", "!=" and "not in" keywords here as well as constants.

Condition and action blocks

Every condition/action block has the following structure:

if:
    <some_condition>
then:
    <some_action>

Optional configuration options

You can use some optional constructs to make you bot more powerful:

  • Constants

  • Extensions

Constants

You can define constants in your bot that can be set to a fixed or dynamic (based on conditions) values:

trigger: "listing"

def max_usd_price = 300
def is_red = switch {
    case nft.traits["Color"] == "Red" => 1
    default                           => 0
}

preconditions:
    marketplace.chain == "Polygon"

if:
    is_red == 1
    and listing.price_usd <= max_usd_price
then:
    discord.send({
        webhook: "<Discord Webhook integration ID>",
        template: "<Discord Embed message template ID>"
    })

What's more, you can use this constants in your message templates too! Let's take a following constant for example:

def price_icon = switch {
    case listing.price > $1000 => "💎💎💎"
    case listing.price >  $500 => "💎💎"
    case listing.price >  $100 => "💎"
    default                    => ""
}

Depending on the price of listed NFT its value will be one of the icons above, and you may embed those icons in your template just by using the "{price_icon}" placeholder!

Extensions

Suppose that the "is_red" constant from the config above is defined not directly in the bot config, but in some extension. You may use this constant in your bot like this:

trigger: "listing"

use { is_red } from "<Your Extension ID>"

def max_usd_price = 300

if:
    is_red == 1
    and listing.price_usd <= max_usd_price
then:
    discord.send({
        webhook: "<Discord Webhook integration ID>",
        template: "<Discord Embed message template ID>"
    })

You can learn more about extensions here:

Last updated