-
Notifications
You must be signed in to change notification settings - Fork 189
Add Salesforce NPSP integration #547
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| layout: integration | ||
| name: Salesforce NPSP | ||
| description: Ingest Salesforce Nonprofit Success Pack (NPSP) donor records, gift histories, and engagement metrics as Documents for RAG. | ||
| authors: | ||
| - name: Shivam Ashokbhai Lalakiya | ||
| socials: | ||
| github: shivamlalakiya | ||
| pypi: https://pypi.org/project/haystack-salesforce-npsp | ||
| repo: https://github.com/PhilanthroPy-Project/salesforce-npsp-integrations | ||
| type: Data Ingestion | ||
| report_issue: https://github.com/PhilanthroPy-Project/salesforce-npsp-integrations/issues | ||
| logo: /logos/salesforce-npsp.png | ||
| version: Haystack 2.0 | ||
| toc: true | ||
| --- | ||
|
|
||
| ### Table of Contents | ||
|
|
||
| - [Overview](#overview) | ||
| - [Installation](#installation) | ||
| - [Usage](#usage) | ||
| - [License](#license) | ||
|
|
||
| ## Overview | ||
|
|
||
| `haystack-salesforce-npsp` provides a Haystack 2.x component, | ||
| `SalesforceNPSPFetcher`, that ingests donor data from Salesforce | ||
| [Nonprofit Success Pack (NPSP)](https://www.salesforce.org/nonprofit/nonprofit-success-pack/) | ||
| organizations as Haystack `Document`s — no Airbyte and no CDK required. | ||
|
|
||
| Unlike a generic Salesforce connector that returns raw JSON, this component is | ||
| **NPSP-aware**: it understands the `npo02__` and `npsp__` field prefixes and | ||
| produces human-readable donor profiles (lifetime giving, gift history, soft | ||
| credits, planned giving, engagement) that an LLM can reason over directly. An | ||
| optional `affinity_score_fn` injects an ML-derived donor propensity score into | ||
| each document's metadata at fetch time. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install haystack-salesforce-npsp | ||
| ``` | ||
|
|
||
| Set your Salesforce credentials as environment variables: | ||
|
|
||
| ```bash | ||
| export SF_USERNAME="you@yourorg.org" | ||
| export SF_PASSWORD="your_password" | ||
| export SF_TOKEN="your_security_token" | ||
| ``` | ||
|
Comment on lines
+47
to
+51
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is providing a username and password a recommended auth schema for Salesforce? It's pretty unusual.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair question — the current implementation ( |
||
|
|
||
| This is the standard SOAP username-password-security-token flow supported by | ||
| [`simple-salesforce`](https://github.com/simple-salesforce/simple-salesforce), | ||
| suited to trusted server-side ingestion jobs like this one. OAuth 2.0 support | ||
| may be added in a future release. | ||
|
|
||
| ## Usage | ||
|
|
||
| Fetch donors on their own: | ||
|
|
||
| ```python | ||
| from haystack_salesforce_npsp import SalesforceNPSPFetcher | ||
|
|
||
| fetcher = SalesforceNPSPFetcher( | ||
| soql_filter="npo02__TotalOppAmount__c > 5000", | ||
| limit=500, | ||
| ) | ||
| documents = fetcher.run()["documents"] | ||
| # documents[0].content -> narrative donor profile | ||
| # documents[0].meta -> {"donor_id": ..., "total_gift_amount": ..., "source": "salesforce_npsp", ...} | ||
| ``` | ||
|
|
||
| In an indexing pipeline: | ||
|
|
||
| ```python | ||
| from haystack import Pipeline | ||
| from haystack.components.embedders import SentenceTransformersDocumentEmbedder | ||
| from haystack.components.writers import DocumentWriter | ||
| from haystack.document_stores.in_memory import InMemoryDocumentStore | ||
| from haystack_salesforce_npsp import SalesforceNPSPFetcher | ||
|
|
||
| store = InMemoryDocumentStore() | ||
| p = Pipeline() | ||
| p.add_component("fetch", SalesforceNPSPFetcher(soql_filter="npo02__TotalOppAmount__c > 5000")) | ||
| p.add_component("embed", SentenceTransformersDocumentEmbedder()) | ||
| p.add_component("write", DocumentWriter(document_store=store)) | ||
| p.connect("fetch.documents", "embed.documents") | ||
| p.connect("embed.documents", "write.documents") | ||
| p.run({}) | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| `haystack-salesforce-npsp` is distributed under the terms of the MIT license. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add a logo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a
logofield pointing atlogos/salesforce-npsp.png(reusing the PhilanthroPy project mark as a stand-in — happy to swap for a dedicated integration logo later).