Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Strive class #572

Open
thebbennett opened this issue Aug 26, 2021 · 3 comments
Open

Add a Strive class #572

thebbennett opened this issue Aug 26, 2021 · 3 comments
Assignees
Labels
enhancement Impact - something should be added to or changed about Parsons that isn't causing a current breakage high priority Priority - addressing this is an urgent need for a broad swath of Parsons users new connector Work type - creating a new Parsons connector for a tool

Comments

@thebbennett
Copy link
Collaborator

Hello nerds,

Another vague and open ended issue, so my apologies, but it could be useful to have a wrapper for the Strive API in Parsons.

@neverett neverett added the new connector Work type - creating a new Parsons connector for a tool label Nov 3, 2021
@thebbennett
Copy link
Collaborator Author

Here's some code I wrote with the help of Strive staff to push data to Strive for a text campaign

def send_contacts_to_strive(df_for_strive):
    """
    Takes the data frame from the `prepare_data` function and sends each contact
    to Strive and adds them to the "EA API member" group.
    """

    if len(df_for_strive) != 0:
        print("New folk to welcome! Let's send to Strive. They'll handle any deduping.")

        strive_headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + strive_key}

        for index, row in df_for_strive.iterrows():
            phone_number = row['Phone']
            first_name = row['FirstName']
            if pd.isnull(first_name):
                first_name = "Friend"
            last_name = row['LastName']
            if pd.isnull(last_name):
                last_name = "Friend"
            payload = {
				    "phone_number": phone_number,
				    "campaign_id": campaign_id,
				    "first_name": first_name,
				    "last_name": last_name,
				    "opt_in": True,
				      "groups": [
				        {
				          "name": "EA API Member"
				        }
       				]
                    }
            response = requests.request("POST", 'https://api.strivedigital.org/members', headers = strive_headers, data = json.dumps(payload))
            if response.status_code == 201:
            	print(f"Successfully added: {first_name} {last_name}")
            else:
            	print(f"Was not able to add {first_name} {last_name} to Stive. Error: {response.status_code}")

    else:
    	print("No contacts to send to Strive.")

@thebbennett
Copy link
Collaborator Author

Here are some instructions related to automating text campaigns
https://github.com/sunrisedatadept/a-faster-welcome-text

This script works by sending contacts to an Automation flow we've set up in Strive. You must first send at least 1 contact to Strive via the API for this feature to be available. We are taking advantage of the fact that Strive never sends a welcome text to the same person.

  1. Navigate to the Automation section on the left sidebar in your campaign.
  2. Automations > API > Create API automation
  3. Name your automation
  4. Set the trigger to "New member is added via API"
  5. Choose the Flow
  6. Create your automation

@SorenSpicknall SorenSpicknall added the enhancement Impact - something should be added to or changed about Parsons that isn't causing a current breakage label Mar 17, 2022
@shaunagm
Copy link
Collaborator

Note that this in progress: #757

@shaunagm shaunagm added medium priority Priority - this doesn't need to be addressed immediately, but will broadly impact Parsons users high priority Priority - addressing this is an urgent need for a broad swath of Parsons users and removed medium priority Priority - this doesn't need to be addressed immediately, but will broadly impact Parsons users labels Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Impact - something should be added to or changed about Parsons that isn't causing a current breakage high priority Priority - addressing this is an urgent need for a broad swath of Parsons users new connector Work type - creating a new Parsons connector for a tool
Projects
None yet
Development

No branches or pull requests

4 participants