[Yandex Cloud documentation](../../../index.md) > [Yandex Serverless Containers](../../index.md) > [Concepts](../index.md) > [Trigger](index.md) > Trigger for Yandex IoT Core

# Trigger for Yandex IoT Core that sends messages to a Serverless Containers container

A [trigger](index.md) for Yandex IoT Core manages messages exchanged between devices, registries, and brokers. This trigger is created for [topics](../../../iot-core/concepts/topic/index.md): it receives copies of messages from topics and sends those to a Serverless Containers container for processing.

The trigger must be in the same cloud as the device, registry, or broker whose topic it reads messages from.

You can create a trigger:
* For a [standard topic](../../../iot-core/concepts/topic/index.md) implemented by the service except for the `$monitoring/<device_ID>/json` topic.
* For a topic with any [subtopics](../../../iot-core/concepts/topic/subtopic.md) and wildcards.
* For an [alias](../../../iot-core/concepts/topic/usage.md#aliases) topic.

A trigger for Yandex IoT Core needs a [service account](../../../iam/concepts/users/service-accounts.md) to invoke the container.

For more information about creating a trigger for Yandex IoT Core, see [Creating a trigger that will send messages to a container in Serverless Containers from a Yandex IoT Core registry or device topic](../../operations/iot-core-trigger-create.md) and [Creating a trigger that will send messages to a container in Serverless Containers from a Yandex IoT Core broker topic](../../operations/iot-core-trigger-broker-create.md).

## Message batching {#batching}

Batching settings allow you to send multiple messages to a container at the same time. They set a top limit on the message batch size and accumulation time. For example, if the message batch size is `3`, the container can receive batches of one to three messages.

## Roles required for the proper operation of a trigger for Yandex IoT Core {#roles}

* To create a trigger, you need a permission for the service account under which the trigger runs the operation. This permission comes with the [iam.serviceAccounts.user](../../../iam/security/index.md#iam-serviceAccounts-user) and [editor](../../../iam/roles-reference.md#editor) roles or higher.
* To use a trigger, the service account needs the `serverless.containers.invoker` role for the folder with the container the trigger will invoke.

Learn more about access management [here](../../security/index.md).

## Yandex IoT Core trigger message format {#format}

Before copying a message to a container, the trigger converts the copy to the below format.

### Device {#device}

```json
{
    "messages": [
        {
            "event_metadata": {
                 "event_id": "2153b5d2-c6af-4c69-a28d-74ce********",
                 "event_type": "yandex.cloud.events.iot.IoTMessage",
                 "created_at": "2019-09-25T15:51:17.872320525Z"
            },
            "details": {
                 "registry_id": "arenou2oj4ct********",
                 "device_id": "areqjd6un3af********",
                 "mqtt_topic": "$devices/areqjd6un3af********/events",
                 "payload": "VGVz****"
            }
        },
        {
            "event_metadata": {
                 "event_id": "2153b5d2-c6af-4c69-a28d-74ce********",
                 "event_type": "yandex.cloud.events.iot.IoTMessage",
                 "created_at": "2019-09-25T15:51:17.872320525Z"
            },
            "details": {
                 "registry_id": "arenou2oj4ct********",
                 "device_id": "areqjd6un3af********",
                 "mqtt_topic": "$devices/areqjd6un3af********/events",
                 "payload": "VGVz****"
            }
        }
    ]
}
```

### Broker {#broker}

```json
{
   "messages":[
      {
         "event_metadata":{
            "event_id":"2153b5d2-c6af-4c69-a28d-74ce********",
            "event_type":"yandex.cloud.events.iot.IoTMessage",
            "created_at":"2019-09-25T15:51:17.872320525Z"
         },
         "details":{
            "broker_id":"arenou2oj4ct********",
            "mqtt_topic":"broker/topic",
            "payload":"VGVz****"
         }
      },
      {
         "event_metadata":{
            "event_id":"2153b5d2-c6af-4c69-a28d-74ce********",
            "event_type":"yandex.cloud.events.iot.IoTMessage",
            "created_at":"2019-09-25T15:51:17.872320525Z"
         },
         "details":{
            "broker_id":"arenou2oj4ct********",
            "mqtt_topic":"broker/topic",
            "payload":"VGVz****"
         }
      }
   ]
}
```

## Useful links {#see-also}

* [Trigger for Yandex IoT Core that sends messages to a Cloud Functions function](../../../functions/concepts/trigger/iot-core-trigger.md)
* [Trigger for Yandex IoT Core that sends messages to WebSocket connections](../../../api-gateway/concepts/trigger/iot-core-trigger.md)