Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: a552842ada
Fetching contributors…

Cannot retrieve contributors at this time

103 lines (78 sloc) 3.718 kB

Web-To-Lead Capture Plugin for Fat Free CRM

This plugin shows how to implement Fat Free CRM application controller callback hook to capture lead data submitted from remote form. For more information about Fat Free CRM visit github.com/michaeldv/fat_free_crm/tree/master

Installation

The plugin installs just like any Ruby on Rails plugin packaged as git. Assuming that you have Fat Free CRM up and running:

$ ./script/install plugin git://github.com/michaeldv/crm_web_to_lead.git

The sample plugin will be installed in vendor/plugins/crm_web_to_lead directory.

Quick How To

To submit a lead remote form should POST two extra hidden fields to identify the user who will own the lead:

<input type="hidden" name="authorization" value="-- password_hash here --">
<input type="hidden" name="token" value="-- password_token here --">

Two more hidden fields specify redirection URLs to handle successful submissions and possible validation errors:

<input type="hidden" name="on_success" value="-- fuccess URL here --">
<input type="hidden" name="on_success" value="-- failure URL here --">

The following sample is a good start to build your own lead capture form.

<html>
<body>
  <form action="http://localhost:3000/leads/create" method="post">
    <input name="lead[first_name]" value="">
    <input name="lead[last_name]" value="">
    <input name="lead[source]" value="Web">
    <input name="authorization" value="?">
    <input name="token" value="?"
    <input name="on_success" value="http://www.yoursite.com/success">
    <input name="on_failure" value="http://www.yoursite.com/failure">
    <input type="submit" value="OK">
  </form
</body>
</html>

Replace question marks with the actual values of password_hash and password_token as set in users table. Successful lead submissions get logged in Rails log file.

Enjoy!

Alternative Signup with XML

To submit new leads via xml (useful for inline code submissions to a synced app or via AJAX). Default root xml element should be :“ffcrm”, this is required to ensure the parameters are checked correctly.

On source app :

#Required fields:
#access, do-not-call, first-name, last-name 
 xml = Builder::XmlMarkup.new
 xml.instruct!
 xml.ffcrm do
    xml.lead do
      xml.access "Public" #or Private 
      xml.address "1234 Sample Address", "nil" => "true"
      xml.tag!("alt-email", "", "nil" => "true")
      xml.tag!("assigned-to", "", "nil" => "true", "type"=>"integer")
      xml.blog "", "nil" => "true"
      xml.tag!("campaign-id", "", "nil" => "true", "type"=>"integer")
      xml.company "", "nil" => "true"  
      xml.tag!("do-not-call", "false", "type"=>"boolean")
      xml.email "foo.bar@here.com", "nil" => "true" 
      xml.tag!("first-name", "Foo")
      xml.tag!("last-name", "Bar")
      xml.mobile "", "nil" => "true"
      xml.phone "", "nil" => "true"
      xml.tag!("referred-by", "", "nil" => "true")
      xml.source "", "nil" => "true"
      xml.status "", "nil" => "true"
      xml.title "", "nil" => "true"
      xml.tag!("user-id", "", "type" => "integer", "nil" => "true") 
      xml.tag!("uuid", "", "nil" => "true")                               
    end
    xml.authorization "password_hash for user in Fat Free CRM"
    xml.token "password_salt for user in Fat Free CRM"       
 end

#Add to fat free CRM url = URI.parse('localhost:3000/leads.xml') request = Net::HTTP::Post.new(url.path) request.content_type = 'text/xml' request.body = xml.target! response = Net::HTTP.start(url.host, url.port) {|http| http.request(request)}


Copyright © 2009 by Michael Dvorkin, released under the MIT license.

Jump to Line
Something went wrong with that request. Please try again.