QR Code Scanner

Overview:

The 'QR Code Scanner' data action block allows you to scan and extract data from one or more QR codes present in your documents. This block is useful for automating the process of reading QR codes and integrating their data into your workflow.

Steps to Set Up the 'QR Code Scanner' Block:

  1. Access Your Workflow:

    • Navigate to the 'Workflow' section from the left panel on your Nanonets Extract Data page.
  2. Add a New Data Action Block:

    • Click on “Add a new step” to view the available data action blocks.
    • From the list, select "QR Code Scanner".
    QR Code Scanner

    QR Code Scanner

  3. Enter a QR Code Label:

    • Provide a label name for the field where the value of the scanned QR code will be stored. This label helps in identifying and accessing the extracted QR code data later in the workflow.
    QR Code Label

    QR Code Label

  4. Test the Action:

    • Select an uploaded file that contains QR codes and click "Run Test". This allows you to verify that the block correctly scans and extracts data from the QR codes as expected.
    Test the Action

    Test the Action

  5. Complete Setup:

    • After confirming that the configuration and test results meet your requirements, click "Done" to save and apply the action.
    Complete Setup

    Complete Setup

    You can apply this data action conditionally, using the Conditional Block.


Handling JWT Tokens from Scanned QR Codes:

When a scanned QR code returns a JWT (JSON Web Token), you can use Python Block to decode and verify the token. Below is a sample Python code snippet to help you handle JWT tokens extracted from QR codes:

import jwt
import json

def handler(token):
    try:
        # Decode the JWT without verifying the signature
        decoded_token = jwt.decode(token, options={"verify_signature": False})
        
        # Get the 'data' field from the decoded token
        data_str = decoded_token.get('data')
        
        # Convert the 'data' field from JSON string to dictionary
        data_dict = json.loads(data_str)
        
        return json.dumps(data_dict, indent=4)
    except Exception as e:
        return str(e)

If you don't see this block in your model, please contact us at [email protected].