← Back to API Dashboard

🐍 Python SDK

Enterprise-grade Voice, SMS, Email & AI API for Python applications

🚧 Coming Soon - Use REST API for now

📦 Installation

The Python SDK will be available via pip when released:

# Coming soon!
pip install team-connect

# For now, use requests library
pip install requests

🚀 Quick Start

Here's how you'll use the Python SDK once it's available:

# Future SDK usage
from teamconnect import TeamConnectAPI

# Initialize with your API key
api = TeamConnectAPI('tc_live_your_api_key_here')

# Make a voice call
result = api.voice.make_call(
    to='+447123456789',
    message='Hello from Team Connect!'
)

print(f"Call initiated: {result['call_id']}")

# Send an SMS
sms_result = api.sms.send(
    to='+447123456789',
    message='Your verification code is 123456'
)

print(f"SMS sent: {sms_result['message_id']}")

# Send an email
email_result = api.email.send(
    to='customer@example.com',
    subject='Welcome to our service',
    html='

Welcome!

Thanks for signing up.

' ) print(f"Email sent: {email_result['message_id']}")

🔐 Current Implementation (REST API)

Until the SDK is ready, use our REST API with the requests library:

import requests
import json

class TeamConnectAPI:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = 'https://us-central1-customerservice-2156c.cloudfunctions.net'
    
    def _make_request(self, service, action, data):
        """Make API request to Team Connect"""
        url = f'{self.base_url}/executeAPI'
        
        payload = {
            'service': service,
            'action': action,
            'data': data,
            'api_key': self.api_key
        }
        
        headers = {
            'Content-Type': 'application/json'
        }
        
        response = requests.post(url, json=payload, headers=headers)
        
        if response.status_code == 402:
            raise Exception('Insufficient credits. Please top up your account.')
        elif response.status_code == 401:
            raise Exception('Invalid API key.')
        elif response.status_code != 200:
            raise Exception(f'API request failed: {response.text}')
        
        return response.json()

# Initialize the API
api = TeamConnectAPI('tc_live_your_api_key_here')

📞 Voice Calls

Make AI-powered voice calls to any phone number:

# Make a voice call
def make_call(api, to_number, message, from_number=None, voice=None):
    """
    Make an AI voice call
    
    Args:
        to_number (str): Phone number to call (E.164 format)
        message (str): AI instructions/message for the call
        from_number (str, optional): Your phone number
        voice (str, optional): Voice ID to use
    
    Returns:
        dict: Call result with call_id and status
    """
    try:
        result = api._make_request('voice', 'make_call', {
            'to': to_number,
            'message': message,
            'from': from_number,
            'voice': voice,
            'webhook_url': 'https://yourapp.com/webhooks/call-status'  # Optional
        })
        
        return result
        
    except Exception as e:
        print(f"Call failed: {e}")
        return None

# Example usage
call_result = make_call(
    api=api,
    to_number='+447123456789',
    message='Hi, this is Sarah from Dad-Link calling to confirm your appointment tomorrow at 2 PM. Can you please confirm if this time still works for you?',
    voice='Polly.Amy'  # British English voice
)

if call_result and call_result['success']:
    print(f"✅ Call initiated successfully!")
    print(f"Call ID: {call_result['result']['call_id']}")
    print(f"Status: {call_result['result']['status']}")
    print(f"Cost: {call_result['billing']['costFormatted']}")
    
    if 'warning' in call_result:
        print(f"⚠️ {call_result['warning']}")
else:
    print("❌ Call failed")

📋 Appointment Confirmation

make_call(
    api=api,
    to_number='+447123456789',
    message='Hi, this is confirming your dentist appointment tomorrow at 2pm. Reply YES to confirm or NO to reschedule.'
)

🔔 Payment Reminder

make_call(
    api=api,
    to_number='+447123456789',
    message='Hello, this is a friendly reminder that your payment is due. You can pay online or call us back.'
)

💬 SMS Messages

Send SMS messages to any mobile number:

# Send SMS
def send_sms(api, to_number, message, from_number=None):
    """
    Send an SMS message
    
    Args:
        to_number (str): Mobile number to send to
        message (str): SMS content (max 160 chars for single SMS)
        from_number (str, optional): Your SMS number
    
    Returns:
        dict: SMS result with message_id and status
    """
    try:
        result = api._make_request('sms', 'send', {
            'to': to_number,
            'message': message,
            'from': from_number
        })
        
        return result
        
    except Exception as e:
        print(f"SMS failed: {e}")
        return None

# Example usage
sms_result = send_sms(
    api=api,
    to_number='+447123456789',
    message='Your verification code is 123456. Valid for 5 minutes.'
)

if sms_result and sms_result['success']:
    print(f"✅ SMS sent successfully!")
    print(f"Message ID: {sms_result['result']['message_id']}")
    print(f"Cost: {sms_result['billing']['costFormatted']}")
else:
    print("❌ SMS failed")

🔐 2FA Verification

import random

code = random.randint(100000, 999999)
send_sms(
    api=api,
    to_number=user_phone,
    message=f'Your verification code: {code}'
)

🚚 Delivery Update

send_sms(
    api=api,
    to_number=customer_phone,
    message='Your order #12345 is out for delivery. Track: https://track.me/12345'
)

📧 Email Sending

Send HTML emails with high deliverability:

# Send Email
def send_email(api, to_email, subject, html_content, from_name=None):
    """
    Send an HTML email
    
    Args:
        to_email (str): Recipient email address
        subject (str): Email subject line
        html_content (str): HTML email content
        from_name (str, optional): Sender name
    
    Returns:
        dict: Email result with message_id and status
    """
    try:
        result = api._make_request('email', 'send', {
            'to': to_email,
            'subject': subject,
            'html': html_content,
            'from_name': from_name or 'Team Connect'
        })
        
        return result
        
    except Exception as e:
        print(f"Email failed: {e}")
        return None

# Example usage
html_template = """



    


    

Welcome to Dad-Link!

Thanks for signing up

We're excited to have you on board. Your account is now active and ready to use.

Get started by exploring our features:

  • AI Voice Calls
  • SMS Messaging
  • Email Campaigns
""" email_result = send_email( api=api, to_email='customer@example.com', subject='Welcome to Dad-Link - Your Account is Ready!', html_content=html_template, from_name='Dad-Link Team' ) if email_result and email_result['success']: print(f"✅ Email sent successfully!") print(f"Message ID: {email_result['result']['message_id']}") print(f"Cost: {email_result['billing']['costFormatted']}") else: print("❌ Email failed")

🤖 AI Chat

Use GPT-4 for intelligent conversations:

# AI Chat
def ai_chat(api, messages, model='gpt-4'):
    """
    Chat with AI
    
    Args:
        messages (list): Array of message objects
        model (str): AI model to use ('gpt-4', 'gpt-3.5-turbo')
    
    Returns:
        dict: AI response with content and token usage
    """
    try:
        result = api._make_request('ai', 'chat', {
            'messages': messages,
            'model': model
        })
        
        return result
        
    except Exception as e:
        print(f"AI chat failed: {e}")
        return None

# Example usage
conversation = [
    {
        "role": "system",
        "content": "You are a helpful customer service assistant for Dad-Link, a communication platform."
    },
    {
        "role": "user",
        "content": "How do I set up voice calls in my application?"
    }
]

ai_result = ai_chat(api=api, messages=conversation)

if ai_result and ai_result['success']:
    print(f"✅ AI Response:")
    print(f"{ai_result['result']['response']}")
    print(f"Tokens used: {ai_result['result']['tokens_used']}")
    print(f"Cost: {ai_result['billing']['costFormatted']}")
else:
    print("❌ AI chat failed")

⚠️ Error Handling

Robust error handling for production applications:

import time
from typing import Optional, Dict, Any

class TeamConnectError(Exception):
    """Base exception for Team Connect API errors"""
    pass

class InsufficientCreditsError(TeamConnectError):
    """Raised when account has insufficient credits"""
    pass

class InvalidAPIKeyError(TeamConnectError):
    """Raised when API key is invalid or revoked"""
    pass

class RateLimitError(TeamConnectError):
    """Raised when rate limit is exceeded"""
    pass

class TeamConnectAPIEnhanced:
    def __init__(self, api_key: str, timeout: int = 30, max_retries: int = 3):
        self.api_key = api_key
        self.base_url = 'https://us-central1-customerservice-2156c.cloudfunctions.net'
        self.timeout = timeout
        self.max_retries = max_retries
    
    def _make_request_with_retry(self, service: str, action: str, data: Dict[str, Any]) -> Dict[str, Any]:
        """Make API request with retry logic"""
        
        for attempt in range(self.max_retries + 1):
            try:
                response = requests.post(
                    f'{self.base_url}/executeAPI',
                    json={
                        'service': service,
                        'action': action,
                        'data': data,
                        'api_key': self.api_key
                    },
                    headers={'Content-Type': 'application/json'},
                    timeout=self.timeout
                )
                
                # Handle different error cases
                if response.status_code == 401:
                    raise InvalidAPIKeyError('Invalid or revoked API key')
                elif response.status_code == 402:
                    error_data = response.json()
                    raise InsufficientCreditsError(
                        f"Insufficient credits: {error_data.get('error', 'Please top up your account')}"
                    )
                elif response.status_code == 429:
                    if attempt < self.max_retries:
                        wait_time = (2 ** attempt) + random.uniform(0, 1)
                        print(f"Rate limited, retrying in {wait_time:.1f}s...")
                        time.sleep(wait_time)
                        continue
                    else:
                        raise RateLimitError('Rate limit exceeded')
                elif response.status_code == 500:
                    if attempt < self.max_retries:
                        wait_time = (2 ** attempt)
                        print(f"Server error, retrying in {wait_time}s...")
                        time.sleep(wait_time)
                        continue
                    else:
                        raise TeamConnectError('Internal server error')
                elif response.status_code != 200:
                    error_data = response.json()
                    raise TeamConnectError(f"API error: {error_data.get('error', 'Unknown error')}")
                
                return response.json()
                
            except requests.exceptions.Timeout:
                if attempt < self.max_retries:
                    print(f"Request timeout, retrying... (attempt {attempt + 1})")
                    continue
                else:
                    raise TeamConnectError('Request timeout after retries')
            except requests.exceptions.ConnectionError:
                if attempt < self.max_retries:
                    print(f"Connection error, retrying... (attempt {attempt + 1})")
                    time.sleep(2 ** attempt)
                    continue
                else:
                    raise TeamConnectError('Connection error after retries')
    
    def make_call_safe(self, to_number: str, message: str, **kwargs) -> Optional[Dict[str, Any]]:
        """Make a voice call with comprehensive error handling"""
        try:
            return self._make_request_with_retry('voice', 'make_call', {
                'to': to_number,
                'message': message,
                **kwargs
            })
        except InsufficientCreditsError as e:
            print(f"💰 Credit Error: {e}")
            print("💡 Top up at: https://team-connect.co.uk/api-dashboard.html#topup")
            return None
        except InvalidAPIKeyError as e:
            print(f"🔐 Auth Error: {e}")
            print("💡 Check your API key in the dashboard")
            return None
        except RateLimitError as e:
            print(f"⏱️ Rate Limit: {e}")
            print("💡 Slow down your requests or upgrade your plan")
            return None
        except TeamConnectError as e:
            print(f"❌ API Error: {e}")
            return None

# Usage example with error handling
api_enhanced = TeamConnectAPIEnhanced('tc_live_your_api_key_here')

result = api_enhanced.make_call_safe(
    to_number='+447123456789',
    message='Hello, this is a test call with error handling.'
)

if result:
    print("✅ Call successful!")
    print(f"Call ID: {result['result']['call_id']}")
else:
    print("❌ Call failed - check error messages above")

💰 Pricing

Transparent, pay-per-use pricing with no monthly fees:

Service Price Unit Example
📞 Voice Calls 7p per minute 2 min call = 14p
💬 SMS Messages 3p per message 1 SMS = 3p
📧 Email Sending 0.15p per email 1 email = 0.15p
🤖 AI Processing 15p per request 1 AI chat = 15p

💡 Cost Example

Typical monthly usage for a small business:

  • 100 voice calls (2 min avg) = £14.00
  • 500 SMS messages = £15.00
  • 1,000 emails = £1.50
  • 50 AI requests = £7.50
  • Total: £38.00/month

💳 Top up credits: Visit your API Dashboard to add credits. Minimum top-up: £5.00

Need help? Contact us at support@team-connect.co.uk

← Back to API Dashboard | REST API Docs | JavaScript SDK

© 2025 Dad-Link. All rights reserved. | Last updated: August 5, 2025 15:00 UTC