Hi ${customerName},
Thanks for signing up! Your account is now active and ready to use.
Get started by exploring our features:
- π€ AI Voice Calls
- π¬ SMS Messaging
- π§ Email Campaigns
Enterprise-grade Voice, SMS, Email & AI API for JavaScript & Node.js applications
The JavaScript SDK will be available via npm when released:
# Coming soon!
npm install @team-connect/api
# Or with yarn
yarn add @team-connect/api
# For now, use fetch or axios
npm install axios
Here's how you'll use the JavaScript SDK once it's available:
// Future SDK usage
import TeamConnect from '@team-connect/api';
// Initialize with your API key
const api = new TeamConnect('tc_live_your_api_key_here');
// Make a voice call
const callResult = await api.voice.makeCall({
to: '+447123456789',
message: 'Hello from Team Connect!'
});
console.log('Call initiated:', callResult.callId);
// Send an SMS
const smsResult = await api.sms.send({
to: '+447123456789',
message: 'Your verification code is 123456'
});
console.log('SMS sent:', smsResult.messageId);
// Send an email
const emailResult = await api.email.send({
to: 'customer@example.com',
subject: 'Welcome to our service',
html: 'Welcome!
Thanks for signing up.
'
});
console.log('Email sent:', emailResult.messageId);
// AI Chat
const aiResult = await api.ai.chat([
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' }
]);
console.log('AI Response:', aiResult.response);
Until the SDK is ready, use our REST API with fetch or axios:
// Vanilla JavaScript with fetch
class TeamConnectAPI {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://us-central1-customerservice-2156c.cloudfunctions.net';
}
async makeRequest(service, action, data) {
const response = await fetch(`${this.baseUrl}/executeAPI`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
service,
action,
data,
api_key: this.apiKey
})
});
if (response.status === 402) {
throw new Error('Insufficient credits. Please top up your account.');
} else if (response.status === 401) {
throw new Error('Invalid API key.');
} else if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || 'API request failed');
}
return response.json();
}
}
// Initialize the API
const api = new TeamConnectAPI('tc_live_your_api_key_here');
// Using Axios (npm install axios)
import axios from 'axios';
class TeamConnectAPI {
constructor(apiKey) {
this.apiKey = apiKey;
this.client = axios.create({
baseURL: 'https://us-central1-customerservice-2156c.cloudfunctions.net',
timeout: 30000,
headers: {
'Content-Type': 'application/json'
}
});
// Add response interceptor for error handling
this.client.interceptors.response.use(
response => response,
error => {
if (error.response?.status === 402) {
throw new Error('Insufficient credits. Please top up your account.');
} else if (error.response?.status === 401) {
throw new Error('Invalid API key.');
}
throw error;
}
);
}
async makeRequest(service, action, data) {
const response = await this.client.post('/executeAPI', {
service,
action,
data,
api_key: this.apiKey
});
return response.data;
}
}
// Initialize the API
const api = new TeamConnectAPI('tc_live_your_api_key_here');
// Node.js with built-in fetch (Node 18+) or install node-fetch
const fetch = require('node-fetch'); // Only needed for Node < 18
class TeamConnectAPI {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://us-central1-customerservice-2156c.cloudfunctions.net';
}
async makeRequest(service, action, data) {
try {
const response = await fetch(`${this.baseUrl}/executeAPI`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
service,
action,
data,
api_key: this.apiKey
})
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || `HTTP ${response.status}`);
}
return await response.json();
} catch (error) {
console.error('Team Connect API Error:', error.message);
throw error;
}
}
}
// Initialize the API
const api = new TeamConnectAPI(process.env.TEAM_CONNECT_API_KEY);
module.exports = TeamConnectAPI;
Make AI-powered voice calls to any phone number:
// Make a voice call
async function makeCall(to, message, options = {}) {
try {
const result = await api.makeRequest('voice', 'make_call', {
to,
message,
from: options.from,
voice: options.voice,
webhook_url: options.webhookUrl
});
if (result.success) {
return {
callId: result.result.call_id,
status: result.result.status,
to: result.result.to,
from: result.result.from,
cost: result.billing?.cost,
creditsRemaining: result.billing?.creditsRemaining
};
}
throw new Error(result.error || 'Call failed');
} catch (error) {
console.error('Voice call error:', error.message);
throw error;
}
}
// Example usage
const callResult = await makeCall(
'+447123456789',
'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',
webhookUrl: 'https://yourapp.com/webhooks/call-status'
}
);
console.log('β
Call initiated successfully!');
console.log(`Call ID: ${callResult.callId}`);
console.log(`Status: ${callResult.status}`);
console.log(`Cost: ${callResult.cost}p`);
if (callResult.creditsRemaining < 500) {
console.warn('β οΈ Low credits remaining:', callResult.creditsRemaining);
}
// Confirm appointment
await makeCall(
customer.phone,
`Hi ${customer.name}, this is confirming your ${appointment.service} appointment tomorrow at ${appointment.time}. Reply YES to confirm or NO to reschedule.`
);
// Payment reminder
await makeCall(
customer.phone,
`Hello ${customer.name}, this is a friendly reminder that your payment of Β£${invoice.amount} is due. You can pay online at ${paymentUrl} or call us back.`
);
Send SMS messages to any mobile number:
// Send SMS
async function sendSMS(to, message, options = {}) {
try {
const result = await api.makeRequest('sms', 'send', {
to,
message,
from: options.from
});
if (result.success) {
return {
messageId: result.result.message_id,
status: result.result.status,
to: result.result.to,
from: result.result.from,
cost: result.billing?.cost,
creditsRemaining: result.billing?.creditsRemaining
};
}
throw new Error(result.error || 'SMS failed');
} catch (error) {
console.error('SMS error:', error.message);
throw error;
}
}
// Example usage
const smsResult = await sendSMS(
'+447123456789',
'Your verification code is 123456. Valid for 5 minutes.'
);
console.log('β
SMS sent successfully!');
console.log(`Message ID: ${smsResult.messageId}`);
console.log(`Status: ${smsResult.status}`);
console.log(`Cost: ${smsResult.cost}p`);
// Generate and send 2FA code
const code = Math.floor(100000 + Math.random() * 900000);
await sendSMS(
user.phone,
`Your ${appName} verification code: ${code}`
);
// Store code in database with expiry
await saveVerificationCode(user.id, code, 5); // 5 minutes
// Order status update
await sendSMS(
order.customer.phone,
`Your order #${order.number} is ${order.status}. Track: ${order.trackingUrl}`
);
Send HTML emails with high deliverability:
// Send Email
async function sendEmail(to, subject, html, options = {}) {
try {
const result = await api.makeRequest('email', 'send', {
to,
subject,
html,
from_name: options.fromName || 'Team Connect'
});
if (result.success) {
return {
messageId: result.result.message_id,
status: result.result.status,
to: result.result.to,
subject: result.result.subject,
cost: result.billing?.cost,
creditsRemaining: result.billing?.creditsRemaining
};
}
throw new Error(result.error || 'Email failed');
} catch (error) {
console.error('Email error:', error.message);
throw error;
}
}
// HTML email template
const welcomeEmailTemplate = (customerName, dashboardUrl) => `
Welcome to Dad-Link!
Hi ${customerName},
Thanks for signing up! Your account is now active and ready to use.
Get started by exploring our features:
- π€ AI Voice Calls
- π¬ SMS Messaging
- π§ Email Campaigns
Get Started
`;
// Example usage
const emailResult = await sendEmail(
'customer@example.com',
'Welcome to Dad-Link - Your Account is Ready!',
welcomeEmailTemplate('John Doe', 'https://team-connect.co.uk/dashboard.html'),
{ fromName: 'Dad-Link Team' }
);
console.log('β
Email sent successfully!');
console.log(`Message ID: ${emailResult.messageId}`);
console.log(`Cost: ${emailResult.cost}p`);
Use GPT-4 for intelligent conversations:
// AI Chat
async function aiChat(messages, options = {}) {
try {
const result = await api.makeRequest('ai', 'chat', {
messages,
model: options.model || 'gpt-4'
});
if (result.success) {
return {
response: result.result.response,
model: result.result.model,
tokensUsed: result.result.tokens_used,
cost: result.billing?.cost,
creditsRemaining: result.billing?.creditsRemaining
};
}
throw new Error(result.error || 'AI chat failed');
} catch (error) {
console.error('AI chat error:', error.message);
throw error;
}
}
// Example usage
const conversation = [
{
role: 'system',
content: 'You are a helpful customer service assistant for Dad-Link, a communication platform.'
},
{
role: 'user',
content: 'How do I integrate voice calls into my JavaScript application?'
}
];
const aiResult = await aiChat(conversation);
console.log('β
AI Response:');
console.log(aiResult.response);
console.log(`Tokens used: ${aiResult.tokensUsed}`);
console.log(`Cost: ${aiResult.cost}p`);
// Simple chat interface
class ChatInterface {
constructor(apiKey) {
this.api = new TeamConnectAPI(apiKey);
this.messages = [
{
role: 'system',
content: 'You are a helpful assistant for Dad-Link customers.'
}
];
}
async sendMessage(userMessage) {
// Add user message to conversation
this.messages.push({
role: 'user',
content: userMessage
});
// Get AI response
const result = await aiChat(this.messages);
// Add AI response to conversation
this.messages.push({
role: 'assistant',
content: result.response
});
return result.response;
}
}
// Usage
const chat = new ChatInterface('tc_live_your_api_key_here');
const response = await chat.sendMessage('Hello, how can you help me?');
Ready-to-use examples for popular JavaScript frameworks:
// React Hook for Team Connect API
import { useState, useCallback } from 'react';
const useTeamConnect = (apiKey) => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const api = new TeamConnectAPI(apiKey);
const makeCall = useCallback(async (to, message, options) => {
setLoading(true);
setError(null);
try {
const result = await api.makeRequest('voice', 'make_call', {
to, message, ...options
});
return result;
} catch (err) {
setError(err.message);
throw err;
} finally {
setLoading(false);
}
}, [api]);
const sendSMS = useCallback(async (to, message, options) => {
setLoading(true);
setError(null);
try {
const result = await api.makeRequest('sms', 'send', {
to, message, ...options
});
return result;
} catch (err) {
setError(err.message);
throw err;
} finally {
setLoading(false);
}
}, [api]);
return { makeCall, sendSMS, loading, error };
};
// React Component
const CommunicationPanel = () => {
const { makeCall, sendSMS, loading, error } = useTeamConnect(
process.env.REACT_APP_TEAM_CONNECT_API_KEY
);
const handleCall = async () => {
try {
const result = await makeCall(
'+447123456789',
'Hello from React app!'
);
console.log('Call result:', result);
} catch (error) {
console.error('Call failed:', error);
}
};
return (
{error && Error: {error}
}
);
};
// Vue.js Composition API
import { ref, reactive } from 'vue';
export default {
setup() {
const api = new TeamConnectAPI(process.env.VUE_APP_TEAM_CONNECT_API_KEY);
const loading = ref(false);
const error = ref(null);
const makeCall = async (to, message, options = {}) => {
loading.value = true;
error.value = null;
try {
const result = await api.makeRequest('voice', 'make_call', {
to, message, ...options
});
return result;
} catch (err) {
error.value = err.message;
throw err;
} finally {
loading.value = false;
}
};
const sendSMS = async (to, message, options = {}) => {
loading.value = true;
error.value = null;
try {
const result = await api.makeRequest('sms', 'send', {
to, message, ...options
});
return result;
} catch (err) {
error.value = err.message;
throw err;
} finally {
loading.value = false;
}
};
return {
makeCall,
sendSMS,
loading,
error
};
},
template: `
Error: {{ error }}
`,
methods: {
async handleCall() {
try {
const result = await this.makeCall(
'+447123456789',
'Hello from Vue app!'
);
console.log('Call result:', result);
} catch (error) {
console.error('Call failed:', error);
}
}
}
};
// Next.js API Route: /pages/api/team-connect.js
import TeamConnectAPI from '@/lib/team-connect';
const api = new TeamConnectAPI(process.env.TEAM_CONNECT_API_KEY);
export default async function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}
const { service, action, data } = req.body;
try {
const result = await api.makeRequest(service, action, data);
res.status(200).json(result);
} catch (error) {
console.error('Team Connect API error:', error);
res.status(500).json({ error: error.message });
}
}
// Next.js Component: /components/CommunicationForm.js
import { useState } from 'react';
export default function CommunicationForm() {
const [loading, setLoading] = useState(false);
const [result, setResult] = useState(null);
const handleSubmit = async (e) => {
e.preventDefault();
setLoading(true);
try {
const response = await fetch('/api/team-connect', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
service: 'voice',
action: 'make_call',
data: {
to: '+447123456789',
message: 'Hello from Next.js!'
}
})
});
const data = await response.json();
setResult(data);
} catch (error) {
console.error('Error:', error);
} finally {
setLoading(false);
}
};
return (
);
}
// Express.js Server
const express = require('express');
const TeamConnectAPI = require('./lib/team-connect');
const app = express();
const api = new TeamConnectAPI(process.env.TEAM_CONNECT_API_KEY);
app.use(express.json());
// Voice call endpoint
app.post('/api/call', async (req, res) => {
try {
const { to, message, voice } = req.body;
const result = await api.makeRequest('voice', 'make_call', {
to,
message,
voice
});
res.json(result);
} catch (error) {
console.error('Call error:', error);
res.status(500).json({ error: error.message });
}
});
// SMS endpoint
app.post('/api/sms', async (req, res) => {
try {
const { to, message } = req.body;
const result = await api.makeRequest('sms', 'send', {
to,
message
});
res.json(result);
} catch (error) {
console.error('SMS error:', error);
res.status(500).json({ error: error.message });
}
});
// Email endpoint
app.post('/api/email', async (req, res) => {
try {
const { to, subject, html } = req.body;
const result = await api.makeRequest('email', 'send', {
to,
subject,
html
});
res.json(result);
} catch (error) {
console.error('Email error:', error);
res.status(500).json({ error: error.message });
}
});
// Webhook handler
app.post('/webhooks/team-connect', (req, res) => {
const { event, data } = req.body;
console.log('Webhook received:', event, data);
// Process webhook based on event type
switch (event) {
case 'call.completed':
console.log('Call completed:', data.call_id);
break;
case 'sms.delivered':
console.log('SMS delivered:', data.message_id);
break;
case 'email.delivered':
console.log('Email delivered:', data.message_id);
break;
}
res.status(200).json({ received: true });
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Robust error handling for production JavaScript applications:
// Enhanced error handling with retries
class TeamConnectAPIEnhanced {
constructor(apiKey, options = {}) {
this.apiKey = apiKey;
this.baseUrl = 'https://us-central1-customerservice-2156c.cloudfunctions.net';
this.timeout = options.timeout || 30000;
this.maxRetries = options.maxRetries || 3;
}
async makeRequestWithRetry(service, action, data) {
let lastError;
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
try {
return await this.makeRequest(service, action, data);
} catch (error) {
lastError = error;
// Don't retry on these errors
if (error.message.includes('Invalid API key') ||
error.message.includes('Insufficient credits')) {
throw error;
}
// Don't retry on last attempt
if (attempt === this.maxRetries) {
throw error;
}
// Exponential backoff
const waitTime = Math.pow(2, attempt) * 1000 + Math.random() * 1000;
console.warn(`Request failed, retrying in ${waitTime}ms... (attempt ${attempt + 1})`);
await new Promise(resolve => setTimeout(resolve, waitTime));
}
}
throw lastError;
}
async makeRequest(service, action, data) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
try {
const response = await fetch(`${this.baseUrl}/executeAPI`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
service,
action,
data,
api_key: this.apiKey
}),
signal: controller.signal
});
clearTimeout(timeoutId);
if (response.status === 401) {
throw new APIError('Invalid API key', 'INVALID_API_KEY', 401);
} else if (response.status === 402) {
const errorData = await response.json();
throw new APIError(errorData.error || 'Insufficient credits', 'INSUFFICIENT_CREDITS', 402);
} else if (response.status === 429) {
throw new APIError('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429);
} else if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new APIError(errorData.error || `HTTP ${response.status}`, 'HTTP_ERROR', response.status);
}
return await response.json();
} catch (error) {
clearTimeout(timeoutId);
if (error.name === 'AbortError') {
throw new APIError('Request timeout', 'TIMEOUT', 408);
}
if (error instanceof APIError) {
throw error;
}
throw new APIError(`Network error: ${error.message}`, 'NETWORK_ERROR', 0);
}
}
// Safe methods that handle errors gracefully
async makeCallSafe(to, message, options = {}) {
try {
const result = await this.makeRequestWithRetry('voice', 'make_call', {
to, message, ...options
});
return { success: true, data: result.result };
} catch (error) {
console.error('Voice call failed:', error.message);
return { success: false, error: error.message, code: error.code };
}
}
async sendSMSSafe(to, message, options = {}) {
try {
const result = await this.makeRequestWithRetry('sms', 'send', {
to, message, ...options
});
return { success: true, data: result.result };
} catch (error) {
console.error('SMS failed:', error.message);
return { success: false, error: error.message, code: error.code };
}
}
}
// Custom error class
class APIError extends Error {
constructor(message, code, status) {
super(message);
this.name = 'APIError';
this.code = code;
this.status = status;
}
}
// Usage with comprehensive error handling
const enhancedApi = new TeamConnectAPIEnhanced('tc_live_your_api_key_here', {
timeout: 30000,
maxRetries: 3
});
// Safe method calls
const callResult = await enhancedApi.makeCallSafe(
'+447123456789',
'Hello, this is a test call with error handling.'
);
if (callResult.success) {
console.log('β
Call successful:', callResult.data.call_id);
} else {
console.log('β Call failed:', callResult.error);
// Handle specific error codes
switch (callResult.code) {
case 'INSUFFICIENT_CREDITS':
console.log('π° Please top up your account');
break;
case 'INVALID_API_KEY':
console.log('π Please check your API key');
break;
case 'RATE_LIMIT_EXCEEDED':
console.log('β±οΈ Please slow down your requests');
break;
case 'TIMEOUT':
console.log('β° Request timed out, try again');
break;
default:
console.log('β Unknown error occurred');
}
}
Simple, transparent pricing with no monthly fees. Perfect for JavaScript applications:
Service | Price | Unit | JavaScript Example |
---|---|---|---|
π Voice Calls | 7p | per minute | api.makeRequest('voice', 'make_call', data) |
π¬ SMS Messages | 3p | per message | api.makeRequest('sms', 'send', data) |
π§ Email Sending | 0.15p | per email | api.makeRequest('email', 'send', data) |
π€ AI Processing | 15p | per request | api.makeRequest('ai', 'chat', data) |
React/Vue SaaS with 5,000 users:
π³ Manage Credits: Visit your API Dashboard to top up credits and view usage analytics.
Need help? Contact us at support@team-connect.co.uk
β Back to API Dashboard | REST API Docs | Python SDK
Β© 2025 Dad-Link. All rights reserved. | Last updated: 2025-08-05 15:10:08 UTC