def METHOD_NAME(self, session, entities, event):
    '''Callback method for the custom action.
    return either a bool ( True if successful or False if the action
    failed ) or a dictionary with they keys `message` and `success`, the
    message should be a string and will be displayed as feedback to the
    user, success should be a bool, True if successful or False if the
    action failed.
    *session* is a `ftrack_api.Session` instance
    *entities* is a list of tuples each containing the entity type and the
    entity id.
    If the entity is a hierarchical you will always get the entity
    type TypedContext, once retrieved through a get operation you
    will have the "real" entity type ie. example Shot, Sequence
    or Asset Build.
    *event* the unmodified original event
    '''
    if 'values' in event['data']:
        values = event['data']['values']
        if 'number_of_tasks' in values:
            return {
                'success': True,
                'message': '',
                'items': self.get_task_form_items(
                    session, int(values['number_of_tasks'])
                )
            }
        else:
            # Create tasks on each entity
            for entity in entities:
                for count in range(0, int(len(values.keys()) / 2)):
                    task_type = session.query(
                        'Type where id is "{0}"'.format(
                            values["task_{0}_typeid".format(count)]
                        )
                    ).one()
                    # Get name, or assume task type in lower case as name.
                    name = values["task_{0}_name".format(count)]
                    if not name:
                        name = task_type["name"].lower()
                    self.ensure_task(session, name, task_type, entity)
            session.commit()
            return {
                'success': True,
                'message': 'Action completed successfully'
            }
    return {
        'success': True,
        'message': "",
        'items': [
            {
                'label': 'Number of tasks',
                'type': 'number',
                'name': 'number_of_tasks',
                'value': 2
            }
        ]
    }