Announcement

Collapse
No announcement yet.

Web-to-lead for MODX CMS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web-to-lead for MODX CMS

    There is a need to set up sending requests from the site to ModX in Espo. Lead Capture tried, I could not get
    if anyone has a solution, please share

  • #2
    First time I heard of ModX, looked through their website and it seem to be possible, quite a few CRM and form integration for other system. You might be able to figure it out on how they did it and do it for EspoCRM.

    Searching on the forum, there is only 1 Russian thread that talked about ModX.

    https://forum.espocrm.com/forum/inte...82%D0%BE%D0%BC
    https://modx.com/extras/browse/?cate...ts=&search=api
    https://modx.com/extras/browse/?cate...s=&search=form

    Comment


    • #3
      thank you, I will study if someone has a ready-made solution or experience with MODx, is ready to consider paid services

      Comment


      • #4
        Solution

        1. Create an entry point to CRM

        Payload (for example):


        {
        "firstName": "FIRST_NAME",
        "phoneNumber": "PHONE_NUMBER",
        "emailAddress": "EMAIL_ADDRESS",
        "description": "DESCRIPTION",
        "iPAddress": "I_P_ADDRESS"
        }

        2. Add a Sniped to the "FormIt" category in ModX

        Snippet
        code (you need to replace URL and API Key with your own values) :

        PHP Code:
        <?php
        if(file_exists(MODX_BASE_PATH 'libs/EspoApiClient.php')) {
        require_once(
        MODX_BASE_PATH 'libs/EspoApiClient.php');
        } else {
        $modx->log('error''Not found need Class');
        return 
        true;
        }

        $name '';
        $phone '';
        $email '';
        $question '';
        $message '';
        $allFormFields $hook->getValues();
        $ip $modx->getOption('REMOTE_ADDR'$_SERVER'');
        $formName $modx->getOption('emailSubject'$formit->config'form-'.$modx->resource->get('id'));

        foreach (
        $allFormFields as $key => $value) {
        if(
        strpos($key'email') !== false) {
        $email $value;
        unset(
        $allFormFields[$key]);
        }
        if(
        strpos($key'name') !== false) {
        $name $value;
        unset(
        $allFormFields[$key]);
        }
        if(
        strpos($key'phone') !== false) {
        $phone str_replace(['('')'' ''-'], ''$value);
        unset(
        $allFormFields[$key]);
        }
        if(
        strpos($key'question') !== false) {
        $question "".$value.", ";
        unset(
        $allFormFields[$key]);
        }
        if(
        strpos($key'message') !== false) {
        $message "".$value."";
        unset(
        $allFormFields[$key]);
        }
        }
        $message 'Application "'.$formName.'" from the page "'.$modx->resource->get('pagetitle').'", description: '$question .' '.$message.', IP - ' $ip;
        // $message = "Filled form from page -" . $allFormFields['page_name'] . '. Name of the form - ' . $formName . '. ' . '. IP - ' . $ip . '. ';
        unset($allFormFields['page_name'], $allFormFields['page_url'], $allFormFields['pageId']);

        $message .= implode('. '$allFormFields);

        $client = new EspoApiClient('https://xxxxxxxxxx.xxx/); // link to your site here

        $apiKey = '
        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // specify your API key here

        $formData = [
        '
        firstName' => $name,
        '
        phoneNumber' => $phone,
        '
        emailAddress' => $email,
        '
        description' => $message
        ];

        $client->request('
        POST', 'LeadCapture/' . $apiKey, $formData);
        Last edited by alexisc; 01-18-2022, 03:28 PM.

        Comment

        Working...
        X