Extract text from images to Mem

TLDR;

  1. Take a photo on your Apple Device
  2. Run the Shortcut in Apple Shortcuts to fetch the latest photo and extract text from the image
  3. Send the extracted text to any note taking platform of your choice

What is Apple Shortcuts?

Shortcuts is a feature in Apple's iOS and Mac operating system that allows users to create custom commands for Siri, the company's digital assistant. Shortcuts can be used to perform a variety of tasks, including opening apps, sending messages, making phone calls, and much more.

Users can create their own shortcuts, or download shortcuts created by others. Shortcuts can be stored in the Shortcuts app, or in the Today widget. Shortcuts can be triggered using Siri.

What is the best way to use Apple Shortcuts?

There is no one "best" way to use Apple Shortcuts. It depends on what you want to use them for. Some people use them to save time by automate tasks they perform frequently. Others use them to be more productive by creating custom commands for Siri. Still others use them to have fun by creating shortcuts that perform humorous or whimsical tasks.

How can I create an automation in Apple Shortcuts?

1. Open the Shortcuts app.

2. Tap the Shortcuts tab on iPhone or All Shortcuts menu on Mac.

3. Tap the + button.

4. Select the type of automation you want to create.

5. Follow the on-screen instructions to complete

Shortcuts App on iPhone
Shortcuts App on Mac

In this post we'll explore how to extract text from most recent image/photo or screenshot from your Mac or iPhone and send it to a note taking app Mem using API.

Steps to create the automation

Step 1: Get the latest Photos or Screenshots

Get the latest photo or screenshot from your device (iPhone, iPad or Mac).

  • Click + to start a new automation 
  • Search for "Get latest photos"
  • Add the step and enable "Include Screenshots"
Get photos from Mac
get photos from iPhone using Shortcuts

Step 2: Extract text from Image

Extract Text from the latest photo or screenshot from Step 1.

  • Search for "Extract Text from Image"
  • Add the step and ensure the input is "Latest Photos" from Step 1

In this step, the text is extracted from the image using Apple's OCR on device. 

Extract text from latest photos
Extract text from image

Step 3: Copy to Clipboard

Copy the extracted text to clipboard. 

  • Search for "Copy to Clipboard" action in Apple Shortcuts
  • Add "Text from Image" as input in this step. This step will help you to temporarily store the extracted text locally on device
  • Next step is to send the extracted information to destination of your choice
Copy text to clipboard
copy text to clipboard


· · ·

You can now send the extracted data to anywhere you'd like. Fe examples destinations:

  • Apple Notes
  • Send as Email
  • Send as Text or WhatsApp message to a friend
  • Send to your PKM (Personal Knowledge Management) system like Evernote, Mem Notion, etc.

In this post, we'll be exploring how to send the text to Mem using API. 

To send the data using API to an external system, you need the API documentation and API Access Key. 

Here's the example API Call that needs to be added in Apple Shortcuts:

curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: ApiAccessToken <Replace this with your access token>" \
-d '{ "content": "Hello there! I am a new mem." }' \
https://api.mem.ai/v0/mems

Once you have the API Access Token, let's continue with Step 4.

· · ·

Step 4: Get the destination URL for API Call

Get the URL of the destination app (Mem) to initiate API Call. 

From the code snippet above, the destination URL is: 

https://api.mem.ai/v0/mems
  • Add "URL" Action in Apple Shortcuts and update the destination URL
Add destination URL
add destination URL

Step 5: API Call to Mem

This is the final step to send the data to your personal knowledge management system. 

API Call in Apple Shortcuts

In this we need:

  1. URL - Add "Get Contents from URL" Action from Apple Shortcuts
    1. Add URL as input from Step 4
  2. Method "POST"
    1. POST method is used to send data using API
  3. Headers
    1. Content/Type:application/json
      1. This is used to inform the API to accept the What is JSON as input format
    2. Authorization: ApiAccessToken <your API token from Mem>
      1. your API token is private and should not be revealed to anyone
  4. Request Body (JSON)
  5. Content - Text extracted from Image
    1. The output of Step 3, extracted text content stored in clipboard 

And, done!

Now, you're ready to run the shortcut from any of your apple devices to extract the text from most recent image or screenshot. 

extract text from image to Mem

This automation saves you 2-3 minutes every time you want to extract text from your images. 

Congratulations! You have successfully created an automation without writing a single line of code.

This blog is dedicated to help non-technical people build products and automations using No-Code. If you’re new to No-Code, you can check out the Beginner’s guide to No-Code .