Topic for Trigger when a new user is created

Hi Guys,

Hope you all are doing well.

I am looking for the topic to start my trigger when a new user is created.

If you see below snippet from the add trigger page in the Genesys cloud Admin, you can see it is has a default prompt as "runs when you a user is created"

But I cannot find any topic to get that working. I am looking for suggestions/guidance on the same. TIA

Trigger

Regards,
Sreekand.

Hello,

I think it was just a random choice for a string, provided as an example for a description.
As far as I know, there is no topic available at this time for user creation.

Regards,

That's pretty unfortunate then that of all "random choices", the one chosen was not actually even available lol :slight_smile: Do we know if there's work being done on developing that particular topic?

Yes indeed. I raised this to the Process Automation team. They will make the change for the default description of the trigger.
I don't have info myself on next topics. I didn't see anything on the Genesys Cloud Ideas. I'll try to reach the Notifications team early next week to see if I can possibly get some info.

Regards,

Thanks Jerome,

Kindly keep us posted on this. We have some automation planned based on the user creation topic.

Regards,
Sreekand

Hi @Jerome.Saint-Marc,

do you have any update for us?

It would be very helpful to have a trigger for a "user creation", instead of getting all users every day via API and have some checks (e.g. if a user has a WebRTC phone assigned - ahh sorry ... the user is assigned to a WebRTC phone).

In this area of thinking, also "user deletion" or inactivation would be a very good trigger to e.g. delete the WebRTC phones that has the user assigned. Right now the WebRTC phone is still there, but there is no user assigned anymore.

BR, Robert

Hello,

No, I don't.
You can request new features and share your use case on the Genesys Cloud Ideas Portal.

Regards,

Hi guys,

You might solve this by listening to audit events and event bridge. We publish our audit events ( v2.audits.entitytype.USER.entityid.{id} ) to event bridge and event bridge allows us to wildcard all messages. so you don't have to subscribe to a specific user id (which is what is required in for a websockets notification).

Unfortunately, this event is not available for process automation triggers. If you need this event you might want to open an Idea in our Ideas portal asking for process automation trigger support.

Here are some thoughts on the eventbridge implementation. I used an AI to help generate the answer, so the process should be correct, but the code will need to be reviewed and checked. Take a look at this page as we have large amount of examples of how to setup events in eventbridge.

Thanks,
John Carnell
Director Developer, Engagement


Using the v2.audits.entitytype.USER.entityid.{id} topic with WebSocket notifications requires knowing the user ID upfront, which isn’t feasible for catching CREATE events for new users since their IDs aren’t known in advance. Switching to Amazon EventBridge integration with Genesys Cloud provides a better solution, as it supports wildcard-like behavior by allowing you to filter events based on patterns without needing to specify exact IDs.

Genesys Cloud can publish audit events to an AWS EventBridge event bus via an integration, and you can set up rules to capture user-related audit events (CREATE, UPDATE, DELETE) without requiring specific entityid values upfront. Below, I’ll provide a JavaScript implementation that processes these events using an AWS Lambda function triggered by EventBridge.

Approach

  1. Genesys Cloud Setup:
  • Configure an EventBridge integration in Genesys Cloud to send audit events to your AWS EventBridge event bus.

  • Use the User entity type filter to capture all user-related audit events.

  1. EventBridge Rule:
  • Create an EventBridge rule to match user audit events (e.g., based on entityType: USER and actions like CREATE, UPDATE, DELETE).

  • Target the rule to an AWS Lambda function.

  1. Lambda Function:
  • Write a JavaScript Lambda handler to process the events and log or act on user changes.

JavaScript Code Example (AWS Lambda)

javascript

// Lambda handler function
exports.handler = async (event) => {
  try {
    console.log('Received EventBridge event:', JSON.stringify(event, null, 2));

    // Genesys Cloud audit events are sent as detail in the EventBridge event
    const detail = event.detail;

    // Extract relevant fields from the audit event
    const entityType = detail.entityType; // Should be "USER"
    const entityId = detail.entityId; // The user ID
    const action = detail.action; // CREATE, UPDATE, DELETE
    const initiatedBy = detail.initiatedBy?.displayName || 'Unknown'; // Who made the change
    const timestamp = detail.timestamp; // When the change occurred

    // Ensure the event is for a USER entity
    if (entityType === 'USER') {
      switch (action) {
        case 'CREATE':
          console.log(`User Created - ID: ${entityId}, By: ${initiatedBy}, At: ${timestamp}`);
          // Add your logic here (e.g., save to DynamoDB, send SNS notification)
          break;
        case 'UPDATE':
          console.log(`User Updated - ID: ${entityId}, By: ${initiatedBy}, At: ${timestamp}`);
          // Add your logic here
          break;
        case 'DELETE':
          console.log(`User Deleted - ID: ${entityId}, By: ${initiatedBy}, At: ${timestamp}`);
          // Add your logic here
          break;
        default:
          console.log(`Other action on user ${entityId}: ${action}, By: ${initiatedBy}, At: ${timestamp}`);
      }
    } else {
      console.log(`Ignoring non-USER event: ${entityType}`);
    }

    return {
      statusCode: 200,
      body: JSON.stringify({ message: 'Event processed successfully' })
    };
  } catch (error) {
    console.error('Error processing event:', error);
    throw error; // Let Lambda retry or log the failure
  }
};

Genesys Cloud EventBridge Integration Setup

  1. Create an EventBridge Integration:
  • In Genesys Cloud Admin UI, go to Integrations > Add Integration > Amazon EventBridge.

  • Provide your AWS Account ID, Region, and an optional Event Bus Name (default is default).

  • Activate the integration.

  1. Configure Event Filters:
  • In the integration settings, add a filter for User entity type audit events:

    • Entity Type: USER

    • Actions: CREATE, UPDATE, DELETE

  • Save and activate the integration.

  1. Event Payload:
  • Genesys Cloud sends audit events to EventBridge in a format like this:

json

{
  "version": "0",
  "id": "event-id",
  "detail-type": "Genesys Cloud Audit Event",
  "source": "genesys.cloud",
  "account": "your-aws-account-id",
  "time": "2025-03-21T12:00:00Z",
  "region": "your-region",
  "resources": [],
  "detail": {
    "entityType": "USER",
    "entityId": "123e4567-e89b-12d3-a456-426614174000",
    "action": "CREATE",
    "initiatedBy": { "displayName": "Admin User" },
    "timestamp": "2025-03-21T12:00:00Z"
  }
}

EventBridge Rule Setup

  1. Create a Rule in AWS EventBridge:
  • Go to the AWS Console > EventBridge > Rules > Create Rule.

  • Name: GenesysUserAuditRule.

  • Event Pattern:

json

{
  "source": ["genesys.cloud"],
  "detail": {
    "entityType": ["USER"],
    "action": ["CREATE", "UPDATE", "DELETE"]
  }
}
  • Target: Select your Lambda function (e.g., processGenesysUserEvents).
  1. Permissions:
  • Ensure the Lambda function has an execution role with permissions to log to CloudWatch (AWSLambdaBasicExecutionRole).

Explanation

  1. Wildcard Advantage:
  • Unlike the WebSocket approach, EventBridge doesn’t require subscribing to specific entityid values. The integration pushes all matching audit events to the event bus, and the rule filters them dynamically.
  1. Lambda Handler:
  • The handler processes each event, checking the entityType and action to determine if it’s a user-related CREATE, UPDATE, or DELETE.

  • You can extend the switch block with custom logic (e.g., writing to DynamoDB, sending an email via SES).

  1. Scalability:
  • EventBridge and Lambda scale automatically, making this more robust than managing WebSocket connections.

Running the Solution

  • Deploy the Lambda:

    • Zip the JavaScript file and upload it to AWS Lambda, or use the inline editor.

    • Set the handler to index.handler (if the file is named index.js).

  • Test:

    • Create, update, or delete a user in Genesys Cloud, then check CloudWatch Logs for the Lambda output.

Notes

  • Permissions: Ensure the Genesys Cloud integration has appropriate permissions to publish to EventBridge, and your AWS IAM role allows EventBridge to invoke Lambda.

  • Cost: EventBridge and Lambda have free tiers, but monitor usage for large-scale deployments.

  • Documentation: Refer to Genesys Cloud EventBridge Integration and AWS EventBridge for details.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.