gateway: host: "127.0.0.1" port: 8765agents: personal: instructions: "You are a helpful personal assistant" model: gpt-4o-mini tools: - internet_search - get_current_time reflection: true support: instructions: "You are a customer support agent" model: gpt-4o role: "Customer Support Specialist" goal: "Resolve customer issues quickly and accurately" backstory: "Expert in troubleshooting and customer care" tools: - internet_search tool_choice: auto allow_delegation: falsechannels: telegram: token: ${TELEGRAM_BOT_TOKEN} routes: dm: personal group: support default: personal discord: token: ${DISCORD_BOT_TOKEN} routes: default: personal
channels: telegram: token: ${TELEGRAM_BOT_TOKEN} # Environment variable routes: dm: personal # DMs → personal agent group: support # Groups → support agent default: personal # Fallback agent
Use ${ENV_VAR_NAME} syntax in token fields. The gateway automatically reads from your environment variables.
from praisonai.gateway import WebSocketGateway# Load gateway config, agents, and channels from YAMLgateway = WebSocketGateway.from_config_file("gateway.yaml")import asyncioasyncio.run(gateway.start())
from_config_file() automatically resolves ${ENV_VAR} syntax in your YAML, creates agents with tools, and configures channel bots.
import asynciofrom praisonai.gateway import WebSocketGatewayfrom praisonaiagents import Agentfrom praisonaiagents.gateway import GatewayConfig# Create agentspersonal = Agent(name="personal", instructions="You are a helpful assistant")support = Agent(name="support", instructions="You are a support agent")# Create gatewayconfig = GatewayConfig(host="127.0.0.1", port=8765)gateway = WebSocketGateway(config=config)# Register agents (use overwrite=False to prevent accidental replacement)gateway.register_agent(personal, agent_id="personal")gateway.register_agent(support, agent_id="support", overwrite=False)# Start gatewayasyncio.run(gateway.start())