curl -X POST https://py.callai.rejoicehub.com/api/agents \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN" \ -d '{ "name": "Customer Support Agent", "initial_message": "Hello! How can I help you today?", "ai_provider": "gemini", "system_prompt": "You are a helpful customer support representative...", "voice_provider": "twilio", "temperature": 0.7, "max_tokens": 1024 }'
from Service.AgentService import AgentServicefrom models.models import AgentConfigservice = AgentService()config = AgentConfig( name="Customer Support Agent", initial_message="Hello! How can I help you today?", ai_provider="gemini", system_prompt="You are a helpful customer support representative...", temperature=0.7, max_tokens=1024)agent = service.create_agent(config)print(f"Agent created: {agent.id}")
The system prompt defines the agent’s personality and behavior:
You are a helpful customer support representative for TechCorp.Your responsibilities:1. Answer customer questions about our products2. Help with troubleshooting issues3. Process refund requests4. Maintain a professional and friendly toneGuidelines:- Always be polite and patient- Ask clarifying questions if needed- Apologize for any inconvenience- Offer solutions or escalate if necessaryAvailable tools:- Look up order history- Process refunds- Schedule callbacks- Create support tickets
1. Caller connects2. Agent plays initial_message3. Agent listens to caller input4. Input processed by AI5. Agent generates response6. Response converted to speech7. Audio played to caller8. Loop until call ends
agent_config = { "knowledge_base_id": "kb-123", "knowledge_base_instructions": """ Use the knowledge base to answer questions about: - Product features - Pricing information - Company policies """,}
CUSTOMER_SUPPORT_PROMPT = """You are a friendly and professional customer support agent.Your goals:1. Help customers with product questions2. Troubleshoot technical issues3. Process orders and refunds4. Escalate complex issues to a human agentAlways:- Be empathetic and understanding- Listen carefully to customer concerns- Provide clear solutions- Ask permission before actions"""
TECHNICAL_SUPPORT_PROMPT = """You are a knowledgeable technical support specialist.Your approach:1. Understand the technical problem2. Ask diagnostic questions3. Provide step-by-step solutions4. Verify the issue is resolvedRemember:- Be patient with non-technical users- Avoid jargon when possible- Escalate if beyond your scope- Document the issue"""
# Test agent responsefrom Service.AgentService import AgentServiceservice = AgentService()agent = service.get_agent("agent-id")response = agent.process_message( "What are your business hours?")print(response)
# Make a test call to the agentcurl -X POST https://py.callai.rejoicehub.com/api/calls \ -H "Content-Type: application/json" \ -d '{ "agent_id": "agent-id", "to_phone": "+1234567890", "from_phone": "+0987654321", "test_mode": true }'