Real-World Implementation Examples 🔗

Let's move from theory to practice. Here are real examples of what you can build with the SignalWire AI Agents SDK, complete with code that you can run today.

Customer Service Agent with CRM Integration 🔗

This agent handles customer inquiries, integrates with your CRM, and seamlessly escalates to human agents when needed:

from signalwire_agents import AgentBase
from signalwire_agents.core.data_map import DataMap

class CustomerServiceAgent(AgentBase):
    def __init__(self):
        super().__init__(name="Customer Service")

        # Set professional voice and personality
        self.add_language("English", "en-US", "rime.amy")

        self.prompt_add_section(
            "Role",
            "You are Sarah, a helpful customer service representative. "
            "Be professional, empathetic, and solution-oriented."
        )

        # Add CRM lookup capability
        crm_tool = (DataMap('lookup_customer')
            .parameter('email', 'string', 'Customer email', required=True)
            .webhook('GET', 'https://api.crm.com/v1/customers?email=${args.email}')
            .header('Authorization', 'Bearer ${env.CRM_API_KEY}')
            .output(SwaigFunctionResult('''
                Found customer: ${response.name}
                Status: ${response.status}
                Last order: ${response.last_order_date}
            '''))
        )
        self.add_datamap_tool(crm_tool)

        # Add knowledge base search
        self.add_skill("native_vector_search", {
            "index_file": "support_docs.swsearch",
            "tool_name": "search_help_docs"
        })

        # Add transfer capability
        self.add_skill("swml_transfer", {
            "transfers": {
                "/billing|payment|invoice/i": {
                    "url": "https://api.company.com/billing-agent",
                    "message": "I'll transfer you to our billing specialist."
                },
                "/technical|broken|not working/i": {
                    "url": "https://api.company.com/tech-support",
                    "message": "Let me connect you with technical support."
                }
            }
        })

Multi-Agent Triage System 🔗

A sophisticated system where specialized agents work together:

from signalwire_agents import AgentBase, AgentServer

class TriageAgent(AgentBase):
    def __init__(self):
        super().__init__(name="Triage Agent")

        self.prompt_add_section(
            "Primary Goal",
            "Quickly understand the caller's needs and route them to the right specialist.",
            bullets=[
                "Greet warmly and ask how you can help",
                "Listen for keywords indicating sales or support needs",
                "Collect their name before transferring"
            ]
        )

        # Dynamic configuration for smart routing
        self.set_dynamic_config_callback(self.configure_routing)

    def configure_routing(self, query_params, body_params, headers, agent):
        base_url = agent.get_full_url(include_auth=True).rstrip('/')

        agent.add_skill("swml_transfer", {
            "required_fields": {
                "customer_name": "The customer's name",
                "need_summary": "Brief summary of what they need"
            },
            "transfers": {
                "/buy|purchase|pricing|cost/i": {
                    "url": f"{base_url}/sales",
                    "message": "I'll connect you with our sales team."
                },
                "/help|support|problem|issue/i": {
                    "url": f"{base_url}/support",
                    "message": "Let me transfer you to technical support."
                }
            }
        })

class SalesAgent(AgentBase):
    def __init__(self):
        super().__init__(name="Sales Specialist")

        # Enthusiastic, helpful personality
        self.add_language("English", "en-US", "rime.hudson")

        self.set_dynamic_config_callback(self.check_transfer_context)

    def check_transfer_context(self, query_params, body_params, headers, agent):
        if query_params.get('transfer') == 'true':
            # This is a transfer - we have context
            agent.prompt_add_section(
                "Transfer Context",
                "The customer was transferred to you from triage.",
                bullets=[
                    "Their name is: ${call_data.customer_name}",
                    "They need: ${call_data.need_summary}",
                    "Acknowledge the transfer naturally"
                ]
            )

# Deploy the multi-agent system
server = AgentServer(port=3000)
server.register(TriageAgent(), "/")
server.register(SalesAgent(), "/sales")
server.register(SupportAgent(), "/support")
server.run()

Healthcare Appointment Assistant 🔗

An agent that handles appointment scheduling with HIPAA compliance considerations:

class HealthcareAgent(AgentBase):
    def __init__(self):
        super().__init__(name="Healthcare Assistant")

        # Professional, calming voice
        self.add_language("English", "en-US", "rime.kai")

        # HIPAA-conscious prompting
        self.prompt_add_section(
            "Privacy Notice",
            "Always protect patient privacy. Never repeat full SSN or sensitive medical details.",
            bullets=[
                "Verify identity with last 4 of SSN only",
                "Use general terms for medical conditions",
                "Confirm permissions before discussing with third parties"
            ]
        )

        # Add appointment scheduling
        appointment_tool = (DataMap('schedule_appointment')
            .parameter('patient_id', 'string', 'Patient ID', required=True)
            .parameter('date', 'string', 'Requested date', required=True)
            .parameter('reason', 'string', 'Visit reason', required=True)
            .webhook('POST', 'https://api.emr.com/appointments')
            .body({
                'patient_id': '${args.patient_id}',
                'requested_date': '${args.date}',
                'visit_type': '${args.reason}',
                'duration_minutes': 30
            })
            .output(SwaigFunctionResult(
                'Appointment scheduled for ${response.confirmed_date} at ${response.time}'
            ))
        )
        self.add_datamap_tool(appointment_tool)

        # Add medication lookup (read-only)
        self.add_skill("datasphere", {
            "document_id": "medication_database",
            "tool_name": "lookup_medication_info"
        })

Financial Services Bot 🔗

A compliant financial services assistant:

class FinancialAdvisorBot(AgentBase):
    def __init__(self):
        super().__init__(name="Financial Assistant")

        # Compliance-first prompting
        self.prompt_add_section(
            "Compliance Requirements",
            "You are a financial information assistant, NOT an advisor.",
            bullets=[
                "Never provide specific investment advice",
                "Always include appropriate disclaimers",
                "Direct complex questions to licensed advisors",
                "Verify identity before discussing account details"
            ]
        )

        # Add secure account lookup
        @AgentBase.tool(
            name="check_balance",
            auth_token="secure_fin_token"  # Extra security
        )
        def check_balance(self, args, raw_data):
            # Verify caller identity first
            if not self.verify_caller_identity(args):
                return SwaigFunctionResult(
                    "I need to verify your identity first. "
                    "Please provide the last 4 digits of your account number."
                )

            # Simulate secure balance check
            return SwaigFunctionResult(
                "Your current balance is $12,345.67. "
                "Would you like to hear recent transactions?"
            )

These examples demonstrate real patterns used in production deployments. Each can be extended, customized, and deployed immediately using the SignalWire platform.