Customer support
Support agents reply to tickets and read profiles only for the customer they serve.
A support agent answers a signed-in customer. It may read that customer's profile and reply on their tickets, and cancel a subscription only with a human's approval.
1. Register actions and resource types
In the dashboard, open Actions & resources. Register each resource type, then each action. To paste an attribute schema, switch the attribute editor to JSON.
Resource type ticket: attributes
{
"customer_id": { "type": "id", "required": true }
}Resource type customer: attributes
{
"customer_id": { "type": "id", "required": true }
}Resource type subscription: attributes
{
"customer_id": { "type": "id", "required": true }
}Action tickets.reply on ticket: context attributes
{
"channel": { "type": "enum", "values": ["email", "chat"], "required": true }
}Action customers.profile.read on customer, no context attributes
Action subscriptions.cancel on subscription, no context attributes
2. Policy
Replace <YOUR_POLICY_ID> with a new policy ID, then
validate, test and publish it with reqlo policies push --publish.
id: <YOUR_POLICY_ID>
name: Support
rules:
- id: own-customer-only
effect: allow
actions: [tickets.reply, customers.profile.read]
agents: { tags: [support] }
subjects: { kinds: [customer] }
condition: resource.attributes.customer_id == subject.id
- id: cancel-needs-approval
effect: require_approval
actions: [subscriptions.cancel]
agents: { tags: [support] }
condition: resource.attributes.customer_id == subject.id
approval: { expires_in_seconds: 1800 }Owners and admins can approve requests from this policy in Approvals. To route them to specific people,
create an approval channel and add channel_id: APC_… to the rule's approval.
3. Authorize on the server
const ticket = await tickets.get(args.ticketId);
await reqlo.enforce({
agent: { id: "agt_support_7" },
subject: { id: session.customerId, kind: "customer" }, // the signed-in customer
action: "tickets.reply",
resource: { type: "ticket", id: ticket.id, attributes: { customer_id: ticket.customerId } },
context: { channel: ticket.channel },
});
await tickets.reply(ticket.id, args.text);Notes
- The target customer is restricted by comparing the ticket's owner with the verified customer, preventing a model from replying on another customer's ticket.
- Cancelling uses
require_approval, not allow.
Every example uses the same request model; only the customer-defined actions, resources and attributes differ. See Core concepts.
Something wrong or unclear? Report an issue with this page.