/** * Catalogue of pre-shaped `aaf_sdk.js` calls for the Methods tab. Each entry is * a JSON array of arguments that mirrors the **published Ameyo App SDK docs** * (`client..(...args)`). Placeholders like `{{customerId}}` get * substituted from the live event context at render time. * * Tip: server returns code **121** when the dataObject string is unknown to * the host SDK, **122** when it is not accessible at the current app slot, * and **123** when the call needs a manage/monitor dashboard slot. */ export type AafApiNamespace = | "globalData" | "globalEvent" | "lifeCycle" | "interface" | "httpRequest" | "contextData" | "contextEvent" | "instance" | "appConf" | "augmentModel" | "request" | "store"; export type AafMethodSpec = { /** The aaf_sdk.js namespace on `AmeyoClient.init()`. */ api: AafApiNamespace; /** Method name on that namespace. */ name: string; /** Short, unique description used as the row title. */ description: string; /** * JSON array of arguments. Placeholders are substituted from `eventContext` * at render time so the user can hit Run without editing for the common case. */ sampleRequest: string; }; export const AAF_API_NAMESPACES: readonly AafApiNamespace[] = [ "globalData", "globalEvent", "lifeCycle", "interface", "httpRequest", "contextData", "contextEvent", "instance", "appConf", "augmentModel", "request", "store" ]; /* ------------------------------------------------------------------ */ /* globalData — see https://...App SDK API > globalData service */ /* ------------------------------------------------------------------ */ const GLOBAL_DATA_GET: AafMethodSpec[] = [ { api: "globalData", name: "get", description: "Logged-in user (loggedInUser).", sampleRequest: '[\n "loggedInUser"\n]' }, { api: "globalData", name: "get", description: "Agent session — extended logged-in agent state (getAgentSession).", sampleRequest: '[\n "getAgentSession"\n]' }, { api: "globalData", name: "get", description: "Selected campaigns (selectedCampaigns).", sampleRequest: '[\n "selectedCampaigns"\n]' }, { api: "globalData", name: "get", description: "Ongoing call ticket (ongingCallTicket — note ECC enum spelling).", sampleRequest: '[\n "ongingCallTicket"\n]' }, { api: "globalData", name: "get", description: "Ticket external states by internal state (ticketStates).", sampleRequest: '[\n "ticketStates"\n]' }, { api: "globalData", name: "get", description: "Custom fields per campaign (customFields).", sampleRequest: '[\n "customFields"\n]' }, { api: "globalData", name: "get", description: "Closure reason option per campaign (closureReasonOption).", sampleRequest: '[\n "closureReasonOption"\n]' }, { api: "globalData", name: "get", description: "Current managing/monitoring campaign (currentManagingOrMonitoringCampaign — only on dashboard slots, returns 123 elsewhere).", sampleRequest: '[\n "currentManagingOrMonitoringCampaign"\n]' }, { api: "globalData", name: "get", description: "Selected campaign full configuration (getSelectedCampaignConfiguration).", sampleRequest: '[\n "getSelectedCampaignConfiguration"\n]' }, { api: "globalData", name: "get", description: "Interaction Campaign configuration map (getICConfigurations).", sampleRequest: '[\n "getICConfigurations"\n]' }, { api: "globalData", name: "get", description: "Contact-center preference map (getContactCenterPreference).", sampleRequest: '[\n "getContactCenterPreference"\n]' }, { api: "globalData", name: "get", description: "Agent resource availability for a campaign (getAgentInteractionResourceAvailibility) — second arg required.", sampleRequest: '[\n "getAgentInteractionResourceAvailibility",\n { "campaignId": {{campaignId}} }\n]' } ]; const GLOBAL_DATA_OTHER: AafMethodSpec[] = [ { api: "globalData", name: "update", description: "Update a ticket (priority / subject / externalState / customFields).", sampleRequest: '[\n "ticket",\n {\n "ticketId": "{{ticketId}}",\n "priority": "High",\n "subject": "Updated from AAF debugger",\n "externalState": "OPEN"\n }\n]' }, { api: "globalData", name: "getTickets", description: "List tickets via the global filter (getAllTickets) — set userId:\"none\" for unassigned.", sampleRequest: '[\n "getAllTickets",\n {\n "campaignId": {{campaignId}},\n "internalState": ["OPEN"],\n "orderBy": "dateCreated",\n "orderType": "desc",\n "offset": 0,\n "limit": 10,\n "includeCustomerInfo": true\n }\n]' }, { api: "globalData", name: "addNote", description: "Add a note on a ticket (workbenchInternalTab1/2/3 only).", sampleRequest: '[\n "ticket",\n {\n "ticketId": "{{ticketId}}",\n "subject": "Note from AAF debugger",\n "description": "Sample note created by the SDK debugger app",\n "isPrivate": true\n }\n]' }, { api: "globalData", name: "bulkUpdate", description: "Bulk-update up to 10 tickets (priority / externalState / customFields).", sampleRequest: '[\n "ticket",\n ["{{ticketId}}"],\n {\n "priority": "High",\n "externalState": "OPEN"\n }\n]' }, { api: "globalData", name: "bulkAction", description: "Bulk-action on tickets — actions: \"note\" or \"pick\" (max 10 ids).", sampleRequest: '[\n "ticket",\n "note",\n ["{{ticketId}}"],\n {\n "subject": "Bulk note from AAF debugger",\n "description": "Hello from create-exotel-gwt-app",\n "isPrivate": false\n }\n]' }, { api: "globalData", name: "transfer", description: "Transfer a ticket to a specific agent in a queue (transferToAgentInQueue).", sampleRequest: '[\n "transferToAgentInQueue",\n {\n "campaignId": {{campaignId}},\n "userId": "agent-user-id",\n "agentQueueId": 1,\n "interactionId": "{{ticketId}}",\n "transfferingUserId": "transferring-user-id",\n "transferReason": "test"\n }\n]' }, { api: "globalData", name: "transfer", description: "Transfer a ticket to an agent queue (transferToAgentQueue).", sampleRequest: '[\n "transferToAgentQueue",\n {\n "campaignId": {{campaignId}},\n "userId": "agent-user-id",\n "agentQueueId": 1,\n "interactionId": "{{ticketId}}",\n "transferReason": "test"\n }\n]' }, { api: "globalData", name: "invoke", description: "Mark a message as read on a ticket (setAnswered).", sampleRequest: '[\n "setAnswered",\n {\n "ticketId": "{{ticketId}}",\n "campaignId": "{{campaignId}}",\n "messageId": "message-id-from-payload",\n "userId": "agent-user-id"\n }\n]' }, { api: "globalData", name: "invoke", description: "Generate a CRM URL for a ticket (generateCRMURLTicket).", sampleRequest: '[\n "generateCRMURLTicket",\n {\n "ticketId": "{{ticketId}}",\n "campaignId": "{{campaignId}}",\n "crmURLParams": "{\\"userId\\":\\"userId\\",\\"sessionId\\":\\"sessionId\\",\\"customerId\\":\\"customerId\\",\\"emailId\\":\\"emailId\\",\\"phone\\":\\"phone\\"}",\n "userId": "agent-user-id"\n }\n]' }, { api: "globalData", name: "invoke", description: "Change a ticket external state (changeStatusTicket).", sampleRequest: '[\n "changeStatusTicket",\n {\n "ticketId": "{{ticketId}}",\n "campaignId": "{{campaignId}}",\n "externalState": "PENDING",\n "reason": "test",\n "subject": "Changing ticket state via AAF debugger",\n "isVoiceTicket": false,\n "userId": "agent-user-id"\n }\n]' } ]; /* ------------------------------------------------------------------ */ /* interface — host UI helpers */ /* ------------------------------------------------------------------ */ const INTERFACE_METHODS: AafMethodSpec[] = [ { api: "interface", name: "trigger", description: "Toast notification in the agent shell (toastNotification).", sampleRequest: '[\n "toastNotification",\n { "type": "success", "content": "Hello from create-exotel-gwt-app" }\n]' }, { api: "interface", name: "trigger", description: "Native browser desktop notification (desktopNotification — needs notifications permission).", sampleRequest: '[\n "desktopNotification",\n {\n "title": "Sample notification",\n "body": "Sent from create-exotel-gwt-app",\n "clickAction": "focusWindow",\n "autoClose": true\n }\n]' }, { api: "interface", name: "trigger", description: "Modal close confirmation (must ack on onAppModalClose within ~5s).", sampleRequest: '[\n "modalCloseConfirmation",\n { "title": "Close app?", "message": "You have unsaved changes." }\n]' }, { api: "interface", name: "open", description: "Open the new ticket form prefilled (newTicketForm).", sampleRequest: '[\n "newTicketForm",\n {\n "customerInfo": { "name": "Test", "phone1": "{{phone}}" },\n "ticketInfo": { "campaignId": {{campaignId}} },\n "messageInfo": { "messageType": "MANUAL_MESSAGE", "subject": "From AAF app" }\n }\n]' }, { api: "interface", name: "open", description: "Open the new customer form (newCustomerForm).", sampleRequest: '[\n "newCustomerForm",\n {\n "campaignId": "{{campaignId}}",\n "customerInfo": { "name": "Test", "phone1": "{{phone}}", "email": "test@example.com" }\n }\n]' }, { api: "interface", name: "open", description: "Open existing customer detail page (openCustomerDetail).", sampleRequest: '[\n "openCustomerDetail",\n "{{customerId}}"\n]' } ]; /* ------------------------------------------------------------------ */ /* httpRequest */ /* ------------------------------------------------------------------ */ const HTTP_REQUEST_METHODS: AafMethodSpec[] = [ { api: "httpRequest", name: "invokeAmeyo", description: "Call Ameyo REST via host (path only, no protocol/host).", sampleRequest: '[\n {\n "url": "ameyorestapi/systemintegration/getAllAppInfo",\n "method": "GET",\n "headers": { "content-type": "application/json" }\n }\n]' }, { api: "httpRequest", name: "invoke", description: "Call any external URL via the host proxy (sample GET).", sampleRequest: '[\n {\n "url": "https://httpbin.org/get",\n "method": "GET",\n "headers": {}\n }\n]' }, { api: "httpRequest", name: "invokeAmeyoMultiPart", description: "Multipart upload — `formData.file` should be a FileList; not in every SDK build.", sampleRequest: '[\n "ameyorestapi/path/to/multipart-endpoint",\n { "field": "value" },\n "POST"\n]' } ]; /* ------------------------------------------------------------------ */ /* contextData — slot context (dial / change customer) */ /* ------------------------------------------------------------------ */ const CONTEXT_DATA_METHODS: AafMethodSpec[] = [ { api: "contextData", name: "trigger", description: "Outbound dial (dialPhone) — campaignId must be assigned to this agent.", sampleRequest: '[\n "dialPhone",\n { "phone": "{{phone}}", "campaignId": {{campaignId}} }\n]' }, { api: "contextData", name: "trigger", description: "Dial a customer line (dialCustomer).", sampleRequest: '[\n "dialCustomer",\n { "phone": "{{phone}}", "campaignId": {{campaignId}}, "customerId": "{{customerId}}" }\n]' }, { api: "contextData", name: "trigger", description: "Dial a customer on alternate phone (dialCustomerOnAltPhone).", sampleRequest: '[\n "dialCustomerOnAltPhone",\n { "phone": "{{phone}}", "campaignId": {{campaignId}}, "customerId": "{{customerId}}" }\n]' }, { api: "contextData", name: "trigger", description: "Add a customer to the active interaction (addCustomer).", sampleRequest: '[\n "addCustomer",\n { "phone": "{{phone}}", "campaignId": {{campaignId}}, "name": "Test customer" }\n]' }, { api: "contextData", name: "action", description: "Switch the slot context to another customer id (customer / changeCustomer).", sampleRequest: '[\n "customer",\n "changeCustomer",\n { "customerId": {{customerId}} }\n]' }, { api: "contextData", name: "get", description: "Read a slot context object (e.g. \"customer\").", sampleRequest: '[\n "customer"\n]' } ]; /* ------------------------------------------------------------------ */ /* instance — multi-instance / inter-app messaging */ /* ------------------------------------------------------------------ */ const INSTANCE_METHODS: AafMethodSpec[] = [ { api: "instance", name: "getContext", description: "Read the slot context this app instance was launched with.", sampleRequest: "[]" }, { api: "instance", name: "getAllInfo", description: "List all running instances of an appId across slots.", sampleRequest: '[\n "your-app-id"\n]' }, { api: "instance", name: "getInfo", description: "Lookup info for a single running instance by instanceId.", sampleRequest: '[\n "instance-id"\n]' }, { api: "instance", name: "create", description: "Spawn another instance of the app in a different slot (slotType, creationData, contextData).", sampleRequest: '[\n "MODAL",\n { "title": "From debugger", "width": 600, "height": 400 },\n { "customerId": "{{customerId}}" }\n]' }, { api: "instance", name: "sendData", description: "Send a payload to another instance — the receiver must have called `instance.receiveData(handler)` first.", sampleRequest: '[\n "receiving-instance-id",\n { "ping": "hello from debugger" }\n]' }, { api: "instance", name: "receiveData", description: "Subscribe to inbound `instance.sendData` messages — pass a handler in code; manual-invoke can\'t register a callback through JSON.", sampleRequest: "[]" }, { api: "instance", name: "close", description: "Close an instance you previously spawned (use its instanceId).", sampleRequest: '[\n "instance-id"\n]' } ]; /* ------------------------------------------------------------------ */ /* appConf — app configuration parameters in Ameyo DB */ /* ------------------------------------------------------------------ */ const APP_CONF_METHODS: AafMethodSpec[] = [ { api: "appConf", name: "create", description: "Create an app configuration parameter (parameter is your config payload).", sampleRequest: '[\n {\n "name": "myFeatureFlag",\n "value": "on",\n "type": "STRING"\n }\n]' }, { api: "appConf", name: "get", description: "Read app configuration parameter(s) — `parameter` is a filter object.", sampleRequest: '[\n {\n "name": "myFeatureFlag"\n }\n]' }, { api: "appConf", name: "update", description: "Update an existing app configuration parameter.", sampleRequest: '[\n {\n "id": "config-id",\n "name": "myFeatureFlag",\n "value": "off"\n }\n]' }, { api: "appConf", name: "delete", description: "Delete an app configuration parameter by id / name.", sampleRequest: '[\n {\n "id": "config-id"\n }\n]' } ]; /* ------------------------------------------------------------------ */ /* augmentModel — extend Ameyo data model with custom attributes */ /* ------------------------------------------------------------------ */ const AUGMENT_MODEL_METHODS: AafMethodSpec[] = [ { api: "augmentModel", name: "add", description: "Augment the agent multimedia attributes (only `dataObject = \"userAttributes\"` is supported by ECC).", sampleRequest: '[\n "userAttributes",\n {\n "skills": ["voice", "chat"],\n "myCustomFlag": true\n }\n]' } ]; /* ------------------------------------------------------------------ */ /* request — wrapper for whitelisted Ameyo APIs (RequestApiEnum) */ /* ------------------------------------------------------------------ */ const REQUEST_METHODS: AafMethodSpec[] = [ { api: "request", name: "api", description: "Run a whitelisted Ameyo API (see `RequestService.RequestApiEnum`).", sampleRequest: '[\n "getAllTickets",\n {\n "campaignId": {{campaignId}},\n "internalState": ["OPEN"],\n "limit": 10,\n "offset": 0\n },\n null\n]' }, { api: "request", name: "api", description: "Get a specific ticket by id (getTicket).", sampleRequest: '[\n "getTicket",\n null,\n { "ticketId": "{{ticketId}}" }\n]' }, { api: "request", name: "api", description: "Update a ticket via the request wrapper (updateTicket).", sampleRequest: '[\n "updateTicket",\n {\n "ticketId": "{{ticketId}}",\n "priority": "High",\n "subject": "Updated via request.api"\n },\n null\n]' }, { api: "request", name: "api", description: "Get all messages for a ticket (getAllMessages).", sampleRequest: '[\n "getAllMessages",\n {\n "ticketId": "{{ticketId}}",\n "limit": 50,\n "offset": 0\n },\n null\n]' } ]; /* ------------------------------------------------------------------ */ /* store — runtime-only key/value scratchpad (per appId) */ /* ------------------------------------------------------------------ */ const STORE_METHODS: AafMethodSpec[] = [ { api: "store", name: "set", description: "Set a runtime-only value (lost on iframe reload — use `appConf` for persistent config).", sampleRequest: '[\n "lastCustomerId",\n "{{customerId}}"\n]' }, { api: "store", name: "get", description: "Read a value previously set with `store.set`.", sampleRequest: '[\n "lastCustomerId"\n]' }, { api: "store", name: "delete", description: "Delete a runtime store key.", sampleRequest: '[\n "lastCustomerId"\n]' } ]; export const AAF_METHODS: readonly AafMethodSpec[] = [ ...GLOBAL_DATA_GET, ...GLOBAL_DATA_OTHER, ...INTERFACE_METHODS, ...HTTP_REQUEST_METHODS, ...CONTEXT_DATA_METHODS, ...INSTANCE_METHODS, ...APP_CONF_METHODS, ...AUGMENT_MODEL_METHODS, ...REQUEST_METHODS, ...STORE_METHODS ]; /** Monospace subtitle under the card title — `api.method`. */ export function methodSubtitle(m: AafMethodSpec): string { return `${m.api}.${m.name}`; } /** @deprecated Prefer {@link methodSubtitle} — same value. */ export function methodLabel(m: AafMethodSpec): string { return methodSubtitle(m); }