PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

CRM integration

  1. jglenn29
    Member

    Can anyone help me figure out how to integrate gravity forms with my CRM?

    This is the code i have from the CRM so far, but i can't figure out how to make it work with gravity forms so that the entries will automatically be entered into the CRM. any one know what to do?

    // Change the information below to work with your system
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

    define(SUBDOMAIN,'{nomoremortage}'); // enter your subdomain here (ie. nomoremortgage)
    define(USERNAME, '{username}'); // change to the user name you want to use - needs to be a user that can add/edit/delete leads in the system
    define(PASSWORD, '{password}'); // change to the password you want to use
    define(TOKEN, '{token'); // generate a token in that admin area and get it from the email that will be sent to you and place here.

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    // BEGIN No More Mortgage - Form Post
    if ($_POST) {
    // Set up variables for the REST service.
    $username = USERNAME;
    $password = PASSWORD;
    $token = TOKEN;

    $webservice_url = "https://" . SUBDOMAIN . ".insidesales.com/do=noauth/rest/service";

    // Create a connection to the REST webservice.
    $client = new IS($webservice_url);
    $logged_in = $client->login($username, $password, $token);

    if (!$logged_in) {
    error_log("{$username} using password '{$password}' and token '{$token}' was not logged in.");
    }
    // Map options To the correct Campaign Id
    switch ($_POST['input_16']) {
    case 'Radio Ad':
    $campaign = '5'; // Edit Campaign Id here to change the campaign that Radio Ad goes into.
    break;
    case 'Television Ad':
    $campaign = '7'; // Edit Campaign Id here to change the campaign that Television Ad goes into.
    break;
    case 'Online':
    $campaign = '14'; // Edit Campaign Id here to change the campaign that Online goes into.
    break;
    case 'Other':
    $campaign = '16'; // Edit Campaign Id here to change the campaign that Other goes into.
    break;
    default:
    $campaign = '16'; // Edit Campaign Id here to change the default campaign.
    }
    // Get Post fields
    $first_name = $_POST['input_1_3']; // API: first_name  - First Name
    $last_name = $_POST['input_1_6']; // API: last_name  - Last Name
    $email = $_POST['input_56']; // API: email  - Email
    $phone = $_POST['input_52']; // API: phone  - Phone
    $alt_phone = $_POST['input_53']; // API: customFields_400  - Alternate Phone
    $home_value = $_POST['input_3']; // API: customFields_41  - Estimated Home Value
    $first_mortgage_balance = $_POST['input_4']; // API: customFields_37  - First Mortagage Balance
    $first_mortgage_type = $_POST['input_14']; // API: customFields_39  - First Mortagage Type
    $mortgage_years = $_POST['input_15']; // API: customFields_43  - Mortgage Years Remaining
    $second_mortgage = $_POST['input_6']; // API: customFields_45  - Second Mortgage Balance
    $credit_card_debt = $_POST['input_8']; // API: customFields_49  - Total Credit Card Debt
    $available_credit = $_POST['input_16']; // API: customFields_51  - Total Available Credit
    $auto_loans = $_POST['input_17']; // API: customFields_408  - Auto Loans
    $student_loans = $_POST['input_20']; // API: customFields_410  - Student Loans
    $timeshare_loans = $_POST['input_21']; // API: customFields_412  - Timeshare Loans
    $recreational_vehicles = $_POST['input_22']; // API: customFields_414  - Recreational Vehicle Loans
    $other_mortgages = $_POST['input_23']; // API: customFields_416  - Other Mortgages
    $personal_loans = $_POST['input_24']; // API: customFields_418  - Personal Loans
    $medical_loans = $_POST['input_25']; // API: customFields_420  - Medical Loans
    $tax_debts = $_POST['input_26']; // API: customFields_422  - Tax Debts
    $other_debt = $_POST['input_10']; // API: customFields_424  - Other Debt
    $cash_flow = $_POST['input_11']; // API: customFields_53  - How would you describe your cash flow?
    $make_your_payments = $_POST['input_27']; // API: customFields_426  - Are you able to make all of your payments?
    $credit_for_payments = $_POST['input_57']; // API: customFields_526  - Are you using savings or other credit cards to make your payments?
    $job_title = $_POST['input_30']; // API: customFields_57  - What is your job title?
    $gross_income = $_POST['input_31']; // API: customFields_63  - What is your gross monthly income?
    $net_income = $_POST['input_32']; // API: customFields_430  - What is your approximate net monthly income (take-home after taxes, etc)
    $often_paid = $_POST['input_33']; // API: customFields_65  - How often are you paid?
    $do_you_have_a_spouse = $_POST['input_34']; // API: customFields_721  - Do you have a spouse or significant other you live with?
    $spouse_first_name = $_POST['input_35_3']; // API: assistant_first_name - Spouse First Name
    $spouse_last_name = $_POST['input_35_6']; // API: assistant_last_name  - Spouse Last Name
    $spouse_job_title = $_POST['input_36']; // API: customFields_432  - Spouse Job Title
    $spouse_gross_income = $_POST['input_37']; // API: customFields_434  - Spouse Gross Monthly Income
    $spouse_net_income = $_POST['input_38']; // API: customFields_436  - Spouse Net Monthly Income
    $spouse_often_paid = $_POST['input_39']; // API: customFields_438  - Spouse Pay Frequency
    $other_monthly_income = $_POST['input_40']; // API: customFields_440  - Any Other Monthly Income?
    $do_you_get_a_tax_refund = $_POST['input_41']; // API: customFields_67  - Do you typically get a Federal Tax refund each year?es
    $much_your_tax_refund = $_POST['input_42']; // API: customFields_69  - How much is your typical tax refund amount?
    $checking_balance = $_POST['input_43']; // API: customFields_442  - Checking Account Balance
    $savings_balance = $_POST['input_44']; // API: customFields_444  - Savings Account Balance
    $investment_balance = $_POST['input_45']; // API: customFields_446  - Investment Account Balance
    $retirement_balance = $_POST['input_46']; // API: customFields_448  - Retirement Account Balance
    $other_asset_value = $_POST['input_47']; // API: customFields_452  - Other Assets ($ Value)
    $other_asset_description = $_POST['input_48']; // API: customFields_454  - Other Assets Description
    $when_debt_free = $_POST['input_49']; // API: customFields_460  - In what year do you plan to be debt free?
    $current_age = $_POST['input_50']; // API: customFields_458  - What is your current age?
    $spouse_current_age = $_POST['input_51']; // API: customFields_462  - What is your spouse's current age?
    $notes = $_POST['input_54']; // API: customFields_516  - Notes or Comments
    $form = 'PQ FORM'; // API: customFields_394  - Lead Sub Type

    // Create Filters to find the lead in the CRM that was added on the first form.
    //$get_lead_filter = array('field'=>'email', 'operator'=>'=', 'values'=>array($email));
    //$get_deleted_filter = array('field'=>'deleted', 'operator'=>'=', 'values'=>array('0'));

    $get_lead_by_id = array('field'=>'id', 'operator'=>'=', 'values'=>array($_GET['id']));

    // This calls the webservice's getLeads.
    // The last two parameters are for paging (which page, how many results per page max)
    $leads = $client->get_leads(array($get_lead_by_id)); // , $get_lead_filter, $get_deleted_filter));

    if (count($leads) <= 0) {
    // Create a new lead
    $lead_info['first_name'] = $first_name; // First Name
    $lead_info['last_name'] = $last_name; // Last Name
    $lead_info['email'] = $email; // Email
    $lead_info['phone'] = $phone; // Phone
    $lead_info['customFields_400'] = $alt_phone; // Alternate Phone
    $lead_info['customFields_41'] = $home_value; // Estimated Home Value
    $lead_info['customFields_37'] = $first_mortgage_balance; // First Mortagage Balance
    $lead_info['customFields_39'] = $first_mortgage_type; // First Mortagage Type
    $lead_info['customFields_43'] = $mortgage_years; // Mortgage Years Remaining
    $lead_info['customFields_45'] = $second_mortgage; // Second Mortgage Balance
    $lead_info['customFields_49'] = $credit_card_debt; // Total Credit Card Debt
    $lead_info['customFields_51'] = $available_credit; // Total Available Credit
    $lead_info['customFields_408'] = $auto_loans; // Auto Loans
    $lead_info['customFields_410'] = $student_loans; // Student Loans
    $lead_info['customFields_412'] = $timeshare_loans; // Timeshare Loans
    $lead_info['customFields_414'] = $recreational_vehicles; // Recreational Vehicle Loans
    $lead_info['customFields_416'] = $other_mortgages; // Other Mortgages
    $lead_info['customFields_418'] = $personal_loans; // Personal Loans
    $lead_info['customFields_420'] = $medical_loans; // Medical Loans
    $lead_info['customFields_422'] = $tax_debts; // Tax Debts
    $lead_info['customFields_424'] = $other_debt; // Other Debt
    $lead_info['customFields_53'] = $cash_flow; // How would you describe your cash flow?
    $lead_info['customFields_426'] = $make_your_payments; // Are you able to make all of your payments?
    $lead_info['customFields_526'] = $credit_for_payments; // Are you using savings or other credit cards to make your payments?
    $lead_info['customFields_57'] = $job_title; // What is your job title?
    $lead_info['customFields_63'] = $gross_income; // What is your gross monthly income?
    $lead_info['customFields_430'] = $net_income; // What is your approximate net monthly income (take-home after taxes, etc)
    $lead_info['customFields_65'] = $often_paid; // How often are you paid?
    $lead_info['customFields_721'] = $do_you_have_a_spouse; // Do you have a spouse or significant other you live with?
    $lead_info['assistant_first_name'] = $spouse_first_name; // Spouse First Name
    $lead_info['assistant_last_name'] = $spouse_last_name; // Spouse Last Name
    $lead_info['customFields_432'] = $spouse_job_title; // Spouse Job Title
    $lead_info['customFields_434'] = $spouse_gross_income; // Spouse Gross Monthly Income
    $lead_info['customFields_436'] = $spouse_net_income; // Spouse Net Monthly Income
    $lead_info['customFields_438'] = $spouse_often_paid; // Spouse Pay Frequency
    $lead_info['customFields_440'] = $other_monthly_income; // Any Other Monthly Income?
    $lead_info['customFields_67'] = $do_you_get_a_tax_refund;// Do you typically get a Federal Tax refund each year?es
    $lead_info['customFields_69'] = $much_your_tax_refund; // How much is your typical tax refund amount?
    $lead_info['customFields_442'] = $checking_balance; // Checking Account Balance
    $lead_info['customFields_444'] = $savings_balance; // Savings Account Balance
    $lead_info['customFields_446'] = $investment_balance; // Investment Account Balance
    $lead_info['customFields_448'] = $retirement_balance; // Retirement Account Balance
    $lead_info['customFields_452'] = $other_asset_value; // Other Assets ($ Value)
    $lead_info['customFields_454'] = $other_asset_description;// Other Assets Description
    $lead_info['customFields_460'] = $when_debt_free; // In what year do you plan to be debt free?
    $lead_info['customFields_458'] = $current_age; // What is your current age?
    $lead_info['customFields_462'] = $spouse_current_age; // What is your spouse's current age?
    $lead_info['customFields_516'] = $notes; // Notes or Comments
    $lead_info['customFields_394'] = $form; // Lead Sub Type

    // Add the lead
    $lead_id = $client->add_lead($lead_info);
    } else {
    $lead_id = $leads[0]->id;
    $updated_info = array();
    $updated_info['id'] = $lead_id;
    $updated_info['first_name'] = $first_name; // First Name
    $updated_info['last_name'] = $last_name; // Last Name
    $updated_info['email'] = $email; // Email
    $updated_info['phone'] = $phone; // Phone
    $updated_info['customFields_400'] = $alt_phone; // Alternate Phone
    $updated_info['customFields_41'] = $home_value; // Estimated Home Value
    $updated_info['customFields_37'] = $first_mortgage_balance; // First Mortagage Balance
    $updated_info['customFields_39'] = $first_mortgage_type; // First Mortagage Type
    $updated_info['customFields_43'] = $mortgage_years; // Mortgage Years Remaining
    $updated_info['customFields_45'] = $second_mortgage; // Second Mortgage Balance
    $updated_info['customFields_49'] = $credit_card_debt; // Total Credit Card Debt
    $updated_info['customFields_51'] = $available_credit; // Total Available Credit
    $updated_info['customFields_408'] = $auto_loans; // Auto Loans
    $updated_info['customFields_410'] = $student_loans; // Student Loans
    $updated_info['customFields_412'] = $timeshare_loans; // Timeshare Loans
    $updated_info['customFields_414'] = $recreational_vehicles; // Recreational Vehicle Loans
    $updated_info['customFields_416'] = $other_mortgages; // Other Mortgages
    $updated_info['customFields_418'] = $personal_loans; // Personal Loans
    $updated_info['customFields_420'] = $medical_loans; // Medical Loans
    $updated_info['customFields_422'] = $tax_debts; // Tax Debts
    $updated_info['customFields_424'] = $other_debt; // Other Debt
    $updated_info['customFields_53'] = $cash_flow; // How would you describe your cash flow?
    $updated_info['customFields_426'] = $make_your_payments; // Are you able to make all of your payments?
    $updated_info['customFields_526'] = $credit_for_payments; // Are you using savings or other credit cards to make your payments?
    $updated_info['customFields_57'] = $job_title; // What is your job title?
    $updated_info['customFields_63'] = $gross_income; // What is your gross monthly income?
    $updated_info['customFields_430'] = $net_income; // What is your approximate net monthly income (take-home after taxes, etc)
    $updated_info['customFields_65'] = $often_paid; // How often are you paid?
    $updated_info['customFields_721'] = $do_you_have_a_spouse; // Do you have a spouse or significant other you live with?
    $updated_info['assistant_first_name'] = $spouse_first_name; // Spouse First Name
    $updated_info['assistant_last_name'] = $spouse_last_name; // Spouse Last Name
    $updated_info['customFields_432'] = $spouse_job_title; // Spouse Job Title
    $updated_info['customFields_434'] = $spouse_gross_income; // Spouse Gross Monthly Income
    $updated_info['customFields_436'] = $spouse_net_income; // Spouse Net Monthly Income
    $updated_info['customFields_438'] = $spouse_often_paid; // Spouse Pay Frequency
    $updated_info['customFields_440'] = $other_monthly_income; // Any Other Monthly Income?
    $updated_info['customFields_67'] = $do_you_get_a_tax_refund;// Do you typically get a Federal Tax refund each year?es
    $updated_info['customFields_69'] = $much_your_tax_refund; // How much is your typical tax refund amount?
    $updated_info['customFields_442'] = $checking_balance; // Checking Account Balance
    $updated_info['customFields_444'] = $savings_balance; // Savings Account Balance
    $updated_info['customFields_446'] = $investment_balance; // Investment Account Balance
    $updated_info['customFields_448'] = $retirement_balance; // Retirement Account Balance
    $updated_info['customFields_452'] = $other_asset_value; // Other Assets ($ Value)
    $updated_info['customFields_454'] = $other_asset_description;// Other Assets Description
    $updated_info['customFields_460'] = $when_debt_free; // In what year do you plan to be debt free?
    $updated_info['customFields_458'] = $current_age; // What is your current age?
    $updated_info['customFields_462'] = $spouse_current_age; // What is your spouse's current age?
    $updated_info['customFields_516'] = $notes; // Notes or Comments
    $updated_info['customFields_394'] = $form; // Lead Sub Type

    $updated_id = $client->update_lead($updated_info);
    }
    }

    class IS {

    public $url = null;
    public $curl = null;

    public function __construct($url) {
    $this->url = $url;
    $this->curl = curl_init();
    curl_setopt($this->curl, CURLOPT_URL, $url);
    curl_setopt($this->curl, CURLOPT_COOKIESESSION, TRUE);
    curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($this->curl, CURLOPT_COOKIEFILE, "cookies.txt");
    curl_setopt($this->curl, CURLOPT_COOKIEJAR, "cookies.txt");
    curl_setopt($this->curl, CURLOPT_POST, 1);
    }

    public function login($username, $password, $token) {
    return $this->request(array('operation' => 'login', 'parameters' => array($username, $password, $token)));
    }

    public function add_lead($lead_info) {
    return $this->request(array('operation' => 'addLead', 'parameters' => array($lead_info)));
    }

    public function get_leads($filters, $page=0, $limit=100) {
    return json_decode($this->request(array('operation' => 'getLeads', 'parameters' => array($filters, $page, $limit))));
    }

    public function delete_lead($id) {
    return $this->request(array('operation' => 'deleteLead', 'parameters' => array($id)));
    }

    public function update_lead($lead_info) {
    return $this->request(array('operation' => 'updateLead', 'parameters' => array($lead_info)));
    }

    public function request($data) {
    curl_setopt($this->curl, CURLOPT_POSTFIELDS, json_encode($data));
    $content = curl_exec($this->curl);
    return $content;
    }

    }
    // END No More Mortgage - Form Post

    Posted 12 years ago on Wednesday November 30, 2011 | Permalink
  2. While I can't tell you exactly what you need to get your code working, that is too involving for standard support and enters consulting and customization territory.

    However, I can give you a high level overview of what you need to do.

    You need to use the gform_after_submission hook to execute your custom code when the form is submitted. The gform_after_submission hook runs after everything has been completed and the form entry has been created. This hook gives you access to the entry object containing all of the data submitted in the form. This hook is documented here:

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    You would have to use this hook and execute your code within it and then by accessing the entry object populate the field values wherever they need to go in your code to interact with your CRM's API.

    You would place your custom code either in your themes functions.php file OR create your own custom plugin to contain your custom code that you then activate (more ideal).

    This does require knowledge of how to use WordPress hooks/filters and while a form specific implementation isn't an extremely complex customization, it isn't a simple one either.

    If you aren't familiar enough with PHP, WordPress hook/filter usage or Gravity Forms you may need to hire a developer to implement this customization for you.

    Posted 12 years ago on Wednesday November 30, 2011 | Permalink
  3. Can you explain more on the create custom plugin to contain my custom code to integrate with a 3rd party? what would be its advantages over adding it to function.php?

    Thanks
    Greg

    Posted 10 years ago on Tuesday May 14, 2013 | Permalink