How to sync InfusionSoft’s contacts in a Rails application?
How to sync InfusionSoft’s contacts in a Rails application?
What is Infusionsoft?
Infusionsoft is a CRM software used to handle the services which are going to be provided to the customers. CRM, Marketing and Sales Automation-Infusionsoft web-based solution has customer relationship management features that enable users to organize their contacts, and find everything about their leads and customers, all in one place. Users can import and organize their contacts through tagging and segmentation. They can collect data about their behaviors, score them and prioritize the hottest leads. Marketing processes can be streamlined by automating lead capture and follow-up. Users can send timely messages relevant to their customers’ needs based on triggers. Sales automation features include custom quotes and orders, and pipeline management that enable teams to spend less time working deals and more time closing them.
Why Infusionsoft?
Infusionsoft is a platform, through software and service, that can help solve the problems that small businesses usually encounter. Small businesses do not have as much resources as larger enterprises. Therefore, they should have the tools, insights and network that allow them to spend less time on tasks, so they can focus on strategies and processes that make them more competitive and grow faster.
There are some specific features of the InfusionSoft as
- Affiliate
- Contacts
- Appointments
- Campaigns
- Company
- Emails
- E-Commerce
- Orders
- Order items
- Payment
- Files
- Merchants
- Countries
- Products
- Tags
- Note
- Task
Contacts
Contacts are the people on the InfusionSoft account which will be having above data associated with them. Contacts are divided into information in the following way:
- General: It stores the most pertinent contact information: company, job title, phone number, email address, website, and local weather. It also displays a tag summary. There is an envelope icon that opens the email client so you can quickly send a personal email.
- Address: There will be multiple address for each contact. Billing address is stored in the general tab. Users can store up to two more addresses within the address tab.
- Additional Info: This information contains phone numbers, birthdays, spouse name, etc.
- Person Notes: In this user can add notes about a person that do not need to be date/time stamped.
- Custom Fields: User can have multiple custom tabs; each labeled with a different custom label.
- Tag: Tags can be applied to this contact record. Users can also manually add or remove tags from the contact record.
- Linked Contacts: It displays relationships between contacts in system by linking them together and allows users to create new links.
- Access Privileges: This tab displays relationships you’ve established between contacts in your system by linking them together and allows you to create new links (e.g. links between family members.)
There are two steps to sync the contacts in the rails application as:
- How to create an access token using the Infusionsoft developer keys?
- How to sync the InfusionSoft contact in the rails application.
How to create an access token using the Infusionsoft developer keys?
- Create a developer account from the Infusionsoft developer portal (https://developer.infusionsoft.com/).
- After creating the developer account on the InfusionSoft portal add an application in the application’s section.
- Provide the required details while creating the application.
- After creating an application user will be able to see the developer keys in the keys menu.
- The user will find the Client ID and Client Secret under this section for the created application.
- Create a primary account for the InfusionSoft from the Infusionsoft website. (https://signin.infusionsoft.com/)
- After creating the account login with the credentials for creating the access token.
- After signing in their will be an option i.e. “API Access” after clicking on that link.
- One modal will be open asking for the developer’s keys i.e. Client ID and Client Secret as mentioned in the image.
- Provide the developer keys and generate the Access token and refresh token for the primary account.
- In this way access token and refresh token is generated successfully.
How to sync the InfusionSoft contact in the rails application?
- Store the access token and refresh token in the database for the first time.
- Access token for the InfusionSoft account expires in 24 hours so it is necessary to get another access token.
- This can be accomplished using the refresh token. So use the old refresh token to get the new access token.
- Create a rails POST API call to get a new access token using a refresh token. It will provide the response with the new access token along with a new refresh token.
- Before making the API call it is necessary to convert the client ID and client secret in base64.
- Screenshot for the API POST call is mentioned below.
- Replace the old refresh and access token with the new one and used new refresh token for the next refresh token API call.
- The next step is to store the user’s details to InfusionSoft account for creating the new contact. This can be done using “infusionsoft” gem.
- Insert the gem for the Infusionsoft integration in the Gemfile. Documentation for the gem will on the link (https://github.com/nateleavitt/infusionsoft)
-
gem 'infusionsoft'
- Before using the methods of the Infusionsoft it is important to set the API key in the Infusionsoft.rb initializer file
- All the configuration of the InfusionSoft gem is configured in the “infusionsoft.rb” file.
Infusionsoft.api_key = access_token - How to create contact on the Infusionsoft account using access token? Detailed documentation of the infusionsoft gem is available on the link. (https://www.rubydoc.info/gems/infusionsoft/1.1.8/Infusionsoft)
contact_id = Infusionsoft.contact_add({:FirstName => user['first_name'], :LastName => user['last_name'], :Email => user['email']})
- Above API call will create the contact on the Infusionsoft account using parameters which are passed to it.
- It will return the contact ID created on the Infusionsoft account.
- It is also possible to check whether the contact is present or not on the Infusionsoft account using email ID as shown below.
user_details = Infusionsoft.contact_find_by_email(user['email'] , ['FirstName', 'LastName', 'Email', 'Id'])
- Above API will return the details of the contact whose email ID is passed in the method.
- Whichever the details are required can be passed to the second parameter.
- Other documentation for Infusionsoft APIs are available here.