Name the error and the fix in the first reply
A user has hit the same error three times in the last hour, each time on the field mapping screen, and now they write in. The ticket reaches the desk as a fresh conversation, so the first reply asks what they clicked and for a screenshot, and the error that was recorded three times waits for the second exchange. The error code and how often it fired can be on the ticket before anyone opens it, and the first reply can name the fix.
errors_by_type_1h- Errors shown in the last hour, counted by error code
last_error_1h- The error code shown most recently
Attaches the error code and its count to the ticket as it is created and suggests the help article your team keeps for that code, so the agent's first reply names the fix. The agent decides whether to send it.
from datetime import timedelta
from snowplow_signals import Attribute, Event, EventProperty, StreamAttributeGroup, user_id
error_shown = Event(name="error_shown", vendor="com.example", version="1-0-0")
error_code = EventProperty(vendor="com.example", name="error_shown", major_version=1, path="code")
errors_by_type_1h = Attribute(
name="errors_by_type_1h",
type="dict",
events=[error_shown],
aggregation="category_count",
property=error_code,
period=timedelta(hours=1),
)
last_error_1h = Attribute(
name="last_error_1h",
type="string",
events=[error_shown],
aggregation="last",
property=error_code,
period=timedelta(hours=1),
)
# Keyed on the user, since the ticket carries who wrote in, not which browser they used.
saas_support_errors = StreamAttributeGroup(
name="saas_support_errors",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[errors_by_type_1h, last_error_1h],
)// In the handler that creates the ticket when a user writes in
const user = await signals.getServiceAttributes({
name: "saas_support_errors",
attribute_key: "user_id",
identifier: userId,
});
// { errors_by_type_1h: { mapping_type_mismatch: 3 }, last_error_1h: "mapping_type_mismatch" }
const code = user.last_error_1h;
const count = user.errors_by_type_1h?.[code] ?? 0;
if (count >= 2) {
desk.annotate({
ticket,
note: `Hit ${code} ${count} times in the last hour`,
suggestedReply: help.articleFor(code),
});
}