Documentation

Support

Triggers

Unity Dashboard

Preview, create, and delete triggers using the graphical interface of the Unity Dashboard.
Read time 8 minutesLast updated 3 hours ago

The Unity Dashboard provides a graphical interface for you to preview, create, and delete triggers.
Note
The Unity Dashboard only supports event-based UGS triggers. To create scheduled triggers, you can use the CLI or the Triggers Admin API. You can create both Cloud Code and webhook actions for event-based triggers.

Preview triggers

You can access a list of all triggers for an environment from the Unity Dashboard:
  1. In the Unity Dashboard, select Triggers (or Products > Triggers).
  2. Select an environment from the list of environments.
A list of all triggers in the selected environment for the project appears. The table contains the name, trigger, type, and last updated timestamp.

Trigger details

You can navigate to the trigger details page by selecting a trigger from the list of triggers. The trigger details page shows you the following information:

Data

Description

NameThe name of the trigger.
TypeThe type of trigger: Event or Schedule.
TriggerThe event that triggers the script. For example,
key_saved
by
Cloud Save
.
Event TypeThe full event type, for example,
com.unity.services.cloud-save.key-saved.v1
. For more information on event types, refer to Event structure.
Last updatedThe RFC3339 timestamp of the last time the trigger configuration was updated.
The trigger definition card shows a breakdown of the trigger configuration:
  • when this happens (event type)
  • where (filters)
  • do this (action: Cloud Code script or module, or webhook)
For webhook triggers, the card also shows the Action details: Callback URL, HTTP method, content type, headers, and payload. Use View Trigger Logs to debug delivery, or Delete Trigger to remove the webhook. Failed webhook events appear in the dead letter queue, where you can replay or remove them. The filters are displayed as chips, showing the attribute, operator, and value of the filter. If the dashboard can't display the filter in the chip format, the dashboard displays the filter in its original CEL format. To navigate to the logs page for trigger and view the logs for the trigger execution, select the View Trigger Logs button. Learn more about logs in the Logs section. If the trigger is associated with an existing script or module, the trigger definition card provides a link to the script or module. To navigate to the script or module details page, select the link.

Create a trigger

You can create an event-based trigger in the Unity Dashboard.
  1. In the Unity Dashboard, select Triggers (or Products > Triggers).
  2. Select New trigger.
  3. Fill in the following information:
    • Name: A name for your trigger, used to identify the configuration. Trigger names must be unique across the project and environment and not exceed 255 characters.
    • Type: The type of the trigger. Event-based triggers refer to triggers triggered by UGS-emitted events.
  4. Select Next.
  5. In the next step, select the following information:
    • In the When this happens section:
      1. Select the Add Trigger Event button.
      2. Select the event you want to trigger the script.
      3. Select Add Filter to add a filter to the event.
      Note
      You do not need to encase the string values for quotes. However, you must encase the values for JSON types in quotes.
    • In the Do this section:
      1. Select the Add Action dropdown.
      2. Choose the action type:
        • Cloud Code: Select a script or module to run when the trigger fires. You can only select Cloud Code actions that are in the same environment as the trigger. If you selected a Moderation event in When this happens, you can only select a Moderation script.
        • Webhook: Configure the webhook that sends an HTTP request to your URL when the trigger fires. Refer to Configure a webhook action below.
  6. Select Confirm.
Trigger creation redirects you to the trigger list page. To inspect the trigger configuration, select the trigger name in the table.
Warning
If the trigger interacts with the same service that emits the event, you should define a filter to avoid infinite loops. Refer to Filters in the Unity Dashboard for samples.

Configure a webhook action

When you choose Webhook in the Do this section, you define how the Triggers service calls your endpoint when the event fires. For full template syntax (URL, headers, and payload), refer to Webhooks – Template syntax. The form includes the following fields:

Callback URL

Enter the URL that will receive the webhook request. The URL is called when the trigger fires. You can use template syntax to insert environment secrets or event data—for example
https://mywebsite.com/12345/{{ secret "SECRET_NAME" }}
. The form includes a link to create secrets (project > environment > Secrets); you do not need to leave the page. You can also create secrets in the Secret Manager for the project and environment. For the maximum URL length, refer to Limits.

Method

Select the HTTP method used to deliver the webhook (for example POST).

Environment secret

Environment secrets are used by template expressions in the URL, headers, and payload (for example
{{ secret "SECRET_NAME" }}
,
{{ hmac_sha256 "SECRET_NAME" }}
). Use View Environment Secrets to list secret keys for the current environment, or + Add Environment Secret to create a new secret. The secret key name is what you use inside the double curly braces. For full template syntax, including
hmac_sha256
,
hmac_sha512
,
secret
, and
jwt
, refer to Webhooks – Template syntax.
Add one or more HTTP headers with + Add header. For each header:
  • Key: Header name (for example
    X-Signature-256
    ,
    Authorization
    ).
  • Value: Header value. You can use template expressions such as
    {{ hmac_sha256 "WEBHOOK_SECRET" }}
    or
    Authorization: Bearer {{ jwt }}
    .
Note
Do not wrap values in quotes. Enter the raw value (for example
{{ jwt }}
or
my-value
), not
"{{ jwt }}"
. The Dashboard replaces template expressions when the webhook is sent.
You can add up to 10 custom headers. Each header name and value has a maximum length; header names must be ASCII. For exact limits, refer to Limits. Use the trash icon to remove a header row.

Content type

Select the content type for the request body. This determines the expected format of the payload and controls whether the payload field is optional or required. For the full list of supported content types and their payload formats, refer to Webhooks – Content types. For
application/json
(the default), the payload is optional. For all other content types, the payload is required. Changing the content type clears the payload editor.

Payload

Enter the request body. The expected format depends on the selected content type (see above). For
application/json
, the payload is optional. When left empty, the Triggers service forwards the full event payload as JSON. When provided, the value must be valid JSON — template expressions such as
{{.playerId}}
or
{{ secret "SECRET_NAME" }}
are excluded from JSON validation so they do not cause false errors.
For all other content types, the payload is required. You can use template expressions in the payload:
  • Use
    {{.}}
    to insert the full event payload, or
    {{.fieldName}}
    for a specific field (for example
    {{.playerId}}
    ).
  • Use
    {{ secret "SECRET_NAME" }}
    to insert a secret value. Enter secret names with regular double quotes — the Dashboard handles serialization automatically.
Note
In the Dashboard, enter all template expressions with regular double quotes:
{{ secret "SECRET_NAME" }}
. Do not add backslashes. Quote escaping is only needed when writing templates directly in JSON for the API or CLI.
Select View current event payload to view the shape of the event data for the chosen trigger event. For all supported template functions, refer to Webhooks – Template syntax. Failed webhook deliveries are retried. After retries are exhausted, events appear in the dead letter queue, where you can replay or remove them from the Unity Dashboard. For information on limits, refer to Limits.

Filters in the Unity Dashboard

You can add filters to the trigger configuration to specify the conditions under which the trigger activates. The Unity Dashboard supports a limited set of filters that you can use to filter the event payload. Familiarize yourself with how filters work in the Filters section. Refer to Supported UGS events to inspect event payloads for each UGS event.
Note
The Unity Dashboard provides a limited amount of operators to offer a simple approach to filters. You cannot define type casting, nested expressions, or complex expressions in the Unity Dashboard. If you need more advanced filters, use the CLI or the Triggers API to define your own CEL expressions.
Warning
If your trigger interacts with the same service that emits the event, you need to define a filter to avoid infinite loops. Infinite loops over-process the event, cause unexpected behavior in your game, and eventually exhaust your Cloud Code resources for the project, which leads to a service outage. If you encounter this issue, delete the trigger that is causing the loop.

Supported operators

The Unity Dashboard displays different operators depending on the attribute type:

Operator

Supported by

equals toAll attribute types
not equals toAll attribute types
greater thanint, double and JSON types
greater than or equals toint, double and JSON types
less thanint, double and JSON types
less than or equals toint, double and JSON types
matchesstring and JSON types
not matchesstring and JSON types
containsstring and JSON types
starts withstring and JSON types
ends withstring and JSON types
Note
The JSON type refers to any JSON object, string, number or boolean. Although all operators are supported for JSON types, you need to use the correct operator for the attribute type within the JSON object. For example, you can't use a string operator for a JSON number.

Join filters

You can define up to 10 filters for a trigger. You can join filters by the logical operators
AND
and
OR
. You can use these operators to combine multiple filters to create complex conditions.
Note
The Unity Dashboard doesn't support nested expressions. You can only join filters with the logical operators
AND
and
OR
. If you need more advanced filters, use the CLI or the Triggers API to define your own CEL expressions.

Define filters with the Cloud Save key-saved event

You can define your trigger to only activate when a specific key is saved in Cloud Save. For example, you can define a filter to only activate the trigger when the key
playerData
is saved.
In the Unity Dashboard, you can add this filter to the trigger configuration:
  1. In the When this happens section, select the Add Event button.
  2. Select the event dropdown and choose the Cloud Save key-saved event.
  3. Select the Add Filter button.
  4. In the new Filter card:
    1. In the first dropdown, select the
      key
      attribute.
    2. In the second dropdown, select the
      equals to
      operator.
    3. In the third dropdown, enter the value
      playerData
      .
If you define this filter, you ensure that the trigger only activates when the key
playerData
is saved in Cloud Save.

Define filters with the Leaderboards score-submitted event

You can define your trigger to only activate when a specific score is submitted to a leaderboard. For example, you can define filters to only activate the trigger for a score in a specific range. In the Unity Dashboard, you can add this filter to the trigger configuration:
  1. In the When this happens section, select the Add Event button.
  2. Select the event dropdown and choose the Leaderboards score-submitted event.
  3. Select the Add Filter button.
  4. In the new Filter card:
    1. In the first dropdown, select the
      score
      attribute.
    2. In the second dropdown, select the
      greater than
      operator.
    3. In the third dropdown, enter the value
      0
      .
  5. Select the Add Filter button.
  6. In the new Filter card:
    1. In the first dropdown, select the
      score
      attribute.
    2. In the second dropdown, select the
      less than
      operator.
    3. In the third dropdown, enter the value
      100
      .
If you define this filter, you ensure that the trigger only activates when a score between 0 and 100 is submitted to a leaderboard.

Delete a trigger

To delete triggers from the Unity Dashboard:
  1. Navigate to the Triggers list page.
  2. Select the bin icon. A dialog appears to warn you that trigger deletion can't be undone.
    Note
    If you delete a trigger that is in use by a live game, you may cause unexpected behavior in your game.
  3. Select Delete to confirm the deletion.
Alternatively, you can navigate to the trigger details page and select the Delete button to delete the trigger.

Additional resources