SMS Channels Guide
Set up AI-powered text messaging on your phone number
Setup Time: ~5 minutes (including phone purchase)
Overview
SMS channels enable AI agents to handle text messages. They are automatically created when you purchase a phone number.
Prerequisites
Before setting up SMS channels:
- ✅ Active WIIL Platform account
- ✅ Sufficient account credits
- ✅ Project ID
- ✅ Agent Configuration ID
- ✅ Instruction Configuration ID
Quick Start
Step 0: Find Available Phone Numbers
Before purchasing, search for available phone numbers.
import { WiilClient } from 'wiil-js';
const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! });
// Search for phone numbers
const numbers = await client.telephonyProvider.getPhoneNumbers();
console.log(`Found ${numbers.length} available numbers`);
// Search with filters
const filteredNumbers = await client.telephonyProvider.getPhoneNumbers({
areaCode: '212'
});
// Get pricing
const pricing = await client.telephonyProvider.getPricing();
console.log('Pricing:', pricing);
📖 See Full Guide: Phone Purchase Guide for complete details on searching and purchasing phone numbers.
Step 1: Purchase Phone Number
SMS channels are created automatically when you purchase a phone number.
import { WiilClient } from 'wiil-js';
const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! });
const phonePurchase = await client.telephonyProvider.purchase({
phoneNumber: '+12125551234',
friendlyName: 'Customer Support SMS' // Optional
});
console.log(`Purchase ID: ${phonePurchase.id}`);
console.log('Processing... (under 5 minutes)');
Step 2: Get SMS Channel ID
After purchase completes, retrieve the phone configuration to get the smsChannelId.
// Wait for purchase to complete (under 5 minutes)
await new Promise(resolve => setTimeout(resolve, 300000));
const phoneConfig = await client.phoneConfigs.getByPhoneNumber('+12125551234');
console.log('Phone Configuration:');
console.log(` Voice Channel ID: ${phoneConfig.voiceChannelId}`);
console.log(` SMS Channel ID: ${phoneConfig.smsChannelId}`);
console.log(` Status: ${phoneConfig.status}`);
Output:
Phone Configuration:
Voice Channel ID: 2s3t4u5v6w7x8y9z0a1b
SMS Channel ID: 3t4u5v6w7x8y9z0a1b2c
Status: ACTIVE
Important: Save the smsChannelId - you'll need it to create the deployment.
Step 3: Create SMS Deployment
import { DeploymentStatus, DeploymentProvisioningType } from 'wiil-core-js';
const deployment = await client.deploymentConfigs.create({
projectId: 'YOUR_PROJECT_ID',
deploymentChannelId: phoneConfig.smsChannelId, // ← Use SMS channel ID
agentConfigurationId: 'YOUR_AGENT_ID',
instructionConfigurationId: 'YOUR_INSTRUCTION_ID',
deploymentName: 'SMS Support Agent',
isActive: true,
deploymentStatus: DeploymentStatus.PENDING,
provisioningType: DeploymentProvisioningType.DIRECT
});
console.log('✓ SMS deployment created!');
console.log(`Deployment ID: ${deployment.id}`);
console.log(`Text ${phoneConfig.phoneNumber} to test`);
Step 4: Test Your SMS Agent
Send a text message to test your AI agent:
📱 Text to: +12125551234
Message: "Hello! I need help with my order."
Your AI agent will respond via SMS!
Retrieving SMS Channel Details
Get Channel by ID
const smsChannel = await client.deploymentChannels.get(phoneConfig.smsChannelId);
console.log('SMS Channel Details:');
console.log(` Name: ${smsChannel.channelName}`);
console.log(` Type: ${smsChannel.deploymentType}`); // "SMS"
console.log(` Phone: ${smsChannel.channelIdentifier}`);
console.log(` Recording: ${smsChannel.recordingEnabled}`);
Get Channel by Phone Number
import { DeploymentType } from 'wiil-core-js';
const smsChannel = await client.deploymentChannels.getByIdentifier(
'+12125551234',
DeploymentType.SMS
);
console.log(`SMS Channel ID: ${smsChannel.id}`);
Complete Example
import { WiilClient } from 'wiil-js';
import { DeploymentStatus, DeploymentProvisioningType } from 'wiil-core-js';
async function setupSMSChannel() {
const client = new WiilClient({ apiKey: process.env.WIIL_API_KEY! });
// 1. Purchase phone number
console.log('1. Purchasing phone number...');
const purchase = await client.telephonyProvider.purchase({
phoneNumber: '+12125551234',
friendlyName: 'Customer Support SMS'
});
console.log(`Purchase ID: ${purchase.id}`);
// 2. Wait for completion
console.log('2. Waiting for purchase to complete (under 5 minutes)...');
let phoneConfig;
let attempts = 0;
const maxAttempts = 60;
while (attempts < maxAttempts) {
try {
phoneConfig = await client.phoneConfigs.getByPhoneNumber('+12125551234');
if (phoneConfig.status === 'ACTIVE') {
console.log('✓ Phone purchase completed!');
break;
}
} catch (error) {
// Phone config not ready yet
}
await new Promise(resolve => setTimeout(resolve, 5000));
attempts++;
}
if (!phoneConfig || phoneConfig.status !== 'ACTIVE') {
throw new Error('Phone purchase timeout');
}
// 3. Get SMS channel ID
console.log('3. SMS channel auto-created:');
console.log(` SMS Channel ID: ${phoneConfig.smsChannelId}`);
// 4. Create deployment
console.log('4. Creating SMS deployment...');
const deployment = await client.deploymentConfigs.create({
projectId: 'YOUR_PROJECT_ID',
deploymentChannelId: phoneConfig.smsChannelId,
agentConfigurationId: 'YOUR_AGENT_ID',
instructionConfigurationId: 'YOUR_INSTRUCTION_ID',
deploymentName: 'SMS Support Agent',
isActive: true,
deploymentStatus: DeploymentStatus.PENDING,
provisioningType: DeploymentProvisioningType.DIRECT
});
console.log('✓ Setup complete!');
console.log(`\nYour SMS agent is ready!`);
console.log(`📱 Text: ${phoneConfig.phoneNumber}`);
console.log(`📋 Deployment ID: ${deployment.id}`);
return { phoneConfig, deployment };
}
setupSMSChannel().catch(console.error);
Message Length Handling
Standard SMS (160 characters)
Single SMS message supports up to 160 characters.
Long Messages (Concatenated SMS)
Messages longer than 160 characters are automatically split and reassembled:
- Split into segments of 153 characters
- Delivered as single message to recipient
- Charged per segment
Example:
- 200 characters = 2 segments = 2 SMS charges
- 320 characters = 3 segments = 3 SMS charges
Agent Configuration for SMS
Optimize your agent for concise SMS responses:
const agentConfig = await client.agentConfigs.create({
agentName: 'Jordan',
temperature: 0.7,
maxTokens: 150, // Keep responses under 160 characters
// Configure agent to be concise
});
Best Practice: Configure instructions to keep responses under 160 characters for cost optimization.
Multi-Language SMS Support
Configure your agent to support multiple languages:
// In your Agent Configuration
const agentConfig = await client.agentConfigs.create({
agentName: 'Luna',
language: 'en-US', // Default language
// Agent will auto-detect and respond in sender's language
});
Supported Languages:
- English (US, UK)
- Spanish (ES, MX)
- French (FR, CA)
- German (DE)
- Italian (IT)
- Portuguese (BR, PT)
- And more...
Note: Character encoding may affect message length for non-English languages.
Compliance and Regulations
US Regulations
10DLC Registration Required:
- Local numbers (non-toll-free) require 10DLC registration
- Registration is automatic for verified businesses
- Unregistered numbers have lower throughput
A2P Trust Score:
- Affects message delivery rates
- Based on: business verification, message content, user engagement
- Higher scores = better deliverability
TCPA Compliance
Ensure compliance with Telephone Consumer Protection Act:
- ✅ Obtain explicit opt-in consent
- ✅ Provide clear opt-out instructions
- ✅ Honor opt-out requests immediately
- ✅ Keep consent records
Opt-Out Example:
"Reply STOP to unsubscribe"
GDPR Compliance (EU)
For European customers:
- ✅ Obtain clear consent
- ✅ Provide data access rights
- ✅ Allow data deletion
- ✅ Secure data storage
Toll-Free SMS
Use toll-free numbers for verified business messaging.
Purchase Toll-Free Number
const phonePurchase = await client.telephonyProvider.purchase({
phoneNumber: '+18005551234',
friendlyName: 'Business SMS Line'
});
Benefits:
- Higher throughput (3 msg/sec vs 1 msg/sec)
- Better for high-volume messaging
- Professional appearance
- No 10DLC registration needed
Verification Required:
- Toll-free verification through carrier
- Submit business info and use case
- Processing time: 5-10 business days
Troubleshooting
Messages not delivering
- ✅ Verify phone purchase completed (
status: ACTIVE) - ✅ Check deployment is active (
isActive: true) - ✅ Ensure
smsChannelIdis correct - ✅ Verify phone number has SMS capability enabled
- ✅ Check account has sufficient credits
- ✅ Review carrier filtering (spam detection)
Delayed message delivery
- ✅ Check carrier throughput limits
- ✅ Verify 10DLC registration status
- ✅ Review A2P trust score
- ✅ Contact support for carrier status
Agent not responding
- ✅ Verify Agent Configuration is valid
- ✅ Check Instruction Configuration exists
- ✅ Review message logs in WIIL Console
- ✅ Test with simple message first
Messages marked as spam
- ✅ Complete 10DLC registration
- ✅ Improve A2P trust score
- ✅ Avoid spam trigger words
- ✅ Include opt-out instructions
- ✅ Monitor user engagement
Next Steps
- Voice: Voice Channels Guide
- Web: Web Channels Guide
- Troubleshooting: Troubleshooting Guide
- Phone Purchase: Phone Purchase Guide