Channel transfers enable you to move a conversation with a user to another integrated channel, while preserving the conversation history and unifying the user’s identity in the backend of your software. It allows businesses and end-users to have conversations on whichever channel is better suited for the topic at hand and to benefit from a single, continuous, cross-channel conversation thread. Changing channels can be used to:
By leveraging the auth code and link request APIs, links can be generated and sent to users to direct them to the channel of your choice.
The guides below cover how to achieve this transfer in either direction:
The scenario below demonstrates how a customer Sue can begin a conversation with her bank on Facebook, and continue the same conversation on the bank’s own website. The flow chart below summarizes what we’re about to cover:
Sue is looking to set up a new bank account at Acme Bank. She first reaches out on their Facebook page. Acme Bank’s Facebook page is integrated with Sunshine Conversations, so Sue’s conversation shows up as a new conversation in Acme Bank’s helpdesk software.
Sue is now in the Acme banking app, but she hasn’t yet logged in. She does however see the history of messages that were sent between her and Ash over Facebook replicated here.
On Ash’s end, the conversation continues within the same help desk context as before and the help desk indicates that Sue is now talking to him via the Acme banking app. Ash directs Sue to log in.
The banking app validates Sue's Acme Bank account credentials. In doing so, Acme Bank issues a JWT for Sue and includes it in the dashboard login response. In the browser, the dashboard logs Sue in to Sunshine Conversations using this JWT.
Smooch.login('sue_purb@lunamail.com', '{jwt}').then(
function() {
// Your code after login is complete
},
function(err) {
// Something went wrong during login. Your JWT might be invalid
}
);
Smooch.login("sue_purb@lunamail.com", jwt:"{jwt}") { ( error:Error? , userInfo:[AnyHashable : Any]?) in
if (error == nil) {
// Your code after login is complete
} else {
// Something went wrong during login. Your JWT might be invalid
}
}
Smooch.login("sue_purb@lunamail.com", "{jwt}", new SmoochCallback() {
@Override
public void run(Response response) {
if (response.getError() == null) {
// Your code after login is complete
} else {
// Something went wrong during login. Your JWT might be invalid
}
}
});
Ash sees that Sue has logged in and helps her complete the application to set up her bank account.
userId
and an Acme Bank account that she can log in to, the channel transfer process is simpler. The flow chart below shows the difference:For example, suppose a few years later Sue is shopping for a mortgage. She again contacts Acme Bank over Facebook. This time a different agent named Bishop responds with some rates. Sue finds the rates attractive and wishes to proceed. Bishop once again sends her a link to the Acme banking app.
The help desk has seen Sue before and it recognizes that she has multiple channels connected: Facebook Messenger, Web, and possibly iOS or Android. It also sees that Sue has a valid userId that matches an existing account on record at Acme Bank. Because of this, no auth code is required, the help desk only needs to send Sue to the dashboard login page:
https://acme-bank.com/login
Sue visits the link and logs in. She can now seamlessly continue her conversation with Bishop from the banking app.
When supplying an expired or otherwise invalid auth code at init time, the init flow will return an error and leave the SDK in an uninitialized state. Your code should account for this possibility and gracefully handle the error. You may also choose to display an error to the user in this case. If you prefer to ignore the error and continue execution anyways, your code should call init again without an auth code in order to trigger a new initialization process as the previously logged in user.
In this example we’ll show how a conversation can be transferred from a Sunshine Conversations SDK to a third party messaging app, in this case Facebook Messenger. The flow chart below summarizes this process:
Sue wants to switch to a credit card that offers more points. She browses to her bank’s website and asks a question.
An agent named Ash helps Sue choose a credit card and opens an application for her. Ash tells Sue that the process should take one day to complete.
Ash then invites Sue to link the conversation to a 3rd party messaging channel of her choice so that she can receive a notification as soon as her application completes. In the help desk software, Ash selects a menu option “Transfer to messaging app”. Sue is then presented with a list of channels to choose from.
The help desk software queries the Sunshine Conversations integrations API for a list of available messaging app integrations. Acme Bank has previously configured Facebook and Telegram integrations, so they appear in the response payload. Using the integrationIds returned, the dashboard calls the Sunshine Conversations link request API to generate channel transfer links for Sue to use.
{
"linkRequests": [
{
"integrationId": "59dbd737f294ea1fa2734829",
"type": "messenger",
"code": "lr_K4DBnWEiWv6LR-CP0j_5FFcl",
"url": "https://m.me/123456781234567?ref=lr_K4DBnWEiWv6LR-CP0j_5FFcl"
},
{
"integrationId": "59fa19888b1dd03638d2dd54",
"type": "telegram",
"code": "lr_Xidl9tTWt6YVXP8SFD3hdUiD",
"url": "https://telegram.me/your_telegram_bot?start=lr_Xidl9tTWt6YVXP8SFD3hdUiD"
}
]
}
Note: Link requests are one time use. See more details here.
{
"text": "Choose your preferred channel:",
"role": "appMaker",
"type": "text",
"actions": [
{
"type": "link",
"text": "Facebook Messenger",
"uri": "https://m.me/123456781234567?ref=lr_K4DBnWEiWv6LR-CP0j_5FFcl"
},
{
"type": "link",
"text": "Telegram",
"uri": "https://telegram.me/your_telegram_bot?start=lr_Xidl9tTWt6YVXP8SFD3hdUiD"
}
]
}
Sue clicks the Facebook link which takes her into a Facebook Messenger conversation with Acme Bank.
Acme Bank receives a client:add webhook event from Sunshine Conversations. The webhook payload includes Sue's basic profile information from Facebook:
{
"trigger": "client:add",
"app": {
"_id": "575040549a38df8fb4eb1e51"
},
"version": "v1.1",
"appUser": {
"_id": "de13bee15b51033b34162411",
"email": "steve.bob@email.com",
"surname": "Steve",
"givenName": "Bob",
"signedUpAt": "2018-04-02T14:45:46.505Z",
"properties": { "favoriteFood": "prizza" }
},
"clients": [
{
"_id": "5c93cb748f63db54ff3b51dd",
"status": "active",
"integrationId": "5a99b74858247c608f64a348",
"externalId": "1128837457239041",
"id": "bea02e14-86f4-4711-8ecc-ab717ebf750a",
"displayName": "Sue Purb",
"info": {
"gender": "female",
"timezone": -5,
"locale": "en_US",
"avatarUrl": "https://scontent.xx.fbcdn.net/example.png"
},
"lastSeen": "2019-01-14T19:11:17.783Z",
"linkedAt": "2019-01-14T19:11:17.783Z",
"avatarUrl": "https://scontent.xx.fbcdn.net/example.png",
"primary": true,
"platform": "messenger",
"active": true,
"blocked": false
}
]
}
In response to this webhook, the help desk software notifies Ash that Sue has linked a new Facebook Messenger client.
Ash sends Sue another message to let her know she can continue the conversation over Facebook Messenger. Sue sees this message in Facebook Messenger while the conversation log continues to be replicated in her browser chat window.
The following day, Sue’s application completes. Acme Bank sends a notification to let Sue know, and she receives the message via a Facebook Messenger push notification on her phone, and she continues the conversation with Acme Bank from there.