Messaging API
The purpose of the MessagingAPI API call is to request an engagement (messaging session) with an agent, who is logged into the Nuance messaging system. Upon making a successfull request to the Nuance Messaging System, the onSuccessListener.onResponse method is invoked with an EngageStatusResponse object as its parameter .
* Note: You should not directly instantiate the MessagingAPI class. Instead use the following Messaging builder class:
MessagingBuilder
Create a MessagingBuilder instance by calling MessagingAPI.builder()
Public Methods
You can use the following builder public methods to pass the parameters needed to setup an engagement. MessagingBuilder exposes its public method in such a way that you cannot invoke Builder.build until you call all of the required fields.
Also, you must invoke Builder.build to create an engagement object. The engagement object must be type-casted to the MessagingAPI to access its public methods.
-
public BusinessUnitID siteID(String siteID)
Sets the siteID which is required to instantiate the MessagingAPI object.
-
public AgentGroupID businessUnitID(String buID)
Sets the business unit ID to check agent availability and HOP availability.
-
public BusinessRuleID agentGroupID(String agID)
Sets the agentGroupID which is required for a new engagement.
-
public InitialMessage businessRuleID(String brID)
The business rule ID is used to tie the engagement to a business rule for reporting purposes.
-
public EngagementBuilder initialMessage(String initialMessage)
The initial message sent by the customer.
-
public EngagementBuilder businessRuleName(String brName)
Business rule name is used as the chat title in the Agent Desktop. The default value is EAPI.
-
public EngagementBuilder automationID(long aID)
The automation ID associated with this engagement request.
-
public EngagementBuilder launchType(LaunchTypes type)
The launchType is displayed in the Agent Desktop. It notifies the agent which device type or experience the customer is currently in.
-
public EngagementBuilder openerMessage(String message)
The opener message will be added to the transcript as soon as it is assigned to an agent.
-
public EngagementBuilder pageID(long pID)
The page ID marker where the engagement starts.
-
public EngagementBuilder prioity(long priority)
Initial priority of the engagement request. A higher number indicates a higher priority for the engagement in the queue.
-
public EngagementBuilder queueMessagingSpecID(long qSpecID)
The ID of the queue messaging spec as identified in Portal. If the queue messaging spec is valid, it will pull the proper queue message and display it as message text when the API uses the GET message API call.
-
public EngagementBuilder queueThreshold(long qThreshold)
The queue threshold value for the engagement. Used to calculate whether this engagement goes into the queue in cases where agent slots are not available.
-
public EngagementBuilder scriptID(String scriptID)
The ID of the agent’s script for this engagement.
-
public EngagementBuilder agentAttributes(HashMap<String, String> aAttributes)
A list of agent attributes used in the routing process. Format: attribute1,value1;attribute2,value2 etc.
-
public EngagementBuilder isAsyncEngagement(boolean async)
Set to true if the engagement is asynchronus.
-
public EngagementBuilder setSuccessListener(OnSuccessListener<EngageStatusResponse> sListener)
The OnSuccessListener.onResponse method is invoked upon successfull request.
-
public EngagementBuilder setErrorListener(OnErrorListener fListener)
The OnErrorListener.onErrorResponse method is invoked if there is an error in the request.
-
public Engagement build()
Returns MessagingAPI instance.
MessagingAPI
Public Methods
-
public void startNewEngagement() throws UnsupportedEncodingException, IllegalAccessException
Start a new messaging engagment with the agent.
-
public void startNewEngagement(final com.nuance.Listener.OnSuccessListener<EngageStatusResponse> successListener, final OnErrorListener errorListener) throws UnsupportedEncodingException, IllegalAccessException
Start a new messaging engagment with the agent. Allows you to pass the success and error listener as arguments if you haven't set the listeners through a builder instance.
-
public static SiteID builder()
Instantiates and returns the MessagingBuilder object.
EngageStatusResponse
An instance of this class is passed as an argument to the successListener.
Public Methods
-
public String getStatus()
getStatus method returns one of following values which denotes status of the engagement request.
Constant.QUEUED
Constant.DENIED
Constant.ACCEPTED
Response
Response object is passed to the OnErrorListener.onErrorResponse
Public Methods
-
public int getStatusCode()
getStatusCode method returns one of the following values.
401: Chat can not be created
403: The user does not have sufficient privileges to use the API or to access the requested site.
500: Server error
String siteID = "your site id";
String businessUnitID = "your business Unit id";
String agentGroupID = "your agent group id";
String businessRuleID = "your business rule id";
String initialMessage = "Initial customer message. eg: editText.getText();";
String openerMesage = "Opener message displayed in messaging window."
Engagement.EngagementBuilder engagementBuilder = MessagingAPI.builder()
.siteID(siteID).businessUnitID(businessUnitID).agentGroupID(agentGroupID)
.businessRuleID(businessRuleID).initialMessage(initialMessage).openerMessage(openerMesage);
engagementBuilder.setSuccessListener(new OnSuccessListener<EngageStatusResponse>() {
@Override
public void onResponse(EngageStatusResponse response) {
switch (response.getStatus()){
case Constant.DENIED:
break;
case Constant.QUEUED:
case Constant.ACCEPTED:
break;
}
}
});
engagementBuilder.setErrorListener(new OnErrorListener() {
@Override
public void onErrorResponse(Response response) {
if(response.getStatusCode() == 401){
}
}
});
MessagingAPI engageMessaging = (MessagingAPI)engagementBuilder.build();
engageMessaging.startNewEngagement();