Setup Guide for Mercury Bank + Slack Integration
Follow these steps to set up your Mercury Bank and Slack integration:
- Log in to your Mercury account at https://mercury.com
- Navigate to Developer Settings
- Create a new API key with the following permissions:
accounts:read
- To read account information
transactions:read
- To read transaction data
- Copy your API key for the next step
Mercury Webhook Setup (If Available)
If Mercury supports webhooks for transaction notifications:
- In your Mercury developer settings, look for "Webhooks" or "Event Subscriptions"
- Register a new webhook with the following details:
- URL: Your Val Town HTTP endpoint URL (same as for Slack commands)
- Events: Subscribe to
transaction.created
or similar events
- Authentication: Follow Mercury's instructions for webhook authentication
2. Val Town Environment Variables
Set up the following environment variables in Val Town:
MERCURY_API_KEY
- Your Mercury API key from step 1
SLACK_SIGNING_SECRET
- You'll get this in step 3
SLACK_WEBHOOK_URL
- You'll get this in step 3
- Go to https://api.slack.com/apps and click "Create New App"
- Choose "From scratch" and give your app a name (e.g., "Mercury Bank")
- Select the workspace where you want to install the app
- Under "Basic Information", note your "Signing Secret" and add it to Val Town as
SLACK_SIGNING_SECRET
- Under "Slash Commands", create a new command:
- Command:
/mercury
- Request URL: Your Val Town HTTP endpoint URL (copy from the Val Town UI)
- Short Description: "Interact with your Mercury bank account"
- Usage Hint: "[balance|transactions|search] [args]"
- Under "Incoming Webhooks", activate incoming webhooks
- Click "Add New Webhook to Workspace"
- Select the channel where you want transaction notifications to appear
- Copy the Webhook URL and add it to Val Town as
SLACK_WEBHOOK_URL
- Under "OAuth & Permissions", add the following scopes:
commands
- To create slash commands
chat:write
- To post messages in channels
incoming-webhook
- To post notifications via webhook
- Install the app to your workspace
4. Cron Job Configuration
The integration includes a cron job that checks for new transactions regularly:
- In Val Town, locate the
cron.ts
file
- Click on the "Schedule" button to set up the cron schedule
- Recommended: Set it to run every 15 minutes (*/15 * * * *)
5. Testing the Integration
- In Slack, try the command
/mercury help
to see available commands
- Try
/mercury balance
to see your account balances
- Try
/mercury transactions 5
to see your 5 most recent transactions
- For transaction notifications:
- If using webhooks: Make a test transaction in Mercury
- If using polling: Wait for the cron job to run, or trigger it manually
- If you see "An unexpected error occurred", check your Val Town logs for details
- Ensure your Mercury API key has the correct permissions
- Verify that your Slack app is properly configured with the correct URL
- For transaction notifications, check that the
SLACK_WEBHOOK_URL
is correctly set
- Your Mercury API key has access to sensitive financial data. Keep it secure.
- Consider implementing additional authentication if multiple users will access this integration.
- For production use, implement proper request signature verification from Slack and Mercury.