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 input
    if input contains "help"
      say "I can help you with coding, research, or scheduling."
    end
  end
end

If/Else

Add an else block for alternative behavior.

if-else.hive
bot "Greeter"
  on input
    if input contains "morning"
      say "Good morning! How can I help?"
    else
      say "Hello! What would you like to do?"
    end
  end
end

Multiple Conditions

Combine conditions using or and and operators.

multi-condition.hive
bot "Router"
  on input
    if input contains "code" or input contains "program"
      delegate to CodingAgent
    end
    
    if input contains "urgent" and input contains "email"
      call messaging.email.send(to: "team@bothive.cloud", subject: "Urgent")
    end
  end
end

Comparison Operators

HiveLang supports standard comparison operators:

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

Was this page helpful?

Confused? Ask HiveMind.

Our autonomous AI assistant can explain any concept, write code snippets, or guide you through the SDK.