The reMarkable 2 is a sleek e-ink tablet made for taking notes and reading documents in a convenient, distraction-free fashion. Its display is significantly easier on the eyes than a conventional, LED screen. Plus, the writing experience is the next best thing to real pencil on paper.
Since I’ve been playing with ChatGPT and OpenAI’s APIs for the last few months, I thought it would be a fun experiment to generate a prompt to send to the Completions API from my handwriting and receive a response back as a document.
I can already reliably convert my handwriting to text on the device and send it as an email, so the first question was: How can I automatically get the text content from the email and use it to make a request to OpenAI’s API?
In order to make things easier and more organized, I set up a Sieve filter on the server that automatically moves any message with the word “Prompt” in the subject line to an Inbox folder with the same name.
As a web developer, I’m most comfortable using PHP. There’s also an existing IMAP extension for PHP, so I wrote a small script that retrieves messages from my Inbox/Prompts folder and uses the DOM extension to parse the HTML from the email message.
There’s also already a PHP SDK for OpenAI’s API, so I didn’t have to deal with writing a bunch of custom cURL requests.
After successfully making the API request, I took the response and generated a PDF using the existing mPDF library. Then, this PDF is uploaded to the reMarkable cloud using shell_exec to call the rMAPI app.
This process is automated by adding a cron job that runs every 1 minute, looking for unread email messages with the prompt keyword in the subject line.
You can get the reMarkable AI script on GitHub with instructions on how to install and use it.
The final process looks like this…
Create a new folder on your reMarkable (mine is called “Prompts”). Create a new note and write yourself a prompt.
Use the “convert to text” feature to convert your handwriting to text and send it via email to your address.
Use an identifying keyword in the subject line that the script will search for. I used “Prompt.”
The cron job checks for messages periodically. If it finds one, it will parse the email body, send a request to OpenAI, create a PDF, then upload it to your reMarkable cloud account.
A document will appear in your specified folder.
Open it up to see the AI-generated response!
You can take a look at the example document here in PDF form as well.