Skip to content

Forum in maintenance, we will back soon 🙂

Create Viral Conten...
 
Notifications
Clear all

Create Viral Content With this Automated System

12 Posts
4 Users
2 Reactions
25 Views
(@google-collmandigitalmarketingagency)
Posts: 6
Active Member
Topic starter
 

Hi Hasan,

Thank you for the tutorials, I am learning a lot. I do have a problem with this download: https://us1.make.com/apps/invite/63e61131a4e45809cd5bd864943f4807/accept

It will not allow me to check my name to activate the install button. 

Please advise

 

Christopher

 

 
Posted : 08/15/2024 10:08 pm
SSAdvisor
(@ssadvisor)
Posts: 1127
Noble Member
 

@google-collmandigitalmarketingagency I cannot either. Hmm... this may be a bug with Make but let @Hasan check his app first.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 08/16/2024 11:53 am
(@google-collmandigitalmarketingagency)
Posts: 6
Active Member
Topic starter
 

Thanks, I am looking forward to the solution. 

 
Posted : 08/17/2024 2:15 pm
(@husein)
Posts: 409
Member Moderator
 

@ssadvisor @google-collmandigitalmarketingagency The problem is from Make's side, we contacted the support and waiting for them to solve it. We'll let you know once the problem is solved.

 
Posted : 08/17/2024 3:14 pm
Hasan Aboul Hasan
(@admin)
Posts: 1185
Member Admin
 

please use the updated link to install the App, it must work now

 
Posted : 08/22/2024 8:02 pm
(@google-collmandigitalmarketingagency)
Posts: 6
Active Member
Topic starter
 

Thank you, Hasan. You are the best 😊 . I just completed the Integrated Google Sheet. It's working like a charm. 

I am working on building my tools and using Perplexity For the YouTube title generator, but I am having problems with the endpoint. https://www.collmandigitalmarketing.com/my-new-ai-tools/

I am practicing with ChatGPT every day. What is the best plugin to use for a WordPress community?

 

The first sale I get I am buying lifetime access for $800.

 

Christopher 

 

 
 
 
 

 
 
 
 
Posted : 08/23/2024 2:52 am
(@husein)
Posts: 409
Member Moderator
 

@google-collmandigitalmarketingagency What exactly is the problem you're having?

 
Posted : 08/23/2024 5:54 am
(@google-collmandigitalmarketingagency)
Posts: 6
Active Member
Topic starter
 

I don't know how to configure the endpoint, the code is already in place.

Integrating the API Key and Endpoint:

Once you have the API key and endpoint, you’ll update the backend PHP code like this:

php

$apiKey = 'YOUR_ACTUAL_API_KEY'; // Replace with your actual API key
curl_setopt($ch, CURLOPT_URL, 'https://api.perplexity.ai/YOUR_ENDPOINT'); // Replace with the actual endpoint
  • YOUR_ACTUAL_API_KEY: Replace 'YOUR_ACTUAL_API_KEY' with the key you obtained.
  • YOUR_ENDPOINT: Replace 'https://api.perplexity.ai/YOUR_ENDPOINT' with the correct API endpoint URL provided by Perplexity.
 
Posted : 08/23/2024 5:36 pm
(@google-collmandigitalmarketingagency)
Posts: 6
Active Member
Topic starter
 

The UI image is 

YouTube UI

but the PHP had an error:

// Unique API Key Setter
function setUniqueApiKey() {
    return "xxxxxxxxxxxxxxxx"; // Replace with your Perplexity API key
}

// Unique Prompt Setter
function generateUniquePrompt($input) {
    return "Generate 5 catchy YouTube titles for a video about " . $input;
}

// Define a Unique "Model"
function createUniqueTitlesModel($titles) {
    return ["titles" => $titles];
}

// Helper JSON Functions with Unique Names
function modelToJsonUnique($modelInstance) {
    return json_encode($modelInstance);
}

function extractJsonUnique($textResponse) {
    $pattern = '/{[^{}]*}/';

    preg_match_all($pattern, $matches);
    $jsonObjects = [];

    foreach ($matches[0] as $jsonStr) {
        try {
            $jsonObj = json_decode($jsonStr, true, 512, JSON_THROW_ON_ERROR);
            array_push($jsonObjects, $jsonObj);
        } catch (JsonException $e) {
            $extendedJsonStr = extendSearchUnique($textResponse, $jsonStr);
            try {
                $jsonObj = json_decode($extendedJsonStr, true, 512, JSON_THROW_ON_ERROR);
                array_push($jsonObjects, $jsonObj);
            } catch (JsonException $e) {
                continue;
            }
        }
    }

    return !empty($jsonObjects) ? $jsonObjects : null;
}

function extendSearchUnique($text, $jsonStr) {
    $start = strpos($text, $jsonStr);
    $end = $start + strlen($jsonStr);
    $nestCount = 0;

    for ($i = $start; $i < strlen($text); $i++) {
        if ($text[$i] === '{') {
            $nestCount++;
        } elseif ($text[$i] === '}') {
            $nestCount--;
            if ($nestCount === 0) {
                return substr($text, $start, $i - $start + 1);
            }
        }
    }

    return substr($text, $start, $end - $start);
}

function jsonToModelUnique($modelClass, $jsonData) {
    try {
        return $modelClass($jsonData);
    } catch (Exception $e) {
        echo "Validation error: " . $e->getMessage();
        return null;
    }
}

function validateJsonWithUniqueModel($modelClass, $jsonData) {
    $validatedData = [];
    $validationErrors = [];

    if (is_array($jsonData)) {
        foreach ($jsonData as $item) {
            try {
                $modelInstance = $modelClass($item);
                array_push($validatedData, $modelInstance);
            } catch (Exception $e) {
                array_push($validationErrors, ["error" => $e->getMessage(), "data" => $item]);
            }
        }
    } elseif (is_assoc_unique($jsonData)) {
        try {
            $modelInstance = $modelClass($jsonData);
            array_push($validatedData, $modelInstance);
        } catch (Exception $e) {
            array_push($validationErrors, ["error" => $e->getMessage(), "data" => $jsonData]);
        }
    } else {
        throw new ValueError("Invalid JSON data type. Expected associative array or array.");
    }

    return [$validatedData, $validationErrors];
}

function is_assoc_unique(array $arr) {
    if (array() === $arr) return false;
    return array_keys($arr) !== range(0, count($arr) - 1);
}

// Perplexity API Interaction with Unique Naming
function generateResponseWithPerplexityUnique($prompt) {
    $api_key = "xxxxxxxxxxxxxxxxxxxxxxx"();
    $api_url = 'https://api.perplexity.ai/v1/query; // Perplexity API endpoint

    // Headers for the Perplexity API
    $headers = [
        'Authorization' => 'Bearer ' . $api_key,
        'Content-Type' => 'application/json'
    ];

    // Body for the Perplexity API
    $body = [
        'prompt' => $prompt,
        'max_tokens' => 150 // Adjust this based on your needs
    ];

    // Args for the WordPress HTTP API
    $args = [
        'method' => 'POST',
        'headers' => $headers,
        'body' => json_encode($body),
        'timeout' => 120
    ];

    // Send the request
    $response = wp_remote_request($api_url, $args);
    
    // Extract the body from the response
    $responseBody = wp_remote_retrieve_body($response);

    // Decode the JSON response body
    $decoded = json_decode($responseBody, true);
    
    // Extract the text
    if (isset($decoded['choices'][0]['text'])) {
        $extractedText = $decoded['choices'][0]['text'];
        return $extractedText;
    } else {
        return 'Text not found in response';
    }
}

// Main AJAX Handler with Unique Naming
function customToolRunUnique() {
    // Add CORS headers
    header('Access-Control-Allow-Origin: *'); // Allows all origins
    header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); // Specifies the allowed methods
    header('Access-Control-Allow-Headers: Content-Type, Authorization'); // Specifies the allowed headers 

    // Variables
    $input = $_POST['input'];

    $basePrompt = generateUniquePrompt($input);
    
    // Creating an instance of your model
    $titlesModel = createUniqueTitlesModel(['title1', 'title2']);
    
    // Convert model instance to JSON
    $jsonModel = modelToJsonUnique($titlesModel);
    
    // Create optimized prompt
    $optimizedPrompt = $basePrompt . ". Please provide a response in a structured JSON format that matches the following model: " . $jsonModel;

    // Generate content using the modified prompt
    $perplexityResponse = generateResponseWithPerplexityUnique($optimizedPrompt);
    
    // Extract and validate the JSON from the response
    $jsonObjects = extractJsonUnique($perplexityResponse);
    
    wp_send_json_success($jsonObjects);

    // Always die in functions echoing AJAX content
    wp_die();
}

add_action('wp_ajax_custom_tool_run_unique', 'customToolRunUnique');
add_action('wp_ajax_nopriv_custom_tool_run_unique', 'customToolRunUnique');
 
Posted : 08/23/2024 5:59 pm
(@husein)
Posts: 409
Member Moderator
 

@google-collmandigitalmarketingagency Is this code ChatGPT generated?

The AJAX add_action in the end of the code is calling for a custom_tool_run_unique, however in this code you don't have a function with this name, so it wont work. 

Or you have this function in another code snippet? if you do please share that PHP code too.

 
Posted : 08/24/2024 6:57 am
(@google-collmandigitalmarketingagency)
Posts: 6
Active Member
Topic starter
 

Yes, ChatGPT generated it  Your original PHP works well -AI Blog post generator. If you can modify this to use perplexity that would be great. I tried this by just changing the prompt but it gave me a saying that it is already in use. Also I am getting this error with

Intensive Topic Research with AI and Recursive LLM Calls

Intensive Topic Research with AI and Recursive LLM Calls

You can now view your Streamlit app in your browser.

Local URL: http://localhost:8505
Network URL: http://192.168.0.53:8505

2024-08-24 04:14:18.270 Uncaught app exception
Traceback (most recent call last):
File "/Applications/Python 3.12/Downloads/Make Automation/MakeAutomations/Hasan Automation/Keyword-Research-Graph-main 2/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 85, in exec_func_with_error_handling
result = func()
^^^^^^
File "/Applications/Python 3.12/Downloads/Make Automation/MakeAutomations/Hasan Automation/Keyword-Research-Graph-main 2/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 576, in code_to_exec
exec(code, module.__dict__)

// Your Inputs
function setApiKey() {
    return "xxxxxxx";
}

function setPrompt($input) {
    return "Generate 5 catchy blog titles for a blog post about " . $input;
}


// Define your "model" as an associative array
function createTitlesModel($titles) {
    return ["titles" => $titles];
}

// Helper JSON Functions
function modelToJson($modelInstance) {
    return json_encode($modelInstance);
}

function extractJson($textResponse) {
    $pattern = '/{[^{}]*}/';

    preg_match_all($pattern, $textResponse, $matches);
    $jsonObjects = [];

    foreach ($matches[0] as $jsonStr) {
        try {
            $jsonObj = json_decode($jsonStr, true, 512, JSON_THROW_ON_ERROR);
            array_push($jsonObjects, $jsonObj);
        } catch (JsonException $e) {
            // Extend the search for nested structures
            $extendedJsonStr = extendSearch($textResponse, $jsonStr);
            try {
                $jsonObj = json_decode($extendedJsonStr, true, 512, JSON_THROW_ON_ERROR);
                array_push($jsonObjects, $jsonObj);
            } catch (JsonException $e) {
                // Handle cases where the extraction is not valid JSON
                continue;
            }
        }
    }

    return !empty($jsonObjects) ? $jsonObjects : null;
}

function extendSearch($text, $jsonStr) {
    // Extend the search to try to capture nested structures
    $start = strpos($text, $jsonStr);
    $end = $start + strlen($jsonStr);
    $nestCount = 0;

    for ($i = $start; $i < strlen($text); $i++) {
        if ($text[$i] === '{') {
            $nestCount++;
        } elseif ($text[$i] === '}') {
            $nestCount--;
            if ($nestCount === 0) {
                return substr($text, $start, $i - $start + 1);
            }
        }
    }

    return substr($text, $start, $end - $start);
}

function jsonToModel($modelClass, $jsonData) {
    try {
        return $modelClass($jsonData);
    } catch (Exception $e) {
        echo "Validation error: " . $e->getMessage();
        return null;
    }
}

function validateJsonWithModel($modelClass, $jsonData) {
    $validatedData = [];
    $validationErrors = [];

    if (is_array($jsonData)) {
        foreach ($jsonData as $item) {
            try {
                $modelInstance = $modelClass($item);
                array_push($validatedData, $modelInstance);
            } catch (Exception $e) {
                array_push($validationErrors, ["error" => $e->getMessage(), "data" => $item]);
            }
        }
    } elseif (is_assoc($jsonData)) {
        try {
            $modelInstance = $modelClass($jsonData);
            array_push($validatedData, $modelInstance);
        } catch (Exception $e) {
            array_push($validationErrors, ["error" => $e->getMessage(), "data" => $jsonData]);
        }
    } else {
        throw new ValueError("Invalid JSON data type. Expected associative array or array.");
    }

    return [$validatedData, $validationErrors];
}

function is_assoc(array $arr) {
    if (array() === $arr) return false;
    return array_keys($arr) !== range(0, count($arr) - 1);
}

function generate_response_with_gemini($prompt) {
    
    $api_key = setApiKey();
    $api_url = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=' . $api_key ;


    // Headers for the Gemini API
    $headers = [
        'Content-Type' => 'application/json'
    ];

    // Body for the Gemini API
    $body = [
        'contents' => [
            [
                'parts' => [
                    ['text' => $prompt]
                ]
            ]
        ]
    ];

    // Args for the WordPress HTTP API
    $args = [
        'method' => 'POST',
        'headers' => $headers,
        'body' => json_encode($body),
        'timeout' => 120
    ];

    // Send the request
    $response = wp_remote_request($api_url, $args);
    
    // Extract the body from the response
    $responseBody = wp_remote_retrieve_body($response);

    // Decode the JSON response body
    $decoded = json_decode($responseBody, true);
    
    // Extract the text
    if (isset($decoded['candidates'][0]['content']['parts'][0]['text'])) {
        $extractedText = $decoded['candidates'][0]['content']['parts'][0]['text'];
        return $extractedText;
    } else {
        return 'Text not found in response';
    }


}

function custom_tool_run() {
    
    
         // Add CORS headers
         header('Access-Control-Allow-Origin: *'); // Allows all origins
         header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); // Specifies the allowed methods
         header('Access-Control-Allow-Headers: Content-Type, Authorization'); // Specifies the allowed headers 
    
    
        // Variables
        $input = $_POST['input'];

        $basePrompt = setPrompt($input);
    
        
        // Creating an instance of your model
        $titlesModel = createTitlesModel(['title1', 'title2']);
    
        // Convert model instance to JSON
        $jsonModel = modelToJson($titlesModel);
    
        
        // Create optimized prompt
        $optimizedPrompt = $basePrompt . ". Please provide a response in a structured JSON format that matches the following model: " . $jsonModel;

    
        // Generate content using the modified prompt
        $gemeniResponse = generate_response_with_gemini($optimizedPrompt);
    
        // Extract and validate the JSON from the response
        $jsonObjects = extractJson($gemeniResponse);
    
        wp_send_json_success($jsonObjects);

        // Always die in functions echoing AJAX content
        wp_die();
}

add_action('wp_ajax_custom_tool_run', 'custom_tool_run');
add_action('wp_ajax_nopriv_custom_tool_run', 'custom_tool_run');
 
Posted : 08/24/2024 8:44 am
(@husein)
Posts: 409
Member Moderator
 

@google-collmandigitalmarketingagency There's a problem with the PHP code that ChatGPT generated that's why you're getting errors; why are you using perplexity? If you're looking for a free API for now, you can use Gemini. 

Here's a PHP code snippet to use Gemini; edit it a bit so that it fits your tool and it'll work fine.

 
Posted : 08/24/2024 2:22 pm
Share:
[the_ad_group id=”312″]