TextLink Integration
WordPress Plugin to Support TextLink API
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/hokiplc/textlink-integration/archive/refs/heads/main.zipTextLink Integration for WordPress
A comprehensive WordPress plugin for integrating TextLink SMS services with your website. Send SMS notifications, schedule reminders, and implement basic chat agent functionality.
Features
- SMS API Integration: Simple wrapper around TextLink API
- Form Integration: Works with Contact Form 7, Gravity Forms, and WPForms
- Scheduled Reminders: Schedule SMS messages for future delivery
- Chat Agent Foundation: Basic two-way SMS chat capability
- Logging: Track all sent messages
- Admin Dashboard: Comprehensive settings and management interface
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- TextLink account with API credentials
- MySQL 5.6 or higher
Installation
- Upload the
textlink-integrationfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to TextLink → Settings
- Enter your API credentials:
- API Key (required)
- API Secret (if applicable)
- Sender ID (display name on SMS)
- Default Country Code (e.g., 44 for UK)
Configuration
Basic Setup
-
Get API Credentials:
- Log into your TextLink dashboard
- Navigate to API settings
- Copy your API Key and Secret
-
Configure Plugin:
WordPress Admin → TextLink → Settings - Enter API Key - Enter Sender ID (max 11 characters) - Set default country code - Enable desired features - Click "Test Connection" to verify -
Test SMS:
- Use the "Send Test SMS" section
- Enter your phone number
- Click "Send Test SMS"
Form Integration
Contact Form 7
- Edit your contact form in WordPress
- Find the "TextLink SMS Settings" meta box
- Enable SMS notification
- Configure:
- Phone field name (e.g., "your-phone")
- Message template using placeholders:
{field-name} - Optional reminder settings
Example template:
Hi {your-name}, thanks for contacting {site_name}! We'll respond within 24 hours.
Gravity Forms
- Edit form in Gravity Forms
- Add TextLink settings to form settings
- Map phone number field
- Configure message template using merge tags:
{Field Label:1}
WPForms
- Edit form in WPForms
- Navigate to Settings → TextLink
- Enable SMS notification
- Configure phone field and message template
Scheduled Reminders
Via Form Submission:
- Enable reminders in form settings
- Set delay in minutes (e.g., 1440 for 24 hours)
- Configure reminder message template
Manual Scheduling:
- Navigate to TextLink → Reminders
- Click "Schedule New Reminder"
- Enter:
- Recipient phone number
- Message content
- Scheduled date/time
- Click "Schedule Reminder"
Programmatic Usage:
<?php
// Schedule a reminder for 60 minutes from now
TextLink_Reminders::schedule_reminder(
'+447xxxxxxxxx',
'Reminder: Your appointment is tomorrow at 2pm',
60, // minutes
array('form_id' => 123) // optional metadata
);
// Schedule for specific datetime
TextLink_Reminders::schedule_reminder(
'+447xxxxxxxxx',
'Your booking is confirmed',
'2024-12-25 10:00:00'
);
?>
Chat Agent (Experimental)
The chat agent provides basic two-way SMS communication:
-
Enable "Chat agent" in Settings
-
Configure business details:
update_option('textlink_business_phone', '+447xxxxxxxxx'); update_option('textlink_business_hours', 'Mon-Fri 9am-5pm'); update_option('textlink_business_address', 'Your address here'); -
Customize automated responses:
$responses = array( 'greeting' => 'Hi! How can we help?', 'hours' => 'We\'re open Mon-Fri 9am-5pm', 'location' => '123 High Street, London' ); update_option('textlink_chat_responses', $responses); -
The plugin checks inbox every 2 hours and auto-responds based on keywords
Intent Recognition Keywords:
- Greeting: hello, hi, hey
- Help: help, support, assistance
- Booking: book, appointment, schedule
- Hours: hours, open, opening times
- Location: address, location, directions
- Stop: stop, unsubscribe, opt out
API Usage
Send SMS Programmatically
<?php
$api = TextLink_API::get_instance();
// Send to single number
$result = $api->send_sms('+447xxxxxxxxx', 'Your message here');
// Send to multiple numbers
$result = $api->send_sms(
array('+447xxxxxxxxx', '+447yyyyyyyyy'),
'Broadcast message'
);
// Send with options
$result = $api->send_sms(
'+447xxxxxxxxx',
'Test message',
array(
'test' => true, // Test mode
'schedule_time' => strtotime('+1 hour')
)
);
// Check result
if ($result['success']) {
echo 'SMS sent successfully!';
$message_id = $result['data']['message_id'];
} else {
echo 'Error: ' . $result['error'];
}
?>
Check Account Balance
<?php
$api = TextLink_API::get_instance();
$result = $api->get_balance();
if ($result['success']) {
$balance = $result['data']['balance'];
echo "Credits remaining: $balance";
}
?>
Get Inbox Messages
<?php
$api = TextLink_API::get_instance();
$result = $api->get_inbox(50); // Get last 50 messages
if ($result['success']) {
$messages = $result['data']['messages'];
foreach ($messages as $message) {
echo $message['number'] . ': ' . $message['message'];
}
}
?>
Hooks & Filters
Actions
<?php
// After SMS sent via form submission
add_action('textlink_message_sent', function($recipient, $message, $form_id) {
// Your code here
}, 10, 3);
// After reminder processed
add_action('textlink_reminder_processed', function($reminder, $result) {
// Your code here
}, 10, 2);
// After chat message processed
add_action('textlink_message_processed', function($from, $message, $intent, $response) {
// Your code here
}, 10, 4);
?>
Filters
<?php
// Modify message before sending
add_filter('textlink_before_send', function($message, $recipient) {
return $message . ' - Powered by MyCompany';
}, 10, 2);
// Modify chat response
add_filter('textlink_chat_response', function($response, $intent, $message) {
if ($intent === 'pricing') {
return 'Our pricing starts at £10/month';
}
return $response;
}, 10, 3);
?>
Database Tables
The plugin creates three tables:
- wp_textlink_logs: SMS delivery logs
- wp_textlink_reminders: Scheduled messages
- wp_textlink_conversations: Chat conversations (if chat enabled)
- wp_textlink_messages: Chat message history (if chat enabled)
Troubleshooting
SMS Not Sending
- Check API credentials in Settings
- Click "Test Connection" button
- Verify phone number format (+country code)
- Check error logs:
TextLink → Logs - Ensure sufficient API credits
Form Integration Not Working
- Verify form plugin is active
- Check phone field name matches exactly
- Test message template syntax
- Enable debugging:
define('WP_DEBUG', true);
Reminders Not Processing
- Check WordPress cron is working:
wp_next_scheduled('textlink_process_reminders'); - Manually trigger:
do_action('textlink_process_reminders'); - Consider using external cron if WP-Cron unreliable
Chat Not Responding
- Verify "Enable chat agent" is checked
- Check inbox processing schedule
- Manually trigger:
do_action('textlink_check_inbox'); - Review processed messages option
Security
- All inputs are sanitized
- Nonce verification on AJAX requests
- Capability checks for admin functions
- SQL queries use prepared statements
- API credentials stored in wp_options
Best Practices
- Phone Numbers: Always use international format (+country code)
- Message Length: Keep under 160 characters (1 SMS credit)
- Rate Limiting: Be mindful of API rate limits
- Opt-outs: Respect user opt-out requests
- Testing: Use test mode for development
- Logging: Enable logging for troubleshooting
Limitations
- Chat agent uses basic keyword matching (no NLP)
- Cron-based reminder processing (max hourly frequency)
- No MMS/media message support
- Single TextLink account per site
Roadmap
- [ ] Advanced NLP for chat agent
- [ ] MMS support
- [ ] Bulk SMS campaigns
- [ ] Detailed analytics dashboard
- [ ] Multi-account support
- [ ] Twilio/Nexmo integration options
Support
For issues and feature requests:
- Email: support@hokiltd.com
- Documentation: https://hokiltd.com/textlink-docs
License
GPL v2 or later
Credits
Developed by Alex Porter / Hoki Limited TextLink API integration for SMS services
Changelog
1.0.0 (2024-12-14)
- Initial release
- TextLink API integration
- Form plugin support (CF7, GF, WPForms)
- Scheduled reminders
- Basic chat agent
- Admin dashboard
- Logging system