Skip to main content

Overview

The WordPress integration enables you to:
  • Import WordPress users as contacts
  • Trigger campaigns from WordPress events
  • Sync user data between WordPress and TelemanAI
  • Authenticate API requests with token-based security

Prerequisites

  • WordPress site with admin access
  • TelemanAI plugin installed on WordPress
  • PHP 7.4 or higher on your WordPress server

Installation

1

Install TelemanAI WordPress Plugin

  1. Download the TelemanAI WordPress plugin
  2. Upload to /wp-content/plugins/teleman-wordpress/
  3. Activate the plugin from Plugins menu in WordPress admin
2

Configure WordPress in TelemanAI

  1. Log in to TelemanAI dashboard
  2. Navigate to IntegrationsWordPress
  3. Enter your WordPress configuration:
  • WordPress URL: Your WordPress site URL (e.g., https://example.com)
  • Admin Email: Your WordPress admin email address
  1. Click Save Configuration
3

Generate API Token

In TelemanAI:
  1. Click Generate Token button
  2. Copy the generated token
  3. This token will be used to authenticate API requests
Keep your API token secure. Anyone with this token can access your TelemanAI account.
4

Configure Plugin in WordPress

In WordPress admin:
  1. Go to SettingsTelemanAI
  2. Paste the API token from previous step
  3. Enter your TelemanAI application URL
  4. Click Save Settings

Importing WordPress Users

1

Fetch WordPress Users

In TelemanAI:
  1. Go to IntegrationsWordPress
  2. Click Fetch Data
  3. TelemanAI will retrieve all WordPress users via API
2

Review Imported Data

TelemanAI displays a preview of fetched contacts:
  • User name
  • Phone number (if available)
  • Email address
  • User role
3

Import to Contacts

  1. Review the preview list
  2. Click Store Contacts
  3. Duplicate phone numbers are automatically skipped
  4. You’ll see a summary: “X new contacts stored”

API Integration Details

Authentication Flow

The integration uses token-based authentication:
// Token Generation (TelemanAI side)
$token = generate_token();
$wordpress->user_token = $token;
$wordpress->save();

Fetching Contacts

The API endpoint for fetching WordPress contacts:
// API Endpoint
GET {WORDPRESS_URL}/wp-content/plugins/teleman-wordpress/teleman/phonebook.php?token={TOKEN}
Expected Response:
[
  {
    "name": "John Doe",
    "phone": "+1234567890"
  },
  {
    "name": "Jane Smith",
    "phone": "+0987654321"
  }
]

WordPress Plugin Setup

The TelemanAI WordPress plugin should expose a contacts endpoint:

Plugin File Structure

wp-content/plugins/teleman-wordpress/
├── teleman-wordpress.php      # Main plugin file
├── teleman/
│   └── phonebook.php           # API endpoint
└── readme.txt

Example Plugin Implementation

teleman/phonebook.php:
<?php
// Verify token
if (!isset($_GET['token']) || !verify_teleman_token($_GET['token'])) {
    http_response_code(401);
    exit('Unauthorized');
}

// Get all WordPress users
$users = get_users();
$contacts = [];

foreach ($users as $user) {
    $phone = get_user_meta($user->ID, 'phone', true);
    
    if (!empty($phone)) {
        $contacts[] = [
            'name' => $user->display_name,
            'phone' => $phone
        ];
    }
}

header('Content-Type: application/json');
echo json_encode($contacts);

Triggering Campaigns from WordPress

You can trigger TelemanAI campaigns from WordPress events:

Example: New User Registration Campaign

add_action('user_register', function($user_id) {
    $user = get_user_by('id', $user_id);
    $phone = get_user_meta($user_id, 'phone', true);
    
    if (!empty($phone)) {
        // Call TelemanAI API to trigger campaign
        $response = wp_remote_post('https://your-teleman.com/api/campaign/trigger', [
            'body' => [
                'token' => get_option('teleman_api_token'),
                'campaign_id' => 123,
                'contact' => [
                    'name' => $user->display_name,
                    'phone' => $phone
                ]
            ]
        ]);
    }
});

Routes and Controller Reference

Key routes for WordPress integration (see routes/woocommerce.php):
RouteMethodDescription
/dashboard/wpGETWordPress integration page
/dashboard/wp/storePOSTSave WordPress configuration
/dashboard/wp/tokenPOSTGenerate API token
/dashboard/wp/fetch_dataGETFetch WordPress users
/dashboard/wp/store_dataGETImport users to contacts
Controller implementation: WordPressController.php (lines 1-228)

Configuration Storage

WordPress configuration is stored in the third_party table:
SELECT * FROM third_party 
WHERE application_name = 'wordpress' 
AND user_id = {current_user_id};
Fields:
  • application_name: ‘wordpress’
  • application_url: WordPress site URL
  • user_email: Admin email
  • user_token: API authentication token

Troubleshooting

Problem: “The connection is failed” when generating tokenSolution:
  • Verify WordPress URL is accessible from TelemanAI server
  • Check that the plugin is installed and activated
  • Ensure the plugin endpoint is publicly accessible
  • Test the URL manually in a browser
Problem: Fetch returns empty or failsSolution:
  • Verify users have phone numbers in WordPress
  • Check the API endpoint returns valid JSON
  • Ensure the token is correctly passed in the URL
  • Review WordPress error logs for PHP errors
Problem: Contacts won’t import to databaseSolution:
  • Ensure phone numbers are in valid format
  • Check that you’ve fetched data first (session ‘woocommerce’ exists)
  • Verify database permissions
  • Review TelemanAI logs for specific errors
Problem: API requests return 401Solution:
  • Regenerate the API token in TelemanAI
  • Update the token in WordPress plugin settings
  • Ensure the token hasn’t expired
  • Check that the token is correctly URL-encoded

Security Best Practices

Security Recommendations:
  • Always use HTTPS for both WordPress and TelemanAI
  • Never expose API tokens in client-side code
  • Implement token rotation/expiration
  • Use WordPress nonces for form submissions
  • Validate and sanitize all API inputs
  • Limit API access by IP if possible

Advanced Configuration

Custom User Meta Fields

To include additional WordPress user meta:
// In WordPress plugin
$contacts[] = [
    'name' => $user->display_name,
    'phone' => get_user_meta($user->ID, 'phone', true),
    'company' => get_user_meta($user->ID, 'company', true),
    'notes' => get_user_meta($user->ID, 'notes', true)
];

Webhook Integration

Set up webhooks to receive events from TelemanAI:
// In WordPress functions.php
add_action('rest_api_init', function() {
    register_rest_route('teleman/v1', '/webhook', [
        'methods' => 'POST',
        'callback' => 'handle_teleman_webhook',
        'permission_callback' => 'verify_teleman_token'
    ]);
});

function handle_teleman_webhook($request) {
    $data = $request->get_json_params();
    
    // Process campaign results
    if ($data['event'] === 'call_completed') {
        update_user_meta(
            $data['user_id'], 
            'last_call_status', 
            $data['status']
        );
    }
    
    return new WP_REST_Response(['success' => true], 200);
}

Next Steps

WooCommerce Integration

Connect with WooCommerce for order-based campaigns

Campaign Automation

Automate campaigns based on WordPress events

Contact Management

Manage your WordPress contacts

API Reference

Complete API documentation

Build docs developers (and LLMs) love