Auto-Response Component for Android
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.
This article applies to the following implementations:
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.
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.
- Implement the
TemplatedUrlValuesProvider interface. This provider contains the setValues method, which the SDK calls to set parameter values.
- Add your provider to the SDK using the
CoreClient.registerTemplatedUrlValuesProvider property. See the CoreClient reference documentation.
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.
1// Create a core client from a config
2val coreClient = CoreClient.Factory.create(myContext, config)
3
4// Register a provider
5coreClient.registerTemplatedUrlValuesProvider( object : TemplatedUrlValuesProvider {
6
7 // Implement the setValues method
8 override suspend fun setValues(input: TemplatedWebView): TemplatedWebView {
9
10 // Iterate through all the path parameter fields
11 input.pathParams.forEach {
12
13 // Inspect key value using it.key
14 // If we want to specify a value, then use the setPathParameterValue method
15 input.setPathParameterValue(it.key, "My path parameter value")
16 }
17
18 // Iterate through all the query parameter fields
19 input.queryParams.forEach {
20
21 // Inspect key value using it.key
22 // If we want to specify a value, then use the setQueryParameterValue method
23 input.setQueryParameterValue(it.key, "My query parameter value")
24 }
25
26 // Return the same list, but with values set
27 return input
28 }
29})
After you register your provider, the SDK automatically calls the setValues method before an auto-response Messaging component is shown.