Single endpoint API for forwarding form data as Twitter DMs:
- HTML form from the
REFERERURL sends its formData with parametermsgas a base64 encoded message- base64 encoding used to avoid complications with encoding and decoding URIs
dm-forwarderreceives the request and decodes it to get the message text- Then on behalf of the user who has given their keys for the config, it sends this as a DM to the Twitter
user under
RECIPIENT_ID - Message arrives for the recipient in their Twitter inbox
dm-forwarder was primarily built to handle HTML contact form message submissions.
It is rate-limited to only allow 3 submissions within a 30 second window per IP.
- Create a Heroku app
- Configure Heroku "Config Vars" (environment variables):
- Twitter API keys and secrets x 4
- You get these by registering for a Twitter Developer account and creating a new app
- Ensure your Twitter app has permission to send DMs
- RECIPIENT_ID should be the Twitter ID
- REDIRECT should be a URL that end user gets sent back to after submission
- REFERER restricts where the endpoint can be reached from
- MAX_BASE64_LENGTH restricts how large a message can be before it gets rejected
- Twitter API keys and secrets x 4
- Either manually deploy or automatically deployed when new commits arrive into the codebase.