Complete reference for all Foreva AI Python SDK methods and classes.
Main class for creating and managing restaurant AI agents.
# Create agent instance
agent = ForevaAgent(api_key, phone_number)
# Set restaurant information
agent.set_store(
name,
address,
timezone="America/Los_Angeles",
website="https://restaurant.com",
category="Italian Restaurant"
)
# Set business context (helps AI understand your restaurant)
agent.set_context(description_text)
# Set menu
agent.set_menu(menu_object)
# Set operating hours (weekday: 0=Monday, 6=Sunday)
hours = [
{"weekday": 0, "open": "11:00", "close": "22:00"},
{"weekday": 1, "open": "11:00", "close": "22:00"}
]
agent.set_hours(hours)
# Set custom greeting
agent.set_greeting("Welcome to Tony's Pizza! How can I help you?")
# Set escalation events (when to forward calls to staff)
agent.set_escalation_events([EscalationEvents.DELIVERY])
# Set call forwarding number
agent.set_forwarding_number("+14155559876")
# Change the linked phone number (must be unique)
agent.change_phone_number("+14155557777")
# Fetch basic agent info
info = agent.get_info()
print(info)
# Configure notifications
agent.set_notifications(
sms="+14155559876",
email="manager@restaurant.com"
)
# Set webhook URL for order processing
agent.set_webhook_url("https://restaurant.com/api/orders")
# Configure order mode
agent.set_order_mode(OrderMode.DEFAULT)
# Options: OrderMode.DEFAULT, OrderMode.SMS, OrderMode.STAFF
# Activate agent and go live
result = agent.activate()
# Returns routing number and agent details
# Force immediate sync for urgent updates
sync_result = agent.sync()
# Load existing agent
agent = ForevaAgent.load(api_key, phone_number)
# List all your agents
agents = ForevaAgent.list_agents(api_key)
Build restaurant menus with categories, items, and customizations.
# Create menu builder
menu = MenuBuilder()
# Add category
menu.add_category(id, name)
# Add simple item
menu.add_item(
id=101,
name="Garlic Bread",
price=8.99,
category=1,
desc="Optional description"
)
# Add item with customizations
menu.add_item_with_customization(
id, name, price, category_id,
customizations=[customization_list]
)
# Build final menu
final_menu = menu.build()
Create customizable options for menu items (sizes, toppings, etc.).
# Create customization
customization = MenuCustomization("Size")
# Add options (name, price_modifier)
customization.add_option("Small (12\")", 0)
customization.add_option("Large (16\")", 4.00)
# Set if required (customer must choose)
customization.set_required(True)
# Set if multiple selections allowed
customization.set_multiple(True)
# Build customization
final_customization = customization.build()
OrderMode.DEFAULT # AI takes order during the conversation
OrderMode.SMS # AI texts order website URL to callers
# Requires: order_url parameter
OrderMode.STAFF # AI escalates ordering to staff
# Requires: set_forwarding_number()
EscalationEvents.DELIVERY # Forward delivery questions to staff
EscalationEvents.CATERING # Forward catering inquiries
EscalationEvents.RESERVATIONS # Forward reservation requests