Learn R Programming

MTurkR (version 0.8.0)

SetHITTypeNotification: Configure a HITType Notification

Description

Configure a notification to be sent when specific actions occur for the specified HITType.

Usage

SetHITTypeNotification(hit.type, notification = NULL, active = NULL, 
                       verbose = getOption('MTurkR.verbose', TRUE), ...)

Arguments

hit.type

A character string specifying the HITTypeId of the HITType for which notifications are being configured.

notification

A character string containing a URL query parameter-formatted Notification structure (e.g., returned by GenerateNotification).

active

A logical indicating whether the Notification is active or inactive.

verbose

Optionally print the results of the API request to the standard output. Default is taken from getOption('MTurkR.verbose', TRUE).

...

Additional arguments passed to request.

Value

A data frame containing details of the Notification and whether or not the request was successfully executed by MTurk.

Once configured, events will trigger a side effect in the form of a notification sent to the specified transport (either an email address or SQS queue). That notification will contain the following details: EventType, EventTime, HITTypeId, HITId, and (if applicable) AssignmentId.

Details

Configure a notification to be sent to the requester whenever an event (specified in the Notification object) occurs. This is useful, for example, to enable email notifications about when assignments are submitted or HITs are completed, or for other HIT-related events.

Email notifications are useful for small projects, but configuring notifications to use the Amazon Simple Queue Service (SQS) is more reliable for large projects and allows automated processing of notifications. See examples for SQS examples. Note that using SQS requires an SQS queue with permissions configured to allow SendMessage requests from MTurk (the “principal” for MTurk is arn:aws:iam::755651556756:user/MTurk-SQS). See the MTurkR wiki for an extended tutorial.

setnotification() is an alias.

References

API Reference: Operation

API Reference: Concept

See Also

GenerateNotification

SendTestEventNotification

Examples

Run this code
# NOT RUN {
# setup email notification
hittype <- 
RegisterHITType(title="10 Question Survey",
                description=
                "Complete a 10-question survey about news coverage and your opinions",
                reward=".20", 
                duration=seconds(hours=1), 
                keywords="survey, questionnaire, politics")

a <- GenerateNotification("requester@example.com", event.type = "HITExpired")
SetHITTypeNotification(hit.type = hittype$HITTypeId, 
                       notification = a,
                       active = TRUE)
# send test notification
SendTestEventNotification(a, test.event.type="HITExpired")
# }
# NOT RUN {
# }
# NOT RUN {
# setup SQS notification
hittype <- 
RegisterHITType(title="10 Question Survey",
                description=
                "Complete a 10-question survey about news coverage and your opinions",
                reward=".20", 
                duration=seconds(hours=1), 
                keywords="survey, questionnaire, politics")

b <- GenerateNotification("https://sqs.us-east-1.amazonaws.com/123456789/Example", 
                          transport = "SQS", 
                          event.type = "HITExpired")
SetHITTypeNotification(hit.type = hittype$HITTypeId, 
                       notification = b,
                       active = TRUE)
# send test notification
SendTestEventNotification(b, test.event.type="HITExpired")
# }

Run the code above in your browser using DataLab