Sending Interactions
Besides sending automatic Interactions to Medallia Experience Orchestration, you can also send Interactions programmatically. Programmatic Interactions can be sent to only a preconfigured Interaction path and with defined Properties.
See in the examples below how you can send an Interaction request, Interaction request with Properties, and how to retrieve responses for those requests.
android://touchpoint/interaction
.Sending an Interaction request
Send an Interaction request programmatically by calling the mxoSendInteraction
Kotlin top-level function in a Coroutine or the MedalliaMXO.sendInteraction
Java method, as shown below:
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import java.net.URI
scope.launch {
mxoSendInteraction {
interaction = MXOInteraction(URI("/InteractionPath"))
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.build();
try {
MedalliaMXO.sendInteraction(sendInteractionRequest);
} catch (Exception e) {
e.printStackTrace();
}
To capture errors, set the throwErrors
parameter to true
and wrap the method in a try/catch
block, as shown below:
import com.medallia.mxo.MXOErrorApi
import com.medallia.mxo.MXOErrorSdk
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import java.net.URI
import android.util.Log
import android.content.ContentValues.TAG
scope.launch {
try {
mxoSendInteraction(throwErrors = true) {
interaction = MXOInteraction(URI("/InteractionPath"))
}
} catch (error: MXOErrorSdk) {
Log.e(TAG, "SDK Error: ${error.errorMessage}")
} catch (error: MXOErrorApi) {
Log.e(TAG, "Api Error: ${error.errorMessage}")
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import com.medallia.mxo.interactions.MXOInteractionResponse;
import com.medallia.mxo.MXOErrorApi;
import com.medallia.mxo.MXOErrorSdk;
import java.util.concurrent.ExecutionException;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.build();
try {
MedalliaMXO.sendInteraction(true, sendInteractionRequest);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (MXOErrorApi mxoErrorApi) {
mxoErrorApi.printStackTrace();
} catch (MXOErrorSdk mxoErrorSdk) {
mxoErrorSdk.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
This sends a POST request to Medallia Experience Orchestration. Only the Tid from the response is used by the SDK; all other response objects are ignored.
Main
thread.Sending an Interaction request and retrieve the response
Send an Interaction request programmatically, access its response, and then process that response by calling the mxoSendInteraction
Kotlin top-level function in a Coroutine or the MedalliaMXO.sendInteraction
Java method and enqueue with a callback, as shown below:
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import com.medallia.mxo.process
import java.net.URI
scope.launch {
val response = mxoSendInteraction {
interaction = MXOInteraction(URI("/InteractionPath"))
}
response?.process()
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import com.medallia.mxo.interactions.MXOInteractionResponse;
import java.net.URI;
import android.os.Build;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/interactionPath")))
.build();
try {
MXOInteractionResponse response;
response = MedalliaMXO.sendInteraction(sendInteractionRequest).get();
MedalliaMXO.process(response);
} catch (Exception e) {
e.printStackTrace();
}
To capture errors, set the throwErrors
parameter to true
and wrap the method in a try/catch
block, as shown below:
import android.content.ContentValues.TAG
import android.util.Log
import com.medallia.mxo.MXOErrorApi
import com.medallia.mxo.MXOErrorSdk
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import com.medallia.mxo.process
import java.net.URI
scope.launch {
try {
val response = mxoSendInteraction(throwErrors = true) {
interaction = MXOInteraction(URI("/InteractionPath"))
}
response?.process()
} catch (error: MXOErrorSdk) {
Log.e(TAG, "SDK Error: ${error.errorMessage}")
} catch (error: MXOErrorApi) {
Log.e(TAG, "Api Error: ${error.errorMessage}")
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import com.medallia.mxo.interactions.MXOInteractionResponse;
import com.medallia.mxo.MXOErrorApi;
import com.medallia.mxo.MXOErrorSdk;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.build();
try {
MXOInteractionResponse response;
response = MedalliaMXO.sendInteraction(true, sendInteractionRequest).get();
MedalliaMXO.process(response);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (MXOErrorApi mxoErrorApi) {
mxoErrorApi.printStackTrace();
} catch (MXOErrorSdk mxoErrorSdk) {
mxoErrorSdk.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
This sends a POST request to Medallia Experience Orchestration.The response can be passed to the MedalliaMXO.process
method, as shown above. This method returns the response to the SDK to process, attaching any Activity capture, Attribute capture, or Optimize instructions to the interaction.
Main
thread.Sending an Interaction request with Properties
To send an Interaction request with Properties, call the mxoSendInteraction
Kotlin top-level function in a Coroutine or the MedalliaMXO.sendInteraction
Java method passing an Interaction path and array of defined Properties, as shown below:
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import java.net.URI
scope.launch {
mxoSendInteraction {
interaction = MXOInteraction(URI("/InteractionPath"))
properties = myProperties
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.properties(myProperties)
.build();
try {
MedalliaMXO.sendInteraction(sendInteractionRequest);
} catch (Exception e) {
e.printStackTrace();
}
To capture errors, set the throwErrors
parameter to true
and wrap the method in a try/catch
block, as shown below:
import android.content.ContentValues.TAG
import android.util.Log
import com.medallia.mxo.MXOErrorApi
import com.medallia.mxo.MXOErrorSdk
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import java.net.URI
scope.launch {
try {
mxoSendInteraction(throwErrors = true) {
interaction = MXOInteraction(URI("/InteractionPath"))
properties = myProperties
}
} catch (error: MXOErrorSdk) {
Log.e(TAG, "SDK Error: ${error.errorMessage}")
} catch (error: MXOErrorApi) {
Log.e(TAG, "Api Error: ${error.errorMessage}")
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import com.medallia.mxo.MXOErrorApi;
import com.medallia.mxo.MXOErrorSdk;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.properties(myProperties)
.build();
try {
MedalliaMXO.sendInteraction(true, sendInteractionRequest);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (MXOErrorApi mxoErrorApi) {
mxoErrorApi.printStackTrace();
} catch (MXOErrorSdk mxoErrorSdk) {
mxoErrorSdk.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
This sends a POST request to Medallia Experience Orchestration. Only the tid from the response will be used by the SDK; all other response objects are ignored.
Sending an Interaction request with Properties and retrieve the response
To send an Interaction request with Properties and retrieve the response, call the mxoSendInteraction
Kotlin top-level function in a Coroutine or the the MedalliaMXO.sendInteraction
Java method passing an Interaction path and array of defined Properties, as shown below:
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import com.medallia.mxo.process
import java.net.URI
scope.launch {
val response = mxoSendInteraction {
interaction = MXOInteraction(URI("/InteractionPath"))
properties = myProperties
}
response?.process()
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import com.medallia.mxo.process;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.properties(myProperties)
.build();
try {
MXOInteractionResponse response = MedalliaMXO.sendInteraction(sendInteractionRequest).get();
MedalliaMXO.process(response);
} catch (Exception e) {
e.printStackTrace();
}
To capture errors, set the throwErrors
parameter to true and wrap the method in a try/catch
block, as shown below:
import android.content.ContentValues.TAG
import android.util.Log
import com.medallia.mxo.MXOErrorApi
import com.medallia.mxo.MXOErrorSdk
import com.medallia.mxo.interactions.MXOInteraction
import com.medallia.mxo.mxoSendInteraction
import com.medallia.mxo.process
import java.net.URI
scope.launch {
try {
val response = mxoSendInteraction(throwErrors = true) {
interaction = MXOInteraction(URI("/InteractionPath"))
properties = myProperties
}
response?.process()
} catch (error: MXOErrorSdk) {
Log.e(TAG, "SDK Error: ${error.errorMessage}")
} catch (error: MXOErrorApi) {
Log.e(TAG, "Api Error: ${error.errorMessage}")
}
}
import com.medallia.mxo.MedalliaMXO;
import com.medallia.mxo.interactions.MXOInteraction;
import com.medallia.mxo.interactions.MXOInteractionRequest;
import com.medallia.mxo.MXOErrorApi;
import com.medallia.mxo.MXOErrorSdk;
import java.net.URI;
final MXOInteractionRequest sendInteractionRequest = new MXOInteractionRequest.Builder()
.interaction(new MXOInteraction(URI.create("/InteractionPath")))
.properties(myProperties)
.build();
try {
MXOInteractionResponse response = null;
response = MedalliaMXO.sendInteraction(true, sendInteractionRequest).get();
MedalliaMXO.process(response);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (MXOErrorApi mxoErrorApi) {
mxoErrorApi.printStackTrace();
} catch (MXOErrorSdk mxoErrorSdk) {
mxoErrorSdk.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
This sends a POST request to Medallia Experience Orchestration.
The response can be passed to the process
method as a parameter as shown above. This method returns the response to the SDK to process, attaching any capture, track or optimize instructions to the Interaction.