Community

Reports and events: notify users when an event is published from draft


Comments

1 comment

  • Official comment
    Avatar
    Hisham Arnaout

    Hi Jonathan,

    Thank you for sharing your idea with us. We understand the importance of timely notifications when publishing an event, and this request aligns with a feature we're actively considering. We’ll keep you posted on our progress and let you know if we have any questions or updates. In the meantime, I have a solution that might work for your needs.

    I recommend setting up a webhook for the specific scenario you described. By doing so, you can automate email notifications to your team members when an event transitions from draft to active.

    Here's a quick guide on how to achieve this:

    Step 1: Identify the Webhook Type
    Start by querying the available webhook types to find the one associated with an "Event Published." Use the following GraphQL query:

    query webhookTypes {
      webhookTypes(
        filters: [
          { field: trigger, operation: eq, value: "automatic" }
          { field: name, operation: like, value: "%event published%"}
        ]
      ) {
        edges {
          node {
            id
            name
            description
          }
        }
      }
    }

    The expected result should include the necessary information, such as ID, Name, and Description.

    {
      "data": {
        "webhookTypes": {
          "edges": [
            {
              "node": {
                "id": "V2ViaG9va1R5cGU6ZXZlbnRfcHVibGlzaGVk",
                "name": "Event Published",
                "description": "A webhook will be triggered when an Event has been set to the active status"
              }
            }
          ]
        }
      }
    }

    Step 2: Create the Webhook

    Now, use the obtained ID to create a webhook with the associated webhookTypeId. Replace the placeholder values with your specific details, and adjust your query to get you the information needed.

    mutation createWebhook{
      webhooks{
        create(input:{
          webhookTypeId: "V2ViaG9va1R5cGU6ZXZlbnRfcHVibGlzaGVk"
          name: "Event is published"
          query: "query test($objectid: ID!){ node(id: $objectid) { id ... on Event{ code location { name }  }}}"
          url: "https://test.example.com"
          emailAddress: "test@example.com"
        }) {
          webhook{
            id
            lifecycleState
          }
          errors{ 
              label 
              message 
            value
          }
        }
      }
    }

    This mutation will create a webhook with the specified details.

    Step 3: Add Conditions to the Webhook

    You can customize your webhook further by adding conditions. In this example, the webhook fires only for Events in Germany. Adjust the filterExpression as needed.

    You can read more about Filtered Webhooks for more info.

    mutation updateWebhook{
      webhooks{
        update(input:{
          webhookId:"FIX_ME_WEBHOOK_ID"
          query: "query test($objectid: ID!){ node(id: $objectid) { id ... on Event{ code location { name }  }}}"
            filterExpression:"node.location.name == 'germany'"
        }) {
          webhook{ id filterExpression }
          errors{ label message value }
        }
      }
    }

    Replace "FIX_ME_WEBHOOK_ID" with the actual ID of your webhook.

    Step 4: Sending Email Notifications

    You can use your own logic or Adminsitrate's communication mutation to send emails. This example demonstrates sending emails for a specific Event to designated learners and personnel.

    mutation sendEmail{
    communication{
      sendTemplatedLearnerEmailForEvent(input:{
        eventId:"FIX_ME_EVENT_ID"
        learnerIds:["1"]
        sendingEmailAddressId:"sending@email.com"
        templateId:"1"
        carbonCopy:"person1@email.com"
      }){
        errors{
          label message value
        }
      }
    }
    }

     

    Comment actions Permalink

Please sign in to leave a comment.