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.
Note
- Authentication
Hustle uses the OAuth2 client credentials flow. Clients with a Hustle account can obtain the client ID and client secret needed to request a token which grants to access the Hustle API for 2 hours before expiring.
Warning: 10 failed attempts to generate an access token will result in a temporary block on your IP address, and 100 failed attempts in 24 hour results in a permanent ban.
- API Limits
There is a limit of 100 requests per second for endpoints returning resources.
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.hustle.Hustle(client_id: str | None = None, client_secret: str | None = None)[source]¶
Instantiate Hustle Class
- Parameters:
- Returns:
Hustle Class
- get_agents(group_id: str) Table[source]¶
Get a list of agents.
- Parameters:
group_id (str) – str The group id.
- Returns:
- Parsons Table
See Parsons Table for output options.
- Return type:
- 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) – str The group id to assign the agent.
name (str) – str The name of the agent.
full_name (str) – str The full name of the agent.
phone_number (str) – str The valid phone number of the agent.
send_invite (bool) – boolean Send an invitation to the agent.
email (str | None) – The email address of the agent.
- Returns:
dict
- Return type:
- update_agent(agent_id: str, name: str | None = None, full_name: str | None = None, send_invite: bool = False) dict[source]¶
Update an agent.
- Parameters:
- Returns:
dict
- Return type:
- get_organizations() Table[source]¶
Get organizations.
- Returns:
- Parsons Table
See Parsons Table for output options.
- Return type:
- get_groups(organization_id: str) Table[source]¶
Get a list of groups.
- Parameters:
organization_id (str) – str
- Returns:
- Parsons Table
See Parsons Table for output options.
- Return type:
- get_leads(organization_id: str | None = None, group_id: str | None = None) Table[source]¶
Get leads metadata. One of
organization_idandgroup_idmust be passed as an argument. If both are passed, an error will be raised.- Parameters:
- Returns:
- Parsons Table
See Parsons Table for output options.
- Return type:
- 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) – str The group id to assign the leads.
first_name (str) – str The first name of the lead.
phone_number (str) – str The phone number of the lead.
last_name (str | None) – str The last name of the lead.
email (str | None) – str The email address of the lead.
notes (str | None) – str The notes for the lead.
follow_up (str | None) – str Follow up for the lead.
custom_fields (dict | None) – dict A dictionary of custom fields, with key as the value name, and value as the value.
tag_ids (list | None) – list A list of tag ids.
- Returns:
None- Return type:
- 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,firstnamelast_name
last_name,last,ln,lastnamephone_number
phone_number,phone,cell,phonenumber,cell_phone,cellphoneemail
email,email_address,emailaddressfollow_up
follow_up,followup
- 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) – str The lead id
first_name (str | None) – str The first name of the lead
last_name (str | None) – str The last name of the lead
email (str | None) – str The email address of the lead
global_opt_out (bool | None) – boolean Opt out flag for the lead
notes (str | None) – str The notes for the lead
follow_up (str | None) – str Follow up for the lead
tag_ids (list | None) – list Tags to apply to lead
- Returns:
dict
- Return type:
- get_tags(organization_id: str) Table[source]¶
Get an organization’s tags.
- Parameters:
organization_id (str) – str The organization id.
- Returns:
- Parsons Table
See Parsons Table for output options.
- Return type:
- get_custom_fields(organization_id: str) Table[source]¶
Retrieve an organization’s custom fields.
- Parameters:
organization_id (str) – str The organization id.
- Returns:
- Parsons Table
See Parsons Table for output options.
- Return type:
- create_custom_field(organization_id: str, name: str, agent_visible: bool | None = None) dict[source]¶
Create a custom field.
- Parameters:
organization_id (str) – str The organization id.
name (str) – str The name of the custom field. Restricted to letters, numbers, and underscores. Minimum of 2 characters, maximum of 40.
agent_visible (bool | None) – 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
- Return type: