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.
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}/messagesWhere
- 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/jsonFor 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 required | Always "page". |
entry array required | One or more sets of messages (an "entry") targeted to a single channel (a "page"). |
entry:id string or integer required | Page 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 integer | Unix 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 required | One or more message objects. |
sender:id string or integer required | Identifier 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 required | Page 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 integer | Unix 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 string | An identifier of the message. Created and used by the adapter/channel service to track the message. |
text string required | Keyword that starts a specific conversation. For details, see Set the Keyword that identifies the conversation. |
trigger_params object | Optional information to be recorded in the Medallia Experience Cloud database record. |
override_session Boolean |
|
consumerobject | Entities that identify the respondent. See Trigger parameters, below. |
custom string | Entities associated with the event the respondent is providing feedback about. See Trigger parameters, below. |
Response
| Response | Description |
|---|---|
| 200 | The request was processed as expected. |
| 401 | Unauthorized. The reason is provided in a human-readable string. |
| 403 | Forbidden.
|
| 500 | Internal server error.
|
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:
In Medallia Conversations, edit the existing Conversation settings.
Add the keyword to the Keywords option.
Press Enter after typing the keyword text to add it to the list of keywords.
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:
consumerparameters contain information about the respondent. These four consumer parameters, and all are optional.nameemail— when included as a consumer parameter, this option must be formatted as an email address or Medallia Conversations flags it as an errorfirst_namelast_name
customparameters 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.
