Hustle

Overview

Hustle is a peer to peer texting communication platform. This Parsons integration with the the Hustle v1 API provides methods for fetching agents, organizations, groups, leads, and tags, as well as creating and updating agents and leads.

Quick Start

To instantiate the Hustle class, you can either store your Hustle client ID and secret as environmental variables (HUSTLE_CLIENT_ID and HUSTLE_CLIENT_SECRET, respectively) or pass them in as keyword arguments:

from parsons import Hustle

# First approach: Use API credentials via environmental variables
hustle = Hustle()

# Second approach: Pass API credentials as arguments
hustle = Hustle(client_id='MYID', client_secret='MYSECRET')

# Export your groups to a csv
tbl = hustle.get_groups(organization_id='ORGID')
tbl.to_csv('my_hustle_groups.csv')

# Export organizations to Redshift
tbl.get_organizations().to_redshift('hustleschema.hustle_organizations')

# Import leads from a csv
leads = Table.from_csv('my_leads.csv')
group_id = 'MYGROUP'
hustle.create_leads(leads, group_id)

API

class parsons.Hustle(client_id: str | None = None, client_secret: str | None = None)[source]

Instantiate Hustle Class

Parameters:
  • client_id – The client id provided by Hustle. Not required if HUSTLE_CLIENT_ID env variable set.

  • client_secret – The client secret provided by Hustle. Not required if HUSTLE_CLIENT_SECRET env variable set.

Returns:

Hustle Class

get_agents(group_id: str) Table[source]

Get a list of agents.

Parameters:

group_id – str The group id.

Returns:

Parsons Table

See Parsons Table for output options.

get_agent(agent_id: str) dict[source]

Get a single agent.

Parameters:

agent_id – str The agent id.

Returns:

dict

create_agent(group_id: str, name: str, full_name: str, phone_number: str, send_invite: bool = False, email: str | None = None) dict[source]

Create an agent.

Parameters:
  • group_id – str The group id to assign the agent.

  • name – str The name of the agent.

  • full_name – str The full name of the agent.

  • phone_number – str The valid phone number of the agent.

  • send_invite – boolean Send an invitation to the agent.

  • email – The email address of the agent.

Returns:

dict

update_agent(agent_id: str, name: str | None = None, full_name: str | None = None, send_invite: bool = False) dict[source]

Update an agent.

Parameters:
  • agent_id – str The agent id.

  • name – str The name of the agent.

  • full_name – str The full name of the agent.

  • phone_number – str The valid phone number of the agent.

  • send_invite – boolean Send an invitation to the agent.

Returns:

dict

get_organizations() Table[source]

Get organizations.

Returns:

Parsons Table

See Parsons Table for output options.

get_organization(organization_id: str) dict[source]

Get a single organization.

Parameters:

organization_id – str The organization id.

Returns:

dict

get_groups(organization_id: str) Table[source]

Get a list of groups.

Parameters:

organization_id – str

Returns:

Parsons Table

See Parsons Table for output options.

get_group(group_id: str) dict[source]

Get a single group.

Parameters:

group_id – str The group id.

create_group_membership(group_id: str, lead_id: str) dict[source]

Add a lead to a group.

Parameters:
  • group_id – str The group id.

  • lead_id – str The lead id.

get_lead(lead_id: str) dict[source]

Get a single lead.

Parameters:

lead_id – str The lead id.

Returns:

dict

get_leads(organization_id: str | None = None, group_id: str | None = None) Table[source]

Get leads metadata. One of organization_id and group_id must be passed as an argument. If both are passed, an error will be raised.

Parameters:
  • organization_id – str The organization id.

  • group_id – str The group id.

Returns:

Parsons Table

See Parsons Table for output options.

create_lead(group_id: str, phone_number: str, first_name: str, last_name: str | None = None, email: str | None = None, notes: str | None = None, follow_up: str | None = None, custom_fields: dict | None = None, tag_ids: list | None = None) dict[source]

Create a lead.

Parameters:
  • group_id – str The group id to assign the leads.

  • first_name – str The first name of the lead.

  • phone_number – str The phone number of the lead.

  • last_name – str The last name of the lead.

  • email – str The email address of the lead.

  • notes – str The notes for the lead.

  • follow_up – str Follow up for the lead.

  • custom_fields – dict A dictionary of custom fields, with key as the value name, and value as the value.

  • tag_ids – list A list of tag ids.

Returns:

None

create_leads(table: Table, group_id: str | None = None) Table[source]

Create multiple leads. All unrecognized fields will be passed as custom fields. Column names must map to the following names.

Column Name

Valid Column Names

first_name

first_name, first, fn, firstname

last_name

last_name, last, ln, lastname

phone_number

phone_number, phone, cell, phonenumber, cell_phone, cellphone

email

email, email_address, emailaddress

follow_up

follow_up, followup

Parameters:
  • table – Parsons table Leads

  • group_id – The group id to assign the leads. If None, must be passed as a column value.

Returns:

A table of created ids with associated lead id.

update_lead(lead_id: str, first_name: str | None = None, last_name: str | None = None, email: str | None = None, global_opt_out: bool | None = None, notes: str | None = None, follow_up: str | None = None, tag_ids: list | None = None) dict[source]

Update a lead.

Parameters:
  • lead_id – str The lead id

  • first_name – str The first name of the lead

  • last_name – str The last name of the lead

  • email – str The email address of the lead

  • global_opt_out – boolean Opt out flag for the lead

  • notes – str The notes for the lead

  • follow_up – str Follow up for the lead

  • tag_ids – list Tags to apply to lead

Returns:

dict

get_tags(organization_id: str) Table[source]

Get an organization’s tags.

Parameters:

organization_id – str The organization id.

Returns:

Parsons Table

See Parsons Table for output options.

get_tag(tag_id: str) dict[source]

Get a single tag.

Parameters:

tag_id – str The tag id.

Returns:

dict

get_custom_fields(organization_id: str) Table[source]

Retrieve an organization’s custom fields.

Parameters:

organization_id – str The organization id.

Returns:

Parsons Table

See Parsons Table for output options.

create_custom_field(organization_id: str, name: str, agent_visible: bool | None = None) dict[source]

Create a custom field.

Parameters:
  • organization_id – str The organization id.

  • name – str The name of the custom field. Restricted to letters, numbers, and underscores. Minimum of 2 characters, maximum of 40.

  • agent_visible – bool Optional. true represents that the custom field is visible to agents. false means that only admins can see it.

Returns:

dict

The newly created custom field