Event Subscriptions
With Event Subscriptions you can create webhooks to your API, just like with data adapters but now triggered by Tick itself
What you should know first
- Know how "states" work => They are used often in flows and metadata components
Warning be careful
Having an event subscription is awesome but when not being careful can also harm your API infrastructure with a bulk of API requests. It is best to specify exactly what you want to subscribe to.
Configuring
Each event subscription has a trigger and a webhook to receive data
Always reply with an OK message (http status code 200 - 299), otherwise Tick will retry (if configured)
Triggers
The following triggers are available
- All
- Notification => receive Tick notifications as seen on the home dashboard
-
Ticket => receive updates for tickets, triggered by each and every change for tickets.
- Ticket added
- New Messages
- Labels changed
- Assignments changed
- etc.
-
Task => receive updates on tasks being created, saved, etc.
- Tenant => receive updates on your workspaces and configuration such as a new User being added, changed, or a data adapter being created.
Use the Tick API swagger documentation to find the serialization schemes used for each EventDataType
Example code for webhook receiving API (C#)
[HttpPost]
[Route("inboundevent/{tenantId}/{workspaceId}/{eventType}/{dataType}/{eventobjectid}")]
public async Task<IActionResult> InboundEvent([FromRoute] Guid tenantId, [FromRoute] Guid workspaceId, [FromRoute] EventType eventType, [FromRoute] EventDataType dataType, [FromRoute] Guid eventobjectid, [FromBody] string jsonData)
{
IJsonEngine jEngine = new JsonEngine();
switch (dataType)
{
case EventDataType.TenantUpdate:
var tenantUpdate = jEngine.FromJson<TenantUpdate>(jsonData);
// Do something with tenant update
break;
case EventDataType.QuestSummary:
var questSummary = jEngine.FromJson<QuestSummary>(jsonData);
// Do something with ticket summary
break;
case EventDataType.QuestSummaries:
var questSummaries = jEngine.FromJson<QuestSummaries>(jsonData);
// Do something with ticket summaries
break;
case EventDataType.QuestUpdate:
var questUpdate = jEngine.FromJson<QuestUpdate>(jsonData);
// Do something with ticket update
break;
case EventDataType.NotificationsBundle:
var notificationsBundle = jEngine.FromJson<RealtimeNotificationsBundle>(jsonData);
// Do something with notifications
break;
case EventDataType.TaskSummary:
var taskSummary = jEngine.FromJson<TickTaskInstanceSummary>(jsonData);
// Do something with task summary
break;
default:
throw new NotImplementedException();
}
return Ok();
}