Bluelink
Overview
Bluelink is an online tool for connecting various digital software tools used by campaigns and movement groups in the political and non-profit space so you can sync data between them. This integration currently supports sending your structured person data and related tags to Bluelink via the Bluelink Webhook API, after which you can use Bluelink’s UI to send to any of their supported tools. If you don’t see a tool you would like to connect to, please reach out at hello@bluelink.org to ask them to add it.
Note
- Authentication
If you don’t have a Bluelink account please complete the form on the Bluelink website or email them at hello@bluelink.org. To get connection credentials select Bluelink Webhook from the apps menu. If you don’t see this option, you may need to ask an account administrator to do this step for you.
The credentials are automatically embedded into a one time secret link in case they need to be sent to you. Open the link to access the user and password.
Quickstart
To instantiate a class, you can either pass in the user and password token as arguments or set them in the BLUELINK_WEBHOOK_USER and BLUELINK_WEBHOOK_PASSWORD environment variables.
from parsons.bluelink import Bluelink
# First approach: Use API credentials via environmental variables
bluelink = Bluelink()
# Second approach: Pass API credentials as arguments
bluelink = Bluelink('username', 'password')
You can upsert person data by directly using a BluelinkPerson object:
from parsons.bluelink import Bluelink, BluelinkPerson, BluelinkIdentifier
# create the person object
person = BluelinkPerson(identifiers=[BluelinkIdentifier(source="SOURCE_VENDOR", identifier="ID")], given_name="Jane", family_name="Doe")
# use the bluelink connector to upsert
source = "MY_ORG_NAME"
bluelink.upsert_person(source, person)
You can bulk upsert person data via a Parsons Table by providing a function that takes a row and outputs a BluelinkPerson:
from parsons.bluelink import Bluelink, BluelinkPerson, BluelinkIdentifier
# a function that takes a row and returns a BluelinkPerson
def row_to_person(row):
return BluelinkPerson(identifiers=[BluelinkIdentifier(source="SOURCE_VENDOR", identifier=row["id"])],
given_name=row["firstName"], family_name=row["lastName"])
# a parsons table filled with person data
parsons_tbl = get_data()
# call bulk_upsert_person
source = "MY_ORG_NAME"
bluelink.bulk_upsert_person(source, parsons_tbl, row_to_person)
API
- class parsons.bluelink.Bluelink(user=None, password=None)[source]
Instantiate a Bluelink connector. Allows for a simple method of inserting person data to Bluelink via a webhook. # see: https://bluelinkdata.github.io/docs/BluelinkApiGuide#webhook
- Args::
- user: str
Bluelink webhook user name.
- password: str
Bluelink webhook password.
- upsert_person(source, person=None)[source]
Upsert a BluelinkPerson object into Bluelink. Rows will update, as opposed to being inserted, if an existing person record in Bluelink has a matching BluelinkIdentifier (same source and id) as the BluelinkPerson object passed into this function.
- Args:
- source: str
String to identify that the data came from your system. For example, your company name.
- person: BluelinkPerson
A BluelinkPerson object. Will be inserted to Bluelink, or updated if a matching record is found.
- Returns:
int An http status code from the http post request to the Bluelink webhook.
- bulk_upsert_person(source, tbl, row_to_person)[source]
Upsert all rows into Bluelink, using the row_to_person function to transform rows to BluelinkPerson objects.
- Args:
- source: str
String to identify that the data came from your system. For example, your company name.
- tbl: Table
A parsons Table that represents people data.
- row_to_person: Callable[[dict],BluelinkPerson]
A function that takes a dict representation of a row from the passed in tbl and returns a BluelinkPerson object.
- Returns:
list[int] A list of https response status codes, one response for each row in the table.