Verint Community exposes a rich set of events throughout the In-process API. These events are exposed to Plugins and Automations to build business logic.
Available Events
Events are specific to each entity type within the Verint Community platform and are registered for use by automations using Automation Event Definitions. In general, events are named related to the type of change and the time at which it occurs:
- BeforeCreate. This type of event occurs before a new item is created in the API. While the final identifier of newly created items may not be available during the BeforeCreate event, the BeforeCreate event provides editable properties in event arguments to support adjusting the data associated with the entity before it is created.
- AfterCreate. This type of event occurs after a new item is created in the API. The event arguments are read-only since the data associated with the item has already been committed. Identifiers for newly created items are available in AfterCreate.
- BeforeUpdate. Similar to BeforeCreate, this type of event occurs before an existing item is edited int he API. This event can be used to modify data associated with the item being updated before its changes are committed.
- AfterUpdate. This type of event occurs after an edit of an item is committed.
- BeforeDelete. This type of event occurs before an item is deleted.
- AfterDelete. This type of event occurs after an item has been deleted.
In addition to these standard event types, there are special event types which can be used to interact with specific areas of the API. The full list of events exposed to automations can be reviewed in API Documentation.
Triggering Automations using Events
Automations can be triggered to execute logic when an API event occurs. To enable an automation to be triggered by one or more events,
- On the automation's Overview, locate Triggers, and check API Event Occurs.
- Within the API Events field, you can use type-ahead search to locate one or more events to handle. Events are named using the format ENTITY_TYPE.EVENT_NAME. To handle the AfterCreate event on Media, the full event name is "Media.AfterCreate"
- As events are selected, they are listed below the API Events field and links to view documentation or remove the event from the automation are provided.
Using Event Triggers in Automation Implementations
When any automation trigger occurs, including API events, the automation's implementation script is executed. Details about the trigger are provided to the implementation script through the context_v2_automationTrigger
API. This API defines a few members that make interacting with events possible:
- Entity. For API event triggers, Entity identifies the entity type of the API Event. For the "Media.AfterCreate" API event, Entity would be set to "Media"
- Event. For API event triggers, Event identifies the event name. For the "Media.AfterCreate" API event, Event would be set to "AfterCreate"
- Arguments. Arguments provides access to the arguments provided by the event that triggered the automation and is specific to the entity and event that occurred. Review the documentation link on the API Events list on the automations Overview to get details about the arguments available with specific events. Generally, "Before" events expose editable arguments and "After" events expose read-only arguments.
Example of an API Event Trigger
Below is a simple example of utilizing an automation with an API event trigger. For this scenario, we would like to send a group invitation to a user when their account is created.
Creating the Automation
After following the dialog in Administration > Automation > Automation Studio to create a new automation, we set the event to listen to. For this example we only need the User.AfterCreate event.
Any instance of this automation will need to specify a group to add the users to, so in the Configuration section of our automation, we add an option for selecting a group.
<propertyGroup id="options" labelText="Options">
<property id="groupId" labelText="Group" descriptionText="Specify which group the user will be added to." dataType="Custom" template="core_v2_groupLookup" enableCurrent="false" maxSelections="1" />
</propertyGroup>
In the Implementation section of our automation, we can then retrieve this value before continuing execution.
var groupId = core_v2_page.ParseQueryString(core_v2_widget.GetCustomValue('groupId', '')).Value('Group'); if(groupId === '') { return; }
Since this automation is running in the context of an event happening, we also have access to the arguments of that event. In this case, we can retrieve the Id of the user who was created.
var userId = context_v2_automationTrigger.Arguments.Id;
Then we can create the invite using the GroupUserMember scripting/widget API.
var response = core_v2_groupUserMember.Create(groupId, userId, { GroupMembershipType: 'PendingMember', Message: 'Welcome to the welcome group!' });
Configuring an Automation Instance
In Administration > Automation > Automations, we create a new Automation instance and specify the type. This then allows us to specify the configuration details we created the options for in our automation.
Once the instance is saved, the automation will run each time the event fires until all instances of this automation are disabled or deleted.
Source code
Full source is attached below.
<automation name="Add users to a group when they join the site" version="11.0.0.0" description="Specify a group that users will be automatically added to when their account is created." id="d6ed947ee6a44dd5b5f3cf637a51d245" executeAsServiceUser="true" trigger="Event" lastModified="2019-06-21 22:54:12Z" provider="31f486cc-03b5-42b6-b5df-81cdd976aa59"> <events> <event key="user.aftercreate" /> </events> <executionScript language="JavaScript"><![CDATA[var groupId = core_v2_page.ParseQueryString(core_v2_widget.GetCustomValue('groupId', '')).Value('Group'); if(groupId === '') { return; } var userId = context_v2_automationTrigger.Arguments.Id; var response = core_v2_groupUserMember.Create(groupId, userId, { GroupMembershipType: 'PendingMember', Message: 'Welcome to the welcome group!' });]]></executionScript> <configuration><![CDATA[<propertyGroup id="options" labelText="Options"> <property id="groupId" labelText="Group" descriptionText="Specify which group the user will be added to." dataType="Custom" template="core_v2_groupLookup" enableCurrent="false" maxSelections="1" /> </propertyGroup>]]></configuration> </automation>