Discord Webhook Automation: json / data package question

By UncreatedLemon , 23 Jun 2025 at 4:08 AM
  • UncreatedLemon @UncreatedLemon
    23 Jun 2025 at 4:08 AM

    Evening everyone,

    Was wondering if anyone had a template / example data package for their Discord webhooks for Perscom: New Record triggers.

    I'm trying to push all notifications into Discord instead of emails and such. Perhaps there is a simpler way? Any advice would be appreciated!

    I'm just struggling to figure what to put in the data package.

    Thanks!


  • jannes @jannes
    23 Jun 2025 at 1:56 PM Edited on 23 Jun 2025 at 2:02 PM by jannes

    Hi there,

    We haven't caught up with our documentation for the plugin yet, but I think we can get something working!


    The trigger exposes 2 variables, "type" and "record"

    I recommend creating a separate automation per record type using conditions. So we'll set up:

    Condition: Expression

    Expression: type == 'award'


    Then we'll add the webhook action to it:

    Webhook URL: https://discord.com/api....

    Data:

    BIG WARNING: This will stop working in v2 of the plugin.

    In v2, the record will already contain all of the data we need to fetch from PERSCOM, but it will no longer include the _id fields, so it will stop working! I'll include a brief example of that too.

    {% set user = perscom().users().get(record.user_id) %}
    {% set award = perscom().awards().get(record.award_id) %}
    {% set title = user.name ~ ' received the ' ~ award.name %}
    {% set description = record.text ? record.text : ('Congratulations on receiving the ' ~ award.name ~ '.') %}
    {{ {
    embeds: [
    {
    title: title,
    description: description,
    url: absolute_url(path('perscom_user', { id: user.id })),
    }
    ]
    }|json_encode|raw }}


    {# V2 example: #}
    {% set title = record.user.name ~ ' received the ' ~ record.award.name %}
    {% set description = record.text ? record.text : ('Congratulations on receiving the ' ~ record.award.name ~ '.') %}
    {{ {
    embeds: [
    {
    title: title,
    description: description,
    url: absolute_url(path('perscom_user', { id: record.user.id })),
    }
    ]
    }|json_encode|raw }}


    Just be aware that the webhook might take a minute to actually post in your Discord. I just typed this up on-the-go, so let me know if it doesn't work and I'll give it a try tonight on one of my test websites.


    EDIT: seems like editing this comment has destroyed the indentation, just imagine it being formatted properly haha


  • UncreatedLemon @UncreatedLemon
    23 Jun 2025 at 2:00 PM

    Thanks for the reply! I'll give this a shot when I get some time.

    Are webhooks the best method? Is it possible to set all notifications to go to a users Discord instead of email?


  • jannes @jannes
    23 Jun 2025 at 2:18 PM

    Hi UncreatedLemon,

    For anything more advanced than just posting to a discord channel you will need a Discord bot. We do not offer any type of first party bot, so you'll have to create your own.

    If you have a bot, you could expose some HTTP endpoints on your bot that forumify can submit data to, and the bot could then DM the user. You could do this with a simple node.js server using discord.js and express. Or you could use any of those fancy bot builder tools, but I've personally been out of the Discord bot game for too long to recommend anything there..

    Another hurdle would be getting the user's Discord snowflake (ID). I'm not sure how you would even get this ID. Maybe a custom field on the PERSCOM user? But then you or an admin would have to manually fill this in on every user during recruitment.

    Personally, I hate getting Discord DMs from bots that I didn't sign up for. Email was, and still is, the standard for transactional asynchronous communication, and it comes with the added benefit that users have the ability to turn off email notifications from forumify in their profile settings.


  • UncreatedLemon @UncreatedLemon
    23 Jun 2025 at 2:21 PM

    You make great points, perhaps I need to rethink my approach on this one.

    I've found myself looking to move to a more forum approach rather than discord for community management, but a lot of users still prefer discord and I'm worried it'll be hard to have users check in to the site routinely.

    Perhaps just a culture issue I'll need to figure out


  • jannes @jannes
    23 Jun 2025 at 2:25 PM

    You can use the report in feature from the premium version. If users don’t report in on the operations center periodically, an assignment record to a status of your choice will be created.

    you could have an automation on that which posts to some discord channel and publicly shame the user for not reporting in on the website 😂