文档

​
​

Development

User Acquisition

Monetization

工业

Triggers

Triggers Admin API

Scheduler Admin API

Open Unity Dashboard

Triggers

此页面不支持所选语言。
LiveOps
​
​
Get started
  • Overview
  • Get started
  • Set up triggers example workflow
  • Authentication
Set up events
  • Understand and manage events
  • Schedule events
Define triggers
  • Define triggers
Configure actions
  • Use Cloud Code
  • Use webhooks
Manage and monitor
  • Use the dead letter queue (DLQ)
  • Limits
  • Failure handling
Examples and reference
  • Use case samples
    • Reward top players at end of season
    • Initialize newly signed-up players
    • Wish players a happy new year
    • Send a push message to player with beaten score
    • Announce a level up to all players in joined lobbies
    • Tune game difficulty level for individual players
    • Notify a Discord channel when players sign up
  1. Triggers
  2. Triggers use case samples

Use case sample: Notify a Discord channel when players sign up

Post messages to a Discord channel using a webhook trigger when players sign up with Authentication.
阅读时间4 分钟
最后更新于 5 个月前

Many game teams use Discord for community and live ops. Discord incoming webhooks lets you post to a channel from an external URL. This sample shows how to use a Triggers webhook to post to Discord every time a player signs up so your team can monitor new sign-ups in real time.
For webhook configuration and template syntax, refer to Webhooks.

Prerequisites

  • A Discord server with a channel where you want messages to appear.
  • A Unity project with Triggers enabled. Refer to Get started if you haven't set up Triggers yet.
  • Familiarity with webhook actions. Refer to Webhooks.

Get a Discord webhook URL

Create an incoming webhook in your Discord server and note its URL structure.
  1. In Discord, open your server and the channel where you want messages (for example
    #new-players
    ).
  2. Open Channel settings > Integrations > Webhooks > New Webhook (or Create Webhook).
  3. Give the webhook a name (for example "player-signed-up"), then select Copy Webhook URL.
Discord webhook URLs have the following format:
https://discord.com/api/webhooks/{webhook.id}/{webhook.token}
Note the webhook ID (the numeric segment) and the webhook token (the string after it). Store both in Secret Manager.

Store the webhook credentials as secrets

Store the Discord webhook ID and token in Secret Manager so neither is exposed in the trigger configuration.
  1. In the Unity Dashboard, navigate to your project and environment.
  2. Open Secrets and select Add project secret.
  3. Enter the key
    DISCORD_WEBHOOK_ID
    and paste your numeric webhook ID as the value. Under Service Access, select Triggers. Select Add.
  4. Select Add secret again. Enter the key
    DISCORD_WEBHOOK_TOKEN
    and paste the token portion of the Discord webhook URL as the value. Under Service Access, select Triggers. Select Add.

Create the trigger in the Unity Dashboard

You can set up your webhook in the Unity Dashboard. Follow the steps below:
  1. In the Unity Dashboard, select Triggers (or Products > Triggers), select your environment, then select New trigger.
  2. Under When this happens, select signed-up (Authentication) as the trigger event.
  3. Under Do this, select Webhook as the action.
  4. In Callback URL, enter the Discord webhook URL with the ID and token as template expressions:
    https://discord.com/api/webhooks/{{ secret "DISCORD_WEBHOOK_ID" }}/{{ secret "DISCORD_WEBHOOK_TOKEN" }}
    The domain is fixed so the URL can be validated when you create the trigger. The Triggers service resolves both secrets from Secret Manager.
  5. For Method, select POST. For Content Type, select application/json.
  6. In the Environment Secret section, confirm that
    DISCORD_WEBHOOK_ID
    and
    DISCORD_WEBHOOK_TOKEN
    appear. If not, select + Add Environment Secret to create them here instead.
  7. In Payload, enter the Discord message body. For example:
    { "username": "player-signed-up", "content": "**New player signed up**\nPlayer ID: `{{.playerId}}` | Provider: `{{.providerId}}`"}
    The fields
    {{.playerId}}
    and
    {{.providerId}}
    come from the Signed up event payload. For richer messages, Discord also supports an
    embeds
    array. Refer to Discord's execute-webhook documentation for the full message format (
    content
    supports plain text and Markdown, up to 2000 characters).
  8. Select Confirm to create the trigger.

Verify the webhook

  1. Trigger a new player sign-up (for example from your game or via the Authentication sign-up API).
  2. Check your Discord channel. A message should appear with the new player's ID and provider.
提示
To trigger a sign-up without running your game, go to Cloud Code > Scripts in the Unity Dashboard, open any script, and then, on the Run Code tab, select Generate in the Player ID section. This creates a new anonymous player and triggers a signed-up event. For more information, refer to Generate a test Player ID.
If no message appears, open the trigger in the Unity Dashboard and select View Trigger Logs to check for delivery errors. If a delivery fails after retries, the event is added to the dead letter queue, where you can replay it.

Create the trigger via the API or CLI

To create the same trigger using the Triggers Admin API or the CLI, store
DISCORD_WEBHOOK_ID
and
DISCORD_WEBHOOK_TOKEN
in Secret Manager, then create the trigger:
{ "name": "discord-new-player", "eventType": "com.unity.services.player-auth.signed-up.v1", "actionType": "webhook", "actionUrn": "urn:ugs:webhook", "webhook": { "url": "https://discord.com/api/webhooks/{{ secret \"DISCORD_WEBHOOK_ID\" }}/{{ secret \"DISCORD_WEBHOOK_TOKEN\" }}", "method": "POST", "headers": { "Content-Type": "application/json" }, "payloadTemplate": "{\"username\": \"player-signed-up\", \"content\": \"**New player signed up**\\nPlayer ID: `{{.playerId}}` | Provider: `{{.providerId}}`\"}" }}

Additional resources

  • Webhooks
  • Dead letter queue
  • Define triggers in the Unity Dashboard
  • Secret Manager

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • Prerequisites

    • Get a Discord webhook URL

    • Store the webhook credentials as secrets

    • Create the trigger in the Unity Dashboard

    • Verify the webhook

    • Create the trigger via the API or CLI

    • Additional resources


报告此页面的问题