Ticket Types
A Ticket Type is a node in the Graph that defines a custom type key, plus items and relationships with other nodes. For instance, custom types include Support, Complaints, and Warranty Tickets.
To create a new Ticket type, define the type key in a YAML file using the path /registry/actors/ticket/types/<TICKET TYPE>
Ticket types are Custom Actors with specific type definition schema.
Example: Create a Return Ticket Type
Create a New Return Ticket Type
This example creates a new Return Ticket custom type. It includes refund and exchange as items, and a relationship with the order node.
- Define Return in a YAML file.
uri: /registry/actors/ticket/types/returnspec:value: graphSetName: return itemEdgeName: head defaultNumberPrefix: "RE" items: refund: graphSetName: refundTicket edgeName: refundEdge relations: orders: node: 'order' cardinality: single exchange: graphSetName: exchangeTicket edgeName: exchangeEdge relations: orders: node: 'order' cardinality: single- Apply it to the Registry via the CLI using
h_ manage apply
h_ manage apply .\newTicketType.yaml -s demo-ecomResponse
Updated registry keys:- actors/ticket/types/return- Old: undefined- New: {"graphSetName":"return","itemEdgeName":"head","defaultNumberPrefix":"RE","items":{"refund":{"graphSetName":"refundTicket","edgeName":"refundEdge","relations":{"orders":{"node":"order","cardinality":"single"}}},"exchange":{"graphSetName":"exchangeTicket","edgeName":"exchangeEdge","relations":{"orders":{"node":"order","cardinality":"single"}}}}}Choose unique names for asset type definitions because existing types are overwritten, which wipes out any previously existing relations. Once you’ve gotten a response, use h_ manage signals to ensure there were no asset type creation errors.
Example: Query the Return Ticket
Query open Return Tickets
Let’s query the Graph for open Return Tickets. Most specifically, we will get all open exchange Return tickets and the dynamic message field.
Send a POST request to /resources/graph with a JSON body containing the rootEdgeName or graphSetName of the node. In this case, from the type definition, it is return.
Request
POST https://<hantera-hostname>/resources/graphAuthorization: Bearer <YOUR TOKEN>Content-Type: application/json
[{ "edge": "return", "filter": " ticketState == 'open' ", "node": { "fields": ["ticketId", "ticketNumber", "ticketState"], "navigate": [{ "edge": "exchangeEdge", "node": { "fields": ["ticketItemId", " dynamic->'message' "]}}]}}]curl -i -X POST \ https://<hantera-hostname>/resources/graph \ -H 'Authorization: Bearer <YOUR TOKEN>' \ -H 'Content-Type: application/json' \ -d '[{ "edge": "return", "filter": " ticketState == 'open' ", "node": { "fields": ["ticketId", "ticketNumber", "ticketState"], "navigate": [{ "edge": "exchangeEdge", "node": { "fields": ["ticketItemId", " dynamic->'message' "]}}]}}]'Invoke-WebRequest `-Uri "https://<hantera-hostname>/resources/graph" `-Method POST `-Headers @{Authorization="Bearer <YOUR TOKEN>"; 'Content-Type'="application/json"} `-Body '[{ "edge": "return", "filter": " ticketState == 'open' ", "node": { "fields": ["ticketId", "ticketNumber", "ticketState"], "navigate": [{ "edge": "exchangeEdge", "node": { "fields": ["ticketItemId", " dynamic->'message' "]}}]}}]'Response
HTTP/1.1 200 OK...
{"return": { "nodes": [ { "ticketId": "0199a9b6-8608-7360-b98b-d2f9adeb2848", "ticketNumber": "RE100011", "ticketState": "open", "exchangeEdge": { "nodes": [ { "ticketItemId": "0199a9b6-860d-703a-bd17-9ef5451e577f", "dynamic": { "message": "pls exchange this item" }, "cursor": "WyIwMTk5YTliNi04NjBkLTcwM2EtYmQxNy05ZWY1NDUxZTU3N2YiXQ==" } ], "firstCursor": "WyIwMTk5YTliNi04NjBkLTcwM2EtYmQxNy05ZWY1NDUxZTU3N2YiXQ==", "lastCursor": "WyIwMTk5YTliNi04NjBkLTcwM2EtYmQxNy05ZWY1NDUxZTU3N2YiXQ==" }, "cursor": "WyIwMTk5YTliNi04NjA4LTczNjAtYjk4Yi1kMmY5YWRlYjI4NDgiXQ==" }, { "ticketId": "0199aa3f-31d0-7dd8-bf32-3a5fd3fd2627", "ticketNumber": "RE100015", "ticketState": "open", "exchangeEdge": { "nodes": [ { "ticketItemId": "0199aa3f-31ea-7cec-931f-9fb9f6bd5381", "dynamic": { "message": "exchange this product" }, "cursor": "WyIwMTk5YWEzZi0zMWVhLTdjZWMtOTMxZi05ZmI5ZjZiZDUzODEiXQ==" } ], "firstCursor": "WyIwMTk5YWEzZi0zMWVhLTdjZWMtOTMxZi05ZmI5ZjZiZDUzODEiXQ==", "lastCursor": "WyIwMTk5YWEzZi0zMWVhLTdjZWMtOTMxZi05ZmI5ZjZiZDUzODEiXQ==" }, "cursor": "WyIwMTk5YWEzZi0zMWQwLTdkZDgtYmYzMi0zYTVmZDNmZDI2MjciXQ==" } ], "firstCursor": "WyIwMTk5YTliNi04NjA4LTczNjAtYjk4Yi1kMmY5YWRlYjI4NDgiXQ==", "lastCursor": "WyIwMTk5YWEzZi0zMWQwLTdkZDgtYmYzMi0zYTVmZDNmZDI2MjciXQ=="}}Check out how to customize graph queries to make them more specific.