Daisychain¶
Overview¶
Daisychain is a digital organizing automation tool that allows organizers to string together automated digital outreach steps, similar to Zapier but designed specifically for digital organizing. The Parsons connector provides methods for finding contacts and triggering events through the Daisychain API.
This connector implements the people/match and actions endpoints of the Daisychain API, allowing you to find existing people records and post actions that can trigger automations.
Note
- Authentication
The Daisychain API uses API token authentication. You can generate your API token from your Daisychain account settings.
Quick Start¶
To instantiate the class, you can either pass in the API token as an argument or set the DAISYCHAIN_API_TOKEN environmental variable.
from parsons import Daisychain
# First approach: Use API credentials via environmental variables
dc = Daisychain()
# Second approach: Pass API credentials as arguments
dc = Daisychain(api_token='MY_API_TOKEN')
You can then call various endpoints:
# Find a person by email address
people = dc.find_person(email_address='person@example.com')
# Find a person by phone number
people = dc.find_person(phone_number='+15555551234')
# Find a person by email and phone (AND logic)
people = dc.find_person(email_address='person@example.com', phone_number='+15555551234')
# Post an action to trigger an automation
# This will create a new person if they don't exist, or associate the action with an existing person
person_id = dc.post_action(
email_address='person@example.com',
phone_number='+15555551234',
first_name='Jane',
last_name='Doe',
email_opt_in=True,
sms_opt_in=True,
action_data={'type': 'petition_signature', 'petition_id': '12345'}
)
# Use action_data with custom fields to trigger specific automations
# The action_data can contain any JSON and be matched in Daisychain automation builder
person_id = dc.post_action(
email_address='volunteer@example.com',
action_data={'event_type': 'volunteer_signup', 'event_id': 'canvass_2024'}
)
API¶
- class parsons.Daisychain(api_token: str)[source]¶
- request(endpoint: str, method: str, data_key: str, json: list | dict | None = None) list[dict][source]¶
Get request with pagination.
- find_person(email_address: str | None = None, phone_number: str | None = None) list[dict][source]¶
Find a person by email address and/or phone number.
If multiple parameters are provided, they will be combined with AND logic. All parameters are optional, but at least one must be provided.
- Parameters:
email_address (string) – Email address of the person to match. This is a case insensitive match. In Daisychain it is possible for multiple people records to have the same email address.
phone_number (string) – Phone number of the person to match. In Daisychain it is possible for multiple people records to have the same phone number. We will do our best to parse any string provided, but E.164 format is preferred
- Returns:
a list of person dictionaries
- post_action(email_address: str | None = None, phone_number: str | None = None, first_name: str | None = None, last_name: str | None = None, addresses: list[dict] | None = None, email_opt_in: bool = False, sms_opt_in: bool = False, action_data: dict | None = None) str[source]¶
Record an action on a person in Daisychain.
Actions are events that are associated with People. They’re things that people have done or things that have happened to them.
Actions of this kind have no defined schema and can contain any data that you want, represented as json. The actions will appear in the timeline view of the person they are associated with and can be used to trigger automations.
If used as the trigger for an automation it is possible to write a jmespath expression in the Daisychain automation builder to match against the data in the action. This can be used to filter automation executions based on the data you or another system provides. For example, you could create an action with a action_data field of {“type”: “donation”} and then use the jmespath expression action.type == ‘donation’ to match against it while authoring an automation. This feature can be used to create powerful automations that can be triggered by any external system that can make an API call.
Person Creation and Match
The action creation endpoint is designed to allow other systems to create actions for people in Daisychain without knowing in advance whether or not that person already exists.
It will create a person if one does not exist with the provided email or phone number. If a person does exist with the provided email or phone number, the action will be associated with that person. Daisychain matches on email and phone number in that order of priority. If different people exist with the provided email and phone number, the action will be associated with the person with the matching email.
- Returns:
person id (string)