Nuance Automaton/Rich Media Framework
Nuance Messaging SDK allows Applications to display a Survey or Guide before starting an engagement with the agent. Surveys are used to collect basic customer informations that are then send to agent.This way agents will know their customer in the begining of the engagement.
A Guide is used for helping Customer to the right Business he/she wants to engage with.
Nuance Messaging SDK also uses this framework to create rich media widgets within the chat window
Following PreChat Survey features are supported.
Survey results are send to agent as datapass.
Automaton Decison Engine can route the engagement to different AG and BU upon survey submission.
Surveys can be configured to check the agent availability post submission before routing the engagement.
Form controls that are supported by the framework are Input, Label, Checkbox, Radio Group, Heading, Select, List, Alert, Button.
Automaton allows surveys and guides to be displayed in more than one pages.
Surveys can decide the type of engagement to start post completion of the survey, either CALL or CHAT.
Importing NuanceGuide.framework to your workspace
Refer the quickstart page for the instructions.
Adding Automaton to your Application
Add an Event Observer to your view Controller to receive start chat notification upon guide completion.
Below code changes are only required if Application uses prechat survey
/* Import the following statement*/ import NuanceGuide
NGNotificationCenter.addEventObserver(self, selector: #selector(self.recieveStartChatNoti), name: NSNotification.Name(rawValue: kStartChatNotificationName), object: nil)
Add a selecter to receive the notification
NGEngageEventData object in the NSNotification parameter contains the datapass and routing information
NGEngageEventData.data object contains routing information.
NGEngageEventData.datapass object contains datapass information.
@objc func recieveStartChatNoti(noti:NSNotification) -> Void { var vc:NuanceMessagingViewController; if(NuanMessaging.getInstance().getChatProgress()) { vc = restoreMessagingViewController(webview:nil); } else { vc = launchMessagingViewController(params: self.getEngageParameters(chatEventData: noti.object as? NGEngageEventData)) } self.setupMessagingUIProps(vc:vc) self.present(vc, animated: false, completion: nil) }
Parse routing and datapass from NGEngageEvent Data
ffunc getEngageParameters(chatEventData : NGEngageEventData?) -> EngageParameters{ var engage = EngageParameters() engage.siteID = "10003715" //engage.autoID = 18000492 if (chatEventData != nil) { if(chatEventData?.data != nil) { engage.agentGroupID = chatEventData?.data["agID"] as? String engage.businessUnitID = chatEventData?.data["buID"] as? String engage.businessRuleID = chatEventData?.data["brID"] as? String engage.openerText = chatEventData?.data["openerText"] as? String } if(chatEventData?.datapass != nil) { engage.customerName = chatEventData?.datapass["customerName"] as? String engage.dataPass = chatEventData?.datapass as? [String : String] } } if(engage.agentGroupID == nil) { engage.agentGroupID = "10004026" } if(engage.businessUnitID == nil) { engage.businessUnitID = "13000508" } if(engage.businessRuleID == nil) { engage.businessRuleID = "20000" } if(engage.openerText == nil) { engage.openerText = "Hi How may i help you" } if(engage.customerName == nil){ engage.customerName = "Test" } return engage; }
Displaying Guide in the App.
var vc:NuanceMessagingViewController; if(NuanMessaging.getInstance().getChatProgress()) { vc = restoreMessagingViewController(webview:nil); setupMessagingUIProps(vc:vc) self.present(vc, animated: false, completion: nil) } else { NGGuideManager.sharedInstance().getGuideConfigs("1001") { (responseDic : Dictionary?, error : Error?) in if (error == nil) { let properties : NGGuideNavProperties = NGGuideNavProperties.init() properties.title = "Welcome PreChat Guide" properties.titleColor = UIColor.white properties.closeImage = UIImage(named:"ic_action_close.png") properties.iconImage = UIImage(named:"ic_action_mail.png") properties.styleJson = style as String? let guideInfo = try! NGGuideInfoData.init(dictionary: responseDic) let navVc : NGGuideNavController = NGGuideNavController.init(properties : properties, guideInfo : guideInfo) navVc.navigationBar.barTintColor = UIColor.blue DispatchQueue.main.async { self.present(navVc, animated: false, completion: nil) } } else { var vc:NuanceMessagingViewController; vc = launchMessagingViewController(params: self.getEngageParameters(chatEventData: nil)) self.setupMessagingUIProps(vc:vc) self.present(vc, animated: false, completion: nil) } } }
NGGuideNavProperties
iconImage | Use the property to set the title bar logos. |
title | Use the property to set the title text. |
titleColor | Use the property to set the title text color. |
closeImage | use the property to set the close image. |
styleJson | Pass an instance of JSON object containing the Guide Style information. |
Create style JSON file.
Style information for Guide elements are described in JSON format
let filePath = Bundle.main.path(forResource: "guide_cus", ofType: "json") let data = NSData.init(contentsOfFile: filePath!) let jsonDic:NSDictionary = try! JSONSerialization.jsonObject(with: data! as Data, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary let style:NSString = NSString.init(data: data! as Data, encoding: String.Encoding.utf8.rawValue)!
Defining styles information in style.json
{ "guideContainerDefault":{ "padding":5, "background":"#fafafa", }, "guideHeadingDefault":{ "textSize":16, "textStyle":"HelveticaNeue-Bold", }, "guideItemContainerDefault":{ "background":"#fafafa", }, "guideInputDefault":{ "padding":10, "marginLeft":0, "marginRight":0, "textSize":14, "textColor":"#303030" }, "guideButtonDefault":{ "background":"#D7E3D9", "textSize":16, "textColor":"#EEB422", "textStyle":"HelveticaNeue-Bold", "hightedTextColor":"#EECBAD", "disableTextColor":"#666666" } }
Styling Rich media
Use below bool properties to enable and configure the rich media containers.
Container | Properties | Sample | Description |
---|---|---|---|
showAvatarForRichWidget | showAvatarForRichWidget : Bool |
@objc public var showAvatarForRichWidget : Bool = false |
This property allows the display of avatar in rich nedia widget bubble |
Form container | formWidgetBackgroundColor : UIColor |
@objc public var formWidgetBackgroundColor : UIColor = UIColor.white |
Sets the container background color |
formWidgetTypeLeftMargin : Int |
@objc public var formWidgetTypeLeftMargin : Int = 20; |
Sets the container left margin |
|
formWidgetTypeRightMargin : Int |
@objc public var formWidgetTypeRightMargin : Int = 50; |
Sets the container right margin |
|
formWidgetTypeTopMargin : Int |
@objc public var formWidgetTypeTopMargin : Int = 50; |
Sets the container top margin |
|
formWidgetTypeBottomMargin : Int |
@objc public var formWidgetTypeBottomMargin : Int = 50; |
Sets the container bottom margin |
|
formWidgetTypePadding : Int |
@objc public var formWidgetTypePadding : Int = 10; |
Sets the container padding from all the 4 sides [left, top, right bottom] |
|
Receipt container | receiptWidgetBackgroundColor : UIColor |
@objc public var receiptWidgetBackgroundColor : UIColor = UIColor.white |
Sets the container background color |
receiptWidgetTypeLeftMargin : Int |
@objc public var receiptWidgetTypeLeftMargin : Int = 5; |
Sets the container left margin |
|
receiptWidgetTypeRightMargin : Int |
@objc public var receiptWidgetTypeRightMargin : Int = 5; |
Sets the container right margin |
|
receiptWidgetTypeTopMargin : Int |
@objc public var receiptWidgetTypeTopMargin : Int = 5; |
Sets the container top margin |
|
receiptWidgetTypeBottomMargin : Int |
@objc public var receiptWidgetTypeBottomMargin : Int = 5; |
Sets the container bottom margin |
|
Card container | cardWidgetBackgroundColor : UIColor |
@objc public var cardWidgetBackgroundColor : UIColor = UIColor.white |
Sets the container background color |
cardWidgetTypeLeftMargin : Int |
@objc public var cardWidgetTypeLeftMargin : Int = 20; |
Sets the container left margin |
|
cardWidgetTypeRightMargin : Int |
@objc public var cardWidgetTypeRightMargin : Int = 13; |
Sets the container right margin |
|
cardWidgetTypeTopMargin : Int |
@objc public var cardWidgetTypeTopMargin : Int = 50; |
Sets the container top margin |
|
cardWidgetTypeBottomMargin : Int |
@objc public var cardWidgetTypeBottomMargin : Int = 50; |
Sets the container bottom margin |
|
cardWidgetTypePadding : Int |
@objc public var cardWidgetTypePadding : Int = 10; |
Sets the container padding from all the 4 sides [left, top, right bottom] |
|
Quick reply container | quickreplyWidgetBackgroundColor : UIColor |
@objc public var quickreplyWidgetBackgroundColor : UIColor = UIColor.white |
Sets the container background color |
quickreplyWidgetTypeLeftMargin : Int |
@objc public var quickreplyWidgetTypeLeftMargin : Int = 20; |
Sets the container left margin |
|
quickreplyWidgetTypeRightMargin : Int |
@objc public var quickreplyWidgetTypeRightMargin : Int = 50; |
Sets the container right margin |
|
quickreplyWidgetTypeTopMargin : Int |
@objc public var quickreplyWidgetTypeTopMargin : Int = 50; |
Sets the container top margin |
|
quickreplyWidgetTypeBottomMargin : Int |
@objc public var quickreplyWidgetTypeBottomMargin : Int = 50; |
Sets the container bottom margin |
|
quickreplyWidgetTypePadding : Int |
@objc public var quickreplyWidgetTypePadding : Int = 10; |
Sets the container padding from all the 4 sides [left, top, right bottom] |