Announcement

Collapse
No announcement yet.

How to integrate with WordPress website form to lead capture of ESPO

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

  • How to integrate with WordPress website form to lead capture of ESPO

    Hi, I am trying to integrate WordPress form to ESPO lead capture functionality. So Far I tried Gravity form and webhook addons of gravity. But it is not working, Here is the screenshot.
    Is there any easy way to do this? any WordPress plugin or any way that I do easily.
    Attached Files

  • #2
    Hi,

    This way is already easy. There can be many reasons why it does not work. Need more details, errors etc.

    Comment


    • #3
      Yes, I check the gravity form webhook log. It seems in ESPO country field was required that's why it is not working. Is there any way to also create a case when this lead is captured from the form?

      Comment


      • #4
        Hi minhaj,

        To create a case when lead is captured from the form you can use the following formula script in the Administration > Entity Manager > Lead > Formula > Before Save Custom Script:
        Code:
        if (entity\isNew() && source == 'Lead Capture' && createdBy.userName == 'system') {
            record\create('Case',
                          'name', 'Case Name'
                          )
        }

        Comment


        • minhaj
          minhaj commented
          Editing a comment
          Hi lazovic, Thank you for the formula, It is working and also giving notification to admin that the system created the case. However I am not able to give the case name the same as the lead name created by lead capture. any way of doing that ? Also, I want to assign the lead and case to someone.

          ```
          if (entity\isNew() && source == 'Lead Capture' && createdBy.userName == 'system') {
          var leadName = entity\attribute('name');
          record\create('Case',
          'name', leadName
          );
          }
          ``​​​​​​`
          Last edited by minhaj; 05-01-2024, 07:54 PM.

      • #5
        I can confirm that this setup - WP + Gravity Forms is working perfectly... I have 10+ forms integrated to Espo instances via this way.

        Comment


        • #6
          Yes, Kpuc . It's working. I have a question though. Why "Source" is not in the Payload Fields yuri ?

          Comment


          • #7
            Gravity form giving me the "source url" which I wanted to pass on the lead source. Lead source would have a value that contains the URL set by me.

            Comment


            • #8
              I have a workaround for this, I need to create a Lead Capture for every form and give them lead source according to that. Ok. But why I am not getting any notification when lead is created by Lead Capture?​

              Comment


              • #9
                Lead source is enum field that is pre-defined by the Lead Capture configuration. You can create a custom URL field.

                Comment


                • #10
                  I am assigning the lead to someone by using the Payload. Thank you everyone for helping me. All I am wondering about is the case now, How I am gonna create a case using the lead info and assign to someone.

                  Comment


                  • #11
                    Hi minhaj,

                    In the EspoCRM formula script, variables are not defined by the var word. Moreover, in this case you don't have to create a variable at all, since you can directly pull out the lead name (since you are in the lead formula). Specifying the case name as the lead name and linking the assigned user will look like this:
                    Code:
                    if (entity\isNew() && source == 'Lead Capture' && createdBy.userName == 'system') {
                       record\create('Case',
                                     'name', name,
                                     'assignedUserId', 'user-id' // insert any user ID
                                    );
                    }​
                    I actually recommend that you use workflows for things like this. This is much more convenient, you don’t need to use formulas (for cases like yours), everything is intuitive. Workflows are the Advanced Pack extension feature: https://www.espocrm.com/extensions/advanced-pack.

                    In any case, I also recommend that you learn more about the formula: https://docs.espocrm.com/administration/formula.​

                    Comment


                    • #12
                      You can make a POST request to api/v1/Case endpoint.

                      1. Create an API user.
                      2. Give that user Role to be able to create Case.
                      3. Configure Wordpress Form to make POST api/v1/Case requests.

                      Comment


                      • #13
                        Hi yuri, Thank you for your help. I have tried your approach. It is working, however, I have an input file upload field on my gravity form. They sends it as a string and ESPO receives it as an array.

                        Here is the error log on Gravity webhook :

                        `` code: 400; body: {"messageTranslation":{"label":"validationFailu re" ,"scope":null,"data":{"field":"photosLink","typ e": "array"}}} ``
                        Is there any way to solve this?
                        Thank you again!!
                        Last edited by minhaj; 05-06-2024, 03:28 PM.

                        Comment


                        • #14
                          I finally solved this. To change the data type of input field from gravity webhook. You can use a filter and return the data as ESPO CRM rest API demand. Here is a snippet of code that you have to add in function.php :
                          ``
                          add_filter( 'gform_webhooks_request_data', function ( $request_data, $feed ) {
                          // Check if the request URL contains 'api url' (adjust as needed)
                          $request_url = rgars( $feed, 'meta/requestURL' );
                          if ( strpos( $request_url, 'example.com' ) !== false ) {
                          // Get the "photosLink" field value from the request data
                          $photos_link = rgar( $request_data, 'photosLink' );
                          // Split the "photosLink" field value into an array of photo links
                          $photo_links = array_map( 'trim', explode( ',', $photos_link ) );

                          // Add the modified "photosLink" field value to the request data
                          $request_data['photosLink'] = $photo_links;
                          }

                          return $request_data;
                          }, 10, 2 );
                          ​``
                          learn more about the filter here : https://docs.gravityforms.com/gform_..._request_data/

                          I hope this solution will be helpful if a person looking to send images via res API in WordPress. I think lazovic's formula solution will run every time I create or update a case or lead. yuri rest API solution is more efficient here. Thank you everyone!​

                          Comment

                          Working...
                          X