Skip to main content

Starting Online Help

Diyalog Platform provides live assistance service to your customers through your mobile application with messaging.

You can download full simple online help android project from SimpleOnlineHelp link.

First of all, you need to know the flow about online help in Diyalog platform.

The flow is like below :

You should first create and get a transaction hash data in Diyalog server by calling Diyalog server's rest api from your application server. Diyalog server will create a transactionHash and then you could start an online help by using this transaction hash. This step is important for security.

  1. Your mobile app should call your application server to get transactionHash with the customer and device hash.
  2. Your application server should create and get transactionHash in Diyalog Server by calling gettransactionhashforonlinehelp rest api. Only server with valid credentials can call this api in Diyalog server and generate transactionHash. You can get the credential information for your server from the Diyalog admin.
  3. Diyalog server creates and return transactionHash to your server.
  4. Your app server return transactionHash to your mobile app.
  5. After getting transactionHash from the server, your mobile app can call startAnonymousOnlineHelp method in the DiyalogSDK with it.
  6. DiyalogSDK call Diyalog server and initiate online help and then waits until other party (agent) to connect.
  7. Diyalog server create online help and then return OK to mobile app. If there is an error, server will return error to mobile app.
  8. DiyalodSDK will return response of startAnonymousOnlineHelp method to your app. Then you can show wait screen in your app if you manage wait screen. If not, DiyalogSDK will show default wait screen.
  9. When this process starts, a request should have been sent to the call system queue for online help from your own system. When an agent (representative) open a customer from the queue, he initiates the online help chat with the customer through the Diyalog application.
  10. Diyalog server starts online help with each parties who are agent and customer.
  11. After online help startted with customer and agent. Diyalog SDK will send online help state to your app via callback function that you subcscribe. These states can be "STARTED", "CHAT_INPROGRESS", "CHAT_ENDED" and "N0_CHAT"
  12. DiyalogSDK will update your app by all changings in the online help states.

An online help can be started at the relevant stage of your application as follows. When you call the following method, Diyalog first performs the necessary security checks for the relevant customer according to the transactionHash, deviceHash and customer number trio and starts the live help for the relevant customer.

Waiting screen should be shown to the customer until the live help is started by the customer representative. You can manage the waiting screen in your own application or use Diyalog SDK's waiting screen if you prefer.

public void startAnonymousOnlineHelp(
Activity context,
String customerId,
String customerName,
Long idNumber,
Long customerPhone,
String email,
OnlineHelpType helpType,
String transactionHash,
String waitDisplayText,
boolean isLoggedIn,
boolean isBackground,
OnlineHelpStartResult onlineHelpStartResult)
Parameters
context (Activity)
Activity that this method called from.
customerId (String) Customer id number.
customerName (String) Name of the customer.
idNumber (Long)
National ID number of the customer. It is not must. You can set 0 for it.
customerPhone (Long)
Opsiyoneldir.
Phone number of the customer. This paramater is optional. It can be set null.
email (Long)
Optional
Email address of the customer. This paramater is optional. It can be set null.
helpType (OnlineHelpType) This parameter is used to define help type. It can be OnlineHelpType.CHAT, OnlineHelpType.VIDEO_CALL, OnlineHelpType.VOICE_CALL.
transactionHash (String) It is the transactionHash value that you create in the Dialog server through your own application server.
waitDisplayText (String)
Optional
It is the text information that will be displayed on the waiting screen. This parameter is used only if Diyalog SDK will manage waiting screen.
isLoggedIn (boolean)It is the flag that show customer is logged in ot not into main app.
isBackground (boolean)It is the flag that show waiting screen will be managed by Diyalog SDK ot not.
onlineHelpStartResult (OnlineHelpStartResult) startAnonymousOnlineHelp method is an asynchronous method and sends the result (information that the online help has been started) to your application with this callback method.

You can find the detail about VideoCallResult class

public interface OnlineHelpStartResult {
void success();
void failure(OnlineHelpStartError onlineHelpStartError);
}
public class OnlineHelpStartError {
public static final String CUSTOMERID_SHOULD_BE_PASSED = "DLGEXCPINP_CUSTOMER_ID";
public static final String EXCEPTION_IN_AUTH_REQUEST = "DLGEXCP_AUTH_REQUEST";
public static final String EXCEPTION_IN_COMPLETE_AUTH = "DLGEXCP_COMPLETE_AUTH";
public static final String EXCEPTION_IN_USER_IS_INCALL_NOW = "DLGEXCP_USER_IS_IN_CALL_NOW";
public static final String EXCEPTION_CUSTOMER_NOT_ACTIVE_IN_DEVICE = "DLGEXCP_CUSTOMER_NOT_ACTIVE_IN_DEVICE";
public static final String GENERAL_EXCEPTION = "DLGEXCP_GENERAL_EXCEPTION";
public static final String TRANSACTION_HASH_IS_EMPTY = "DLGEXCPINP_TRXHASH_IS_EMPTY";
public static final String INVALID_HELP_TYPE = "DLGEXCPINP_INVALID_HELP_TYPE";
public static final String CUSTOMER_NAME_IS_EMPTY = "DLGEXCPINP_CUSTOMER_NAME_IS_EMPTY";
public static final String NOT_SUPPORTED_FEATURE = "DLGEXCP_NOT_SUPPORTED_FEATURE";
private String errorCode;
private String errorMsg;
public OnlineHelpStartError(String errorCode, String errorMsg) {
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
public String getErrorCode() {
return errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
}

After getting success from startAnonymousOnlineHelp method, you can listen state of online help by subscribing the onlineHelpState. You can use following method for it.

public void subscribeToOnlineHelpChatStateEvent(ValueChangedListener<String> listener)

Online help state is a string and can have following values.

"NO_CHAT" : Default and initial value. There is no active chat.
"STARTED" : Online help started and Diyalog wait screen is shwing. If you handle wait screen, this state will not return.
"CHAT_INPROGRESS" : Agent ve customer started to conversation.
"CHAT_ENDED" : Conversation completed.

You can see complete code sample that you need to implement below.

// 1. Get Diyalog device hash from Diyalog sdk
String deviceHash = DiyalogEngine.diyalogInstance().getDeviceHash();
Log.e("OnlineHelp", "deviceHash: " + deviceHash);
// 2. Call Diyalog server gettransactionhashforonlinehelp service from your app server with customerId
// and this deviceHash.
// below code assume that transactionHash recieved from server.
String transactionHash = "88828d22c3acbec026973b8f9ea1de785bc7cf6e";
String customerId = "123456"; //Customer number
String customerName = "Name of Customer"; // Name and surname
Long customerIdCardNo = 0L; // National id number. It is optional. You can set 0L.
Long customerPhoneNumber = null; // Optional
String customerEmail = null; // Optional
// message in wait screen. If you handle wait screen in your app. You can set it null;
String waitText = "Please wait. Our representative will start video call soon.";
boolean isLoggin = false; // this parameter say user logged in to your app or not. Itis not processeing in Diyalog for now. It will be use later.
boolean isBackground = true; // true : Your app handle wait screen. false: Diyalog will handle wait screen
// 3. Call startAnonymousOnlineHelp
DiyalogEngine.diyalogInstance().startAnonymousOnlineHelp(
MainActivity.this,
customerId,
customerName,
customerIdCardNo,
customerPhoneNumber,
customerEmail,
OnlineHelpType.CHAT,
transactionHash,
waitText,
isLoggin,
isBackground,
new OnlineHelpStartResult() {
@Override
public void success() {
Log.e("OnlineHelp", "online help call success");
showWait();
// Subscribe online help and hadle events
DiyalogEngine.diyalogInstance().subscribeToOnlineHelpChatStateEvent(new ValueChangedListener<String>() {
@Override
public void onChanged(String onlineHelpState, Value<String> value) {
Log.e("OnlineHelp", "online help call state : " + onlineHelpState);
// Online help states
//"NO_CHAT" : Default and initial value. There is no active chat
//"STARTED" : Online help started and Diyalog wait screen is shwing. If you handle wait screen, this state will not return.
//"CHAT_INPROGRESS" : Agent ve customer started to conversation.
//"CHAT_ENDED" : Conversation completed.
if (onlineHelpState.equals("CHAT_ENDED")){
showStartOnlineHelpAgain();
}
}
});
}
@Override
public void failure(OnlineHelpStartError onlineHelpStartError) {
Log.e("OnlineHelp", "online help failed with error : " + onlineHelpStartError.getErrorMsg());
}
});
}

If startAnonymousOnlineHelp method return successfull and you showed wait screen to customer and the customer press cancel button in your wait screen before agent start online help, you should call closeMessaging method to stop process

DiyalogEngine.diyalogInstance().closeMessaging();

Done :)

You can download full simple online help android project from SimpleOnlineHelp link.