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.

Important: The Medallia Experience Orchestration SDK does not trigger programmatic Interactions if there is no an associated Activity Capture, Attribute Capture or Optimization Point added for them.

See in the examples below how you can send an Interaction request, Interaction request with Properties, and how to retrieve responses for those requests.

Tip: When sending Interaction requests programmatically, ensure the Interaction is a fully qualified URI, containing the scheme, authority, and path. For example, ios://touchpoint/interaction.

Sending an Interaction request

Send an Interaction request programmatically by calling the sendInteraction method and passing an Interaction path as a parameter as shown below:

Swift
Objective-C
if let interaction = try? MXOInteraction(withString: "/InteractionPath") { do { try MedalliaMXO.sendInteraction(request: MXOInteractionRequest { builder in builder.interaction = interaction }) } catch { print("Error sending an interaction: \(error.localizedDescription)") } }
NSError *error;
__block MXOInteraction *interaction = [MXOInteraction initWithString:@"/InteractionPath" error:&error];
[MedalliaMXO sendInteraction:[MXOInteractionRequest initWithBuilder:^(MXOInteractionRequestBuilder * _Nonnull builder) {
        builder.interaction = interaction;
}] error:&error];

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 and retrieve the response

Send an Interaction request programmatically and retrieve its response by passing an Interaction path and a completion block as a parameters, as shown below:

Swift
Objective-C
if let interaction = try? MXOInteraction(withString: "/InteractionPath") { do { try MedalliaMXO.sendInteraction(request: MXOInteractionRequest { builder in builder.interaction = interaction builder.onError = { error in print("Error sending an interaction: \(error.localizedDescription)") } builder.onSuccess = { response in do { try MedalliaMXO.process(response: response) } catch { print("Error processing response: \(error.localizedDescription)") } } }) } catch { print("Error sending an interaction: \(error.localizedDescription)") } }
__block NSError *error;
__block MXOInteraction *interaction = [MXOInteraction initWithString:@"/InteractionPath" error:&error];
[MedalliaMXO sendInteraction:[MXOInteractionRequest initWithBuilder:^(MXOInteractionRequestBuilder * _Nonnull builder) {
        builder.interaction = interaction;
	builder.onError = ^(NSError *error) {
            NSLog(@"Error sending an interaction: %@", [error debugDescription]);
        };
        builder.onSuccess = ^(MXOInteractionResponse *response) {
        	[MedalliaMXO processResponse:response error:&error];
        };
}] error:&error];

This sends a POST request to Medallia Experience Orchestration. The response can be passed to the process Swift or processResponse Objective-C methods 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.

Sending an Interaction request with Properties

Send an Interaction request with Properties by calling the method below, passing an Interaction path and dictionary of defined Properties to it:

Swift
Objective-C
if let interaction = try? MXOInteraction(withString: "/InteractionPath") { do { try MedalliaMXO.sendInteraction(request: MXOInteractionRequest { builder in builder.interaction = interaction builder.properties = properties }) } catch { print("Error sending an interaction with properties: \(error.localizedDescription)") } }
NSError *error;
__block MXOInteraction *interaction = [MXOInteraction initWithString:@"/InteractionPath" error:&error];
[MedalliaMXO sendInteraction:[MXOInteractionRequest initWithBuilder:^(MXOInteractionRequestBuilder * _Nonnull builder) {
        builder.interaction = interaction;
	builder.properties = properties;
}] error:&error];

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.

Sending an Interaction request with Properties and retrieve the response

Send an Interaction request with Properties and retrieve its response by calling the method below, passing an Interaction path, dictionary of defined Properties, and a completion block to it:

Swift
Objective-C
if let interaction = try? MXOInteraction(withString: "/InteractionPath") { do { try MedalliaMXO.sendInteraction(request: MXOInteractionRequest { builder in builder.interaction = interaction builder.properties = properties builder.onError = { error in print("Error sending an interaction with properties: \(error.localizedDescription)") } builder.onSuccess = { response in do { try MedalliaMXO.process(response: response) } catch { print("Error processing response: \(error.localizedDescription)") } } }) } catch { print("Error sending an interaction with properties: \(error.localizedDescription)") } }
__block NSError *error;
__block MXOInteraction *interaction = [MXOInteraction initWithString:@"/InteractionPath" error:&error];
[MedalliaMXO sendInteraction:[MXOInteractionRequest initWithBuilder:^(MXOInteractionRequestBuilder * _Nonnull builder) {
        builder.interaction = interaction;
	builder.properties = properties;
        builder.onError = ^(NSError *error) {
            NSLog(@"Error sending an interaction with properties: %@", [error debugDescription]);
        };
        builder.onSuccess = ^(MXOInteractionResponse *response) {
        	[MedalliaMXO processResponse:response error:&error];
        };
}] error:&error];

This sends a POST request to Medallia Experience Orchestration.

The response can be passed to the process Swift or processResponse Objective-C methods 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.