You can select "HTTP Action" as an action while creating a rule for Media Profile in "Rule" tab of "System Configuration". HTTP Action also called Webhook triggers an external API to process those messages which meet the pre-selected conditions. Before going ahead to use this options, you should know about the common definitions, data that can be accessed, API response data, and variables. After introduction to these fields, the steps to apply HTTP Action will be discussed.
Following common attributes are used in all methods of HTTP Action in "Rules" tab.
As of now, only data related to "Tickets" can be accessed through the scripts provided in the HTTP Action. Please refer to the following table to know the data that can be accessed and the required function to access it.
Table: Ticket Data and its Calling Methods
Data | Calling Methods for Script |
---|---|
ticket id |
ticket.getTicketId() |
hasUnreadMessage |
ticket.getHasUnreadMessage() |
process id |
ticket.getProcessId() |
contact center id |
ticket.getContactCenterId() |
campaign id |
ticket.getCampaignId() |
queue id |
ticket.getQueueId() |
assigned user id |
ticket.getAssignedUserId() |
attached customer id |
ticket.getCustomerId() |
ticket source type |
ticket.getSourceType() |
ticket source sub type |
ticket.getSourceSubType() |
escalation |
ticket.getIsEscalated() |
date created |
ticket.getDateAdded() |
last modified date |
ticket.getDateModified() |
list of merged ticket ids |
ticket.getMergedTicketList() |
reopen count |
ticket.getReopenCount() |
ticket subject |
ticket.getSubject() |
ticket priority |
ticket.getPriority() |
external state |
ticket.getExternalState() |
first response date |
ticket.getFirstResponseDate() |
first resolve date |
ticket.getResolveDate() |
first assigned date |
ticket.getFirstAssignedDate() |
ticket custom field data |
ticket.getCustomFields() |
count of outgoing messages |
ticket.getOutgoingMessageCount() |
count of incoming messages |
ticket.getIncomingMessageCount() |
count of outgoing calls |
ticket.getOutgoingCallCount() |
count of incoming calls |
ticket.getIncomingCallCount() |
if ticket has failure messages |
ticket.hasFailureMessage() |
heat value |
ticket.getHeatValue() |
count of outgoing chats |
ticket.getOutgoingChatCount() |
count of incoming chats |
ticket.getIncomingChatCount() |
last reopen date |
ticket.getLastReopenDate() |
last unassigned ate |
ticket.getLastUnassignedDate() |
ticket customer information |
ticket.getCustomerInfo() |
if first assign SLA is achieved |
ticket.getFirstAssignedSlaAchieved() |
if first response sla is achieved |
ticket.getFirstResponseSlaAchieved() |
if resolve sla is achieved |
ticket.getResolveSlaAchieved() |
time remaining for first assign sla |
ticket.getTimeRemainingToAchieveFirstAssignSlaInSeconds() |
time remaining for first response sla |
ticket.getTimeRemainingToAchieveFirstResponseSlaInSeconds() |
time remaining for resolve sla |
ticket.getTimeRemainingToAchieveResolveSlaInSeconds() |
if ticket is assigned or not |
ticket.getHasTicketAssigned() |
if a response is made on ticket or not |
ticket.getHasTicketResponded() |
if ticket has been resolved or not |
ticket.getHasTicketResolved() |
source of the ticket |
ticket.getSource(); |
Initial target of the ticket (same as target of message from which ticket was made) |
ticket.getInitialTarget(); |
Following API Response Data can be in the Post Request Script.
Data |
Method to access the Data |
---|---|
Response Code Received |
responseCode |
Response String Received |
responseString |
Use the following code to initialize a variable in the script.
variables.put("<variable_name>","<variable_value>");
Following is an example.
variables.put("$agent","mary");
Use the following code to access a variable in the script.
variables.get("<variable_name>");
Following is an example.
variables.get("$agent");
Select "HTTP Action" in the top drop-down menu of "Actions" section.
Figure: HTTP Action
Now, perform the following steps.
Figure: GET Method of HTTP Action
Here, the sample code for an API will be provided in the examples of the elements.
<protocol>://<domain_name>:<port>/ameyorestapi/tickets/$ticketId/notes
Replace "protocol" with http or https, "domain_name" with the domain name or IP Address of the location where Ameyo Server is installed, and "port" with the port number such as 8888 for HTTP and 8443 for HTTPS.var response=responseString; eval(\"response = \" +response + \";\"); variables.put("$noteId",response.noteId);
Figure: POST Method of HTTP Action
variables.put("$token","fecace70bff6ea0c"); // this is the same token we configured in database variables.put("$ticketId",ticket.getTicketId()); variables.put("$ticketId",ticket.getAssignedUserId()); var subject= ' note for testing http action for '+ ticket.getTicketId(); variables.put("$subjectForNote",subject);
{ "noteId": "d414-5a6c16fc-MessageId-2", "subject": "regarding ticket resolution", "description": "this is test description", "messageType": "EXTERNAL_NOTE", "userId": "mary", "dateModified": 1517034536012, "dateAdded": 1517034536012 }
Figure: PUT Method of HTTP Action
Figure: DELETE Method of HTTP Action
You can follow the same steps to add more HTTP Actions.
With HTTP Actions, you can add other actions also in Routing Rules, Event-based Rules, and Timer-based Rules. Click the following links to know more about the same.