Auto-Response Component for iOS

Send customers structured content (such as survey links) with Messaging auto-response components.

This feature requires version 1.2.0 or later of the Enhanced In-App Chat SDK.

Important

This article applies to the following implementations:

UI SDKCore SDK

An auto-response is a text or link response sent when a customer initiates a messaging session, a rep joins, or a session ends. This topic describes how to send parameters to Salesforce for the auto-response Messaging component. You can use this component during or after the conversation to show the user a web page, such as a survey. To learn about and set up auto-response components, see Create a Messaging Component: Auto-Response.

The Enhanced In-App Chat UI SDK automatically displays any auto-response components that you add in Salesforce. You don’t write any code to display this component. If you’re using the Core SDK, you can process the incoming ConversationEntry object as you would any other incoming message. This documentation shows you how to optionally pass additional parameters to the URL that is presented to the user.

Note

After you’ve set up the auto-response component in Salesforce, you can optionally send additional parameters from the app using the SDK. These parameters are mapped to the path and the query string of the auto-response URL.

  1. Implement the TemplatedUrlDelegate interface. This delegate contains the didRequestTemplatedValues method, which the SDK calls to set parameter values.
  2. Add your delegate to the SDK using the CoreClient.templatedUrlDelegate property. See the CoreClient reference documentation.
Implement auto-response delegate
1class AutoResponseDelegateImplementation: TemplatedUrlDelegate {
2
3  func core(_ core: CoreClient!,
4            didRequestTemplatedValues template: SMITemplateable!,
5            completionHandler: URLParameterValueCompletion!) {
6
7    // Add any auto-response values
8    for key in template.keys {
9        let value = "my auto-response value"
10        template.setValue(value, forKey: key)
11    }
12
13    // Pass template back to SDK
14    completionHandler(template)
15  }
16}

This sample code requires the configuration object that you created when setting up the UI SDK or the Core SDK. See Build a UI SDK App or Build a Core SDK App for more information.

Note

Add your delegate to the core client object
1// Create an instance of the auto-response delegate
2let myAutoResponseDelegate = AutoResponseDelegateImplementation()
3
4// Create a core client from a config
5let coreClient = CoreFactory.create(withConfig: config)
6
7// Assign the auto-response delegate
8coreClient.templatedUrlDelegate = myAutoResponseDelegate

After you register your delegate, the SDK automatically calls the didRequestPrechatValues method before an auto-response Messaging component is shown.