HiveLang

Conditionals

Control the flow of your bot with if/else statements.

Basic If Statement

Use if to execute code based on a condition.

basic-if.hive
bot Helper {
  on user.message {
    if input contains "help" {
      respond with "I can help you with coding, research, or scheduling."
    }
  }
}

If/Else

Add an else block for alternative behavior.

if-else.hive
bot Greeter {
  on user.message {
    if input contains "morning" {
      respond with "Good morning! How can I help?"
    } else {
      respond with "Hello! What would you like to do?"
    }
  }
}

Multiple Conditions

Combine conditions using or and and operators.

multi-condition.hive
bot Router {
  capabilities {
    email.send
  }

  on user.message {
    if input contains "code" or input contains "program" {
      delegate to CodingAgent with { task: input }
    }

    if input contains "urgent" and input contains "email" {
      call email.send with { to: "team@bothive.cloud", subject: "Urgent" }
    }
  }
}

Comparison Operators

HiveLang supports standard comparison operators:

  • == — Equal to
  • != — Not equal to
  • > — Greater than
  • < — Less than
  • contains — String contains substring

How helpful was this page?

Not helpfulExcellent