PubNub Integration

Scale API: On-Demand Tasks by Real Humans

In-app chat

In-app chat

Last Updated:

2016/11/18

Author:

PubNub

Getting Started TutorialScale Documentation

Execute tasks such as content moderation, phone surveys, transcription, e-commerce tagging, and image recognition

Scale is an API for human labor. With the Scale API, you can deploy real humans, on-demand, to execute tasks like content moderation, phone surveys, transcription, e-commerce tagging, and image recognition. The API handles everything from sourcing and managing the crowd to building efficient tooling.

With the Scale API block, execute these tasks while the data is streaming in realtime. The function is executed while the data is in-motion, not when it is received by the subscriber.

Walkthrough

Check out our Getting Started with Scale API tutorial, and we'll show you how to get Scale API to categorize images in realtime.

This block uses the asynchronous Scale API to process data which has been received on the input channel. After Scale is finished processing the data, it will publish a response object to dynamic output channel. Every channel which subscribed on the output channel will receive the processed data.

To make it possible for the block to send a response to a remote user which has requested it, input/output channel names should follow certain pattern: sa-task-create.uuid (for input channel to which request will be sent) and sa-uuid.taskid (for output channel). uuid should be replaced with real remote user identifier which requested data processing. taskid is same value which has been sent with request under sab_id key (allow to link task with local models if required).

To enable dynamic channel names, creation wildcard subscription should be enabled for keys on which block will be launched.

Published object should follow specification defined in Scale API. The object should also include two fields: sab_id and sab_typesab_type is one of the available task types: categorizetranscriptionphonecallcomparison or annotation.

It's required to provide scaleAPIKey to access Scale API. Also it is possible to specify whether processed data should be stored in dynamic channel's history by changing value for storeTasksUpdatesInHistory.

The audition block allows the retrieval of information on previously processed requests, but to make it work, additional parameters should be changed: storeTaskIdentifiers. Audition on completed tasks can be done only using same uuid value which has been used during processing request.

Input

Publish message on input channel: sa-task-create.uuid

Replace uuid with value which is used during submitting PubNub client configuration.

{
    "sab_id": "1",
    "sab_type": "categorize",
    "instruction": "Is this company public or private?",
    "attachment_type": "website",
    "attachment": "http://www.google.com/",
    "categories": [
        "public",
        "private"
    ]
}

Output

Client subscribe on output channel: sa-uuid.*

Replace uuid with value which is used during submitting PubNub client configuration.

{
    "task": { 
        "completed_at": "2016-11-21T20:25:39.230Z",
        "response": {
            "category": "public" 
        }, 
        "created_at": "2016-11-21T20:25:39.225Z", 
        "callback_url": "https://pubsub.pubnub.com/publish/pub-9c4a1e5c-33bf-497b-bae7-9e643b8710cc/sub-c673492b-3e47-11e2-adf4-77ab52641c9b/0/sa-moonlight.undefined/0?store=1&uuid=scale-api-block", 
        "type": "categorization", 
        "status": "completed", 
        "instruction": "Is this company public or private?", 
        "urgency": "day", 
        "params": { 
            "allow_multiple": false, 
            "categories": [ 
                "public", 
                "private" 
            ], 
            "attachment": "http://www.google.com/", 
            "attachment_type": "website" 
        }, 
        "is_test": true, 
        "task_id": "58335843f2a61f0600018c84", 
        "metadata": {}
    }, 
    "response": { 
        "category": "public" 
    },
    "task_id": "58335843f2a61f0600018c84"
}

Feedback & Support

Need help? Contact PubNub Support.


Talk to an expert

Contact Sales