Write a prompt by hand to generate text from OpenAI and receive a response as a PDF document in your specified reMarkable folder.
You can also simply enter a prompt in the command line interface to generate a PDF response and send it to your reMarkable using rMAPI.
This script is experimental and doesn't do much error checking or validation.
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 the address that you have specified for the IMAP server in config.php
.
You must set the prompt_keyword
to specifiy a keyword in the subject line that we'll search for. The default is "Prompt." You can use just the keyword alone, or you can use it in a phrase, as seen in the example screenshot.
You can also specify a folder on the IMAP server in config.php
, if you have created a filter on the server to automatically organize prompt emails there.
Next, a 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. I'm not sure why, but rMAPI has a hard time creating thumbnails. If you really need a thumbnail for the document, you can duplicate the doc on your reMarkable and it will show up.
Voilà. You have an AI-generated PDF document. Documents are also saved in the documents directory.
You can also simply run php cli.php
in your terminal to give the script a prompt directly and it will upload it to your reMarkable without having to deal with cron or IMAP.
composer install
Make sure you have rMAPI installed and successfully tested.
cp config.inc.php config.php
Obtain your API key and enter the required values in the config file.
Add a new cron job: crontab -e
This example runs every minute. You may want to run this less often.
*/1 * * * * /usr/bin/php8.2 -f /path/to/reMarkableAI/cli.php -- --cron >> /path/to/reMarkableAI/cron_log 2>&1
This script makes use of these projects: