Skip to content

Instantly share code, notes, and snippets.

@torpio
torpio / FLG 360 Webhook Create Event.js
Last active August 29, 2015 14:07
Takes a webhook from FLG 360 and adds an event to the lead.
/*
This script receives a webhook from FLG 360 and creates an event. You can choose the description of the event, it's date/time & duration and the user it should be assigned to.
You can use curly bracket templating to insert any {{value}} from the FLG 360 webhook, for example {{data1}}.
For the event duration setting, use this notation:
* ```15m``` (15 minutes)
* ```2h``` (2 hours)
@torpio
torpio / FLG 360 Webhook Create Task.js
Last active August 29, 2015 14:05
Takes a webhook from FLG 360 and adds a task to the lead.
/*
This script receives a webhook from FLG 360 and creates a task. You can choose the description of the task, its due date/time and the user it should be assigned to.
You can use curly bracket templating to insert any {{value}} from the FLG 360 webhook, for example {{data1}}.
*/
var settings = {};
@torpio
torpio / FLG 360 Lead Duplicator.js
Created July 24, 2014 10:25
Takes a webhook from FLG 360 and duplicates the lead.
/*
This script receives a webhook from FLG 360 and copies the lead (usually into another lead group).
By default the copied lead is identical, but you can change how data is saved using 'Extra Field Mappings'.
For example, to save ```data1``` into ```data2``` on the copied lead, use:
{
"data2": "{{data1}}"
}
@torpio
torpio / FLG to FreshBooks Client.js
Created May 23, 2014 12:07
Takes a webhook from FLG 360 and creates a new client in FreshBooks.
/*
This script receives a webhook from FLG 360 and creates a new client in FreshBooks **only if** a client with the same email address doesn't already exist.
If no email address is held in FLG 360, nothing will happen.
*/
if (request.body.email) {
// First check if the client already exists
// First we fetch the logo that we'll embed in the email
http.get({ uri: 'https://s3-eu-west-1.amazonaws.com/torpio-logos/torpio_wide_560.png', encoding: null }, function (error, response, body) {
if (error || response.statusCode !== 200) {
log.error(error, response, body);
} else {
// Gather some values that we'll use in our email templates
var values = {
name: 'Fred',
from: 'Me'
};
@torpio
torpio / FLG 360 to VICIDIAL.js
Created April 3, 2014 08:38
Takes a webhook from FLG 360 and creates a record in a VICIDIAL dialler.
/*
This script receives a webhook from FLG 360 and creates a lead in any [VICIDIAL](http://www.vicidial.org) dialer (as long as it's accessible over the internet).
By default, the lead's title, name, address and main phone number are sent across to the dialer, but you
can map more fields using 'Extra Field Mappings'. For example, to map a dialer field ```mortgageamount```
to FLG 360's ```data5``` field, use:
{
"mortgageamount": "{{data5}}"
@torpio
torpio / FLG 360 Webhook Update.js
Created March 27, 2014 12:30
Takes a webhook from FLG 360 and updates the same lead.
/*
This script receives a webhook from FLG 360 and updates the same lead based on the values received.
For example, to update the field ```data1``` with the date/time of the webhook, you might use a field mapping like this:
{
"data1": "{{eventdatetime}}"
}
@torpio
torpio / FLG 360 to DXI Dialer.js
Created March 25, 2014 16:03
Takes a webhook from FLG 360 and creates a record in a DXI dialler.
/*
This script receives a webhook from FLG 360 and creates a record in any dialer based on DXI. These include:
- [Difference Dialer](http://www.differencecorp.com/products-and-services/dialler-technology/)
- [Easycallnow](http://www.easycallnow.net)
By default, the lead's name, address and phone number(s) are sent across to the dialer, but you
can map more fields using 'Extra Field Mappings'. For example, to map a dialer field ```mortgageamount```
to FLG 360's ```data5``` field, use:
@torpio
torpio / Insightly Opportunities to WebMerge.js
Created March 20, 2014 09:58
Send opportunities with a specific tag to WebMerge, along with contact, organisation and user merge data.
var settings = {};
// Torpio will only merge opportunities that have this tag.
settings.INSIGHTLY_TAG = 'merge'
// The full merge URL copied from your WebMerge account
settings.MERGE_URL = 'https://www.webmerge.me/merge/12345/iqtabg'
function fetch(url, key, n, data, ok) {
n--;
@torpio
torpio / FLG 360 Webhook to MailChimp List.coffee
Created February 21, 2014 17:02
Receives an FLG 360 webhook and adds a subscriber to a MailChimp list.
# CoffeeScript
###
This script receives a webhook from FLG 360 and adds the lead's email address to MailChimp. Here's how to use:
1. In FLG 360, go to 'Settings > Lead Groups > Lead Types > Edit' and add a webhook to this script's webhook URL (below) on any event ('Received' for example).
2. Type in your MailChimp list name (case sensitive).
3. Authorize your MailChimp account by clicking the red 'Authorize' button.
4. All done, switch the script on and trigger the event in FLG 360 to make sure it works.