Replacement for the Relay.app workflow "DocuSign auto Archive" (📝).
Once a day, sync.py finds DocuSign envelopes marked Completed in the last
72 hours, and for each one not yet logged:
- downloads the combined signed PDF (
{updated_at}_{email_subject}.pdf) - uploads it to the Drive folder DocuSign_Archive
- appends a row to the DocuSign_Signed_Documents sheet
(
Envelope URL | Email subject | Status | Created at | Updated at | Drive file URL) - sends a Slack DM to the configured recipients
The run is idempotent — dedupe is done against envelope IDs already present in column A of the sheet, so a missed day is caught up automatically and nothing is ever processed twice.
- DocuSign Admin → Apps and Keys → add app → note the Integration Key.
- Generate an RSA keypair in the app settings, save the private key.
- Note your API Account ID and the User ID (GUID) of the user to impersonate (visible on the same page).
- Grant one-time consent by opening (prod):
https://account.docusign.com/oauth/auth?response_type=code&scope=signature%20impersonation&client_id=INTEGRATION_KEY&redirect_uri=REDIRECT_URI_FROM_APP
- Google Cloud Console → create project → enable Drive API and Sheets API.
- Create a service account, download the JSON key.
- Share the
DocuSign_ArchiveDrive folder and theDocuSign_Signed_Documentssheet with the service account's email (Editor).
- api.slack.com/apps → create app → OAuth scopes:
chat:write,users:read,users:read.email. - Install to the Marinade workspace, note the Bot User OAuth Token
(
xoxb-...).
| Variable | Value |
|---|---|
DS_INTEGRATION_KEY |
DocuSign integration key |
DS_USER_ID |
impersonated user GUID |
DS_ACCOUNT_ID |
DocuSign API account ID |
DS_PRIVATE_KEY_B64 |
base64 -w0 private.key |
DS_ENV |
prod |
GOOGLE_SA_JSON_B64 |
base64 -w0 service-account.json |
DRIVE_FOLDER_ID |
1wmVwdUYm0QRRTykr5sdwnzy_UNpPNkJ4 |
SHEET_ID |
1UcqpJ0LdVhLmKLGTiqq-ttLb5GA7aPbT7L_-MFOuMrY |
SHEET_TAB |
tab name of the index sheet |
SLACK_BOT_TOKEN |
xoxb-... |
NOTIFY_EMAILS |
andrea@marinade.finance (comma-separated for more) |
LOOKBACK_HOURS |
72 |
- Push this repo to GitHub.
- claude.ai → Settings → Environments → create environment
docusign-archive:- env vars: everything from the table above
- allowed network domains:
account.docusign.com,*.docusign.net,oauth2.googleapis.com,www.googleapis.com,slack.com,pypi.org,files.pythonhosted.org - setup script:
pip install -r requirements.txt
- claude.ai/code/routines → New routine:
- repo: this one, environment:
docusign-archive - trigger: scheduled, daily (e.g. 07:00)
- prompt: see
routine-prompt.md
- repo: this one, environment:
- Trigger a manual run first and watch the log.
- Repo → Settings → Secrets → add all env vars as Actions secrets.
- The workflow in
.github/workflows/docusign-archive.ymlruns daily at 06:30 UTC and can be triggered manually via Run workflow.
Set LOOKBACK_HOURS high enough to cover the gap since Relay.app was turned
off (e.g. 240 for 10 days), run once manually, then set it back to 72.