Starting a conversation via API

Start a conversation with the respondent.

Triggering a conversation via an API allows companies to initiate conversations — possibly for surveys — by launching the conversation on a Custom channel. The trigger mechanism works by making a POST API request to the Custom channel. The message payload includes the information necessary to launch the conversation and send it to the respondent via the Custom channel adapter. As the respondent interacts with the conversation, Medallia Conversations passes the relevant information to Medallia Experience Cloud which uses it to updates the conversation/survey record.

API trigger call starts conversation on custom channel, results are fed to the database

The adapter makes an API call to Medallia Conversations and passes the following information to initiate the conversation:

  • a Conversation keyword that uniquely identifies and triggers the conversation.

  • recipient ID that tells the custom channel adapter how to contact the respondent, such as a phone number, email address, or some other channel-specific value.

  • parameter values to record with the conversation (as E-fields in the survey record). For a survey, these include the Unit ID associated with the survey, and other information the company wants to include in the survey record, such as a brand name, and agent name or ID, or store identifier.

Once the conversation is triggered, communication between the adapter and Medallia Conversations begins.

Request URL

{conversations-api-gateway-host}/apis/v0/channels/{channel-guid}/messages

Where

  • conversations-api-gateway-host: the Medallia Experience Cloud hostname to access the Medallia Conversations API gateway.
  • channel-guid: the ID of the Custom Channel assigned in Medallia Conversations.

Request headers

accept: text/plain 
authorization: Bearer 12345
content-type: application/json

For information about the authorization header, see Adapter authentication.

Request payload

The inbound payload has a message element that includes both the trigger keyword that initiates the start of the conversation, and a message ID generated by the adapter/channel service to track the messages for the respondent. Additionally, the trigger_params element contains information about the respondent to be recorded in the Medallia Experience Cloud database.

{
	"object":"page",
	"entry": [{
		"id": "<PAGE_ID>",
		"time": "<UNIX_TIMESTAMP>",
		"messaging": [{
			"sender": { "id": "<CUSTOMER_ID>" },
			"recipient": { "id": "<PAGE_ID>" },
			"message": {
				"mid": "<MESSAGE_ID>",
				"text": "<KEYWORD>",
			},
			"trigger_params": {
				"override_session": false,
				"consumer": {
					"name": "Casey Harley",
					"email": "casey_harley@example.com",
					"first_name": "Casey", 
					"last_name": "Harley"
				},
				"custom": {
					"unitID" : "<UNIT_ID>",
					"<PARAMETER_1_NAME>": "<PARAMETER_1_VALUE>",
					"<PARAMETER_2_NAME>": "<PARAMETER_2_VALUE>"
				}
			}
		}]
	}]
}

Request parameters

object string requiredAlways "page".
entry array requiredOne or more sets of messages (an "entry") targeted to a single channel (a "page").
entry:id string or integer requiredPage ID of the Medallia Conversations Channel — as defined in its Authentication settings — that identifies the unique adapter instance associated with the channel. This value must match the recipient:id for the inbound messages.
time integerUnix epoch timestamp of the last event associated with the element. For example, when it was a multi-part message, this is the time of the last message-part.
messaging array requiredOne or more message objects.
sender:id string or integer requiredIdentifier unique to the respondent, such as phone number, email, or other channel-specific value. For phone numbers, the ID must be in E.164 format.
recipient:id string or integer requiredPage ID of the Medallia Conversations Channel — as defined in its Authentication settings — that identifies the unique adapter instance associated with the channel. This value must match the recipient:id for the inbound messages.
timestamp integerUnix epoch timestamp of the last event associated with the element. For example, when it was a multi-part message, this is the time of the last message-part.
mid stringAn identifier of the message. Created and used by the adapter/channel service to track the message.
text string requiredKeyword that starts a specific conversation. For details, see Set the Keyword that identifies the conversation.
trigger_params objectOptional information to be recorded in the Medallia Experience Cloud database record.
override_session Boolean
  • true — Always (re)trigger a new conversation with the customer.
  • false — Do not trigger a new conversation if one is already in progress with the same respondent; continue the existing conversation.
consumerobjectEntities that identify the respondent. See Trigger parameters, below.
custom stringEntities associated with the event the respondent is providing feedback about. See Trigger parameters, below.

Response

ResponseDescription
200The request was processed as expected.
401Unauthorized. The reason is provided in a human-readable string.
403Forbidden.
  • statusCode: The HTTP status code.

  • error: The error code.

  • message: The error message.

500

Internal server error.

  • statusCode: The HTTP status code.

  • error: The error code.

  • message: The error message.

Set the Keyword that identifies the conversation

When Medallia Conversations detects a predefined keyword as the message text, it automatically initiates the corresponding conversation with the respondent. For a custom adapter, the initial dialog is sent to the adapter, which then forwards it to the respondent.

Briefly, to define a keyword:

  1. In Medallia Conversations, edit the existing Conversation settings.

  2. Add the keyword to the Keywords option.

    Press Enter after typing the keyword text to add it to the list of keywords.

  3. Click Save to save the change.

Now the custom adapter can use the keyword to trigger the conversation with the respondent.

Trigger parameters

Trigger parameters pass respondent data from the adapter/channel service to E-Fields in the Medallia Experience Cloud database record. This data this includes information about the respondent or event, to be recorded in the feedback record. There are two optional categories of data parameters:

  • consumer parameters contain information about the respondent. These four consumer parameters, and all are optional.

    • name
    • email — when included as a consumer parameter, this option must be formatted as an email address or Medallia Conversations flags it as an error
    • first_name
    • last_name
  • custom parameters contain any information to record with the response.

    • unitId — a Unit ID is necessary for feedback requests, such as surveys, as it specifies the business unit related to the feedback.
      Tip: If all surveys on the Conversation apply to the same Unit ID, consider setting that ID as a default value in the Conversation settings instead of passing it in the trigger payload.
"trigger_params": {
	"override_session": true,
	"consumer": {
		"name": "Casey Harley",
		"email": "casey_harley@example.com",
		"first_name": "Casey", 
		"last_name": "Harley"
	},
	"custom": {
		"unitID" : "<UNIT_ID>",
		"<PARAMETER_1_NAME>": "<PARAMETER_1_VALUE>",
		"<PARAMETER_2_NAME>": "<PARAMETER_2_VALUE>"
	}
}

To access the entities in Medallia Conversations, use these identifiers in the Template Value for the Parameter definition.

{{paramsJSON.EVENT_VALUE.consumer.name}}
{{paramsJSON.EVENT_VALUE.consumer.email}}
{{paramsJSON.EVENT_VALUE.custom.unit_id}}

In Medallia Conversations, define the parameters in the Conversation Settings editor for the Conversation. For each parameter, choose the Field in the record in which to store the parameter value. And either

  • assign a default value to the field, or

  • in the Template Value, enter the JSON parameter that identifies the parameter passed to the channel in the API call.