WP Manifestindependent plugin directory
manifest / integrations / textlink-integration

TextLink Integration

WordPress Plugin to Support TextLink API

by Alex Porter / Hoki Limited · github.com/hokiplc/textlink-integration · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/hokiplc/textlink-integration/archive/refs/heads/main.zip

TextLink 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

  1. Upload the textlink-integration folder to /wp-content/plugins/
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Navigate to TextLink → Settings
  4. 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

  1. Get API Credentials:

    • Log into your TextLink dashboard
    • Navigate to API settings
    • Copy your API Key and Secret
  2. 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
  3. Test SMS:

    • Use the "Send Test SMS" section
    • Enter your phone number
    • Click "Send Test SMS"

Form Integration

Contact Form 7

  1. Edit your contact form in WordPress
  2. Find the "TextLink SMS Settings" meta box
  3. Enable SMS notification
  4. 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

  1. Edit form in Gravity Forms
  2. Add TextLink settings to form settings
  3. Map phone number field
  4. Configure message template using merge tags: {Field Label:1}

WPForms

  1. Edit form in WPForms
  2. Navigate to Settings → TextLink
  3. Enable SMS notification
  4. Configure phone field and message template

Scheduled Reminders

Via Form Submission:

  1. Enable reminders in form settings
  2. Set delay in minutes (e.g., 1440 for 24 hours)
  3. Configure reminder message template

Manual Scheduling:

  1. Navigate to TextLink → Reminders
  2. Click "Schedule New Reminder"
  3. Enter:
    • Recipient phone number
    • Message content
    • Scheduled date/time
  4. 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:

  1. Enable "Chat agent" in Settings

  2. 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');
  3. 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);
  4. 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:

  1. wp_textlink_logs: SMS delivery logs
  2. wp_textlink_reminders: Scheduled messages
  3. wp_textlink_conversations: Chat conversations (if chat enabled)
  4. wp_textlink_messages: Chat message history (if chat enabled)

Troubleshooting

SMS Not Sending

  1. Check API credentials in Settings
  2. Click "Test Connection" button
  3. Verify phone number format (+country code)
  4. Check error logs: TextLink → Logs
  5. Ensure sufficient API credits

Form Integration Not Working

  1. Verify form plugin is active
  2. Check phone field name matches exactly
  3. Test message template syntax
  4. Enable debugging: define('WP_DEBUG', true);

Reminders Not Processing

  1. Check WordPress cron is working:
    wp_next_scheduled('textlink_process_reminders');
  2. Manually trigger: do_action('textlink_process_reminders');
  3. Consider using external cron if WP-Cron unreliable

Chat Not Responding

  1. Verify "Enable chat agent" is checked
  2. Check inbox processing schedule
  3. Manually trigger: do_action('textlink_check_inbox');
  4. 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

  1. Phone Numbers: Always use international format (+country code)
  2. Message Length: Keep under 160 characters (1 SMS credit)
  3. Rate Limiting: Be mindful of API rate limits
  4. Opt-outs: Respect user opt-out requests
  5. Testing: Use test mode for development
  6. 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:

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