The SmartFollowup is an intuitive example usage of Bluemix Push Notifications Service with the help of Watson Tone Analyzer Service , OpenWhisk and Cloudant Service.
The SmartFollowup app will register a feedback on the recently purchased items to the cloudant complaints database. The OpenWhisk will read changes in the complaints and will send data to Watson Tone Analyzer. The Tone Analyzer will send back the results to OpenWhisk. By analyzing the results, OpenWhisk will fetch appropriate message from Cloudant moods database and construct a valid message. This message gets pushed to IBM Push Notifications service, and is delivered to the mobile device.
- iOS 10
- Xcode 8.+
- Swift 3.+
- Cocoapods
Complete the steps:
Go to https://console.ng.bluemix.net and Log in. Click on Catalog on the top bar.
-
On the left pane click on
Mobilebelow Apps. Create aPush notification service.
-
Create an
Mobile Foundationservice.
-
Click on Catalog on the top bar. On the left pane click on
WatsonbelowServices.Create aWatson Tone AnalyzerService.
-
Create a database named
moodin your Cloudant. In themooddatabase, create a view namednew_viewand design namedmoodPick. -
Click the new design document you have created in step 3 and update it with the following lines. Do not have to change the
_idand_revvalues.
{
"_id": "_design/moodPick",
"_rev": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"indexes": {
"fields": {
"analyzer": "keyword",
"index": "function(doc) {index("default", doc._id, {"facet": true});if ((doc.mood) || (doc.mood===0)){index("doc.mood", doc.mood);}if ((doc.message) || (doc.message===0)){index("message", doc.message);}}"
}
},
"views": {
"new_view": {
"map": "function (doc) { emit(doc.mood,doc.message);}"
}
},
"language": "javascript"
}
- To the updated new design document, add messages for each emotions -
Fear, Sadness, Disgust, Anger and Joy(Watson Tone Analyzer outputs). For example,
{
"mood": "Joy",
"message": "thank you very much for your valuable feedback. We are extremely happy to here from you. Come back again have a wonderfull shopping experience with us."
}
- In your Cloudant, create one more database named
complaints. This will be used in iOS application
Go to your push service and add iOS configuration. Please follow the doc here to create iOS certificates
The BlueShoping.swift file need the following parameters to complete the actions.
-
appId- Bluemix app GUID. -
appSecret- Bluemix Push Notification service appSecret. -
version- This is the version of the Tone Analyzer service . -
cloudantUserName- Your Cloudant username. This is for accessing yourmooddatabase in Cloudant. -
cloudantPermissionKey- Your Cloudant cloudantPermission Key. This is for accessing yourmooddatabase in Cloudant. -
cloudantPermissionPassword- Your Cloudant cloudantPermission Password. This is for accessing yourmooddatabase in Cloudant.
- Open the OpenWhisk Web Editor, and create
swiftaction. Replace the content of the action withBlueShoping.swift - Create a Cloudant package binding using the Bluemix OpenWhisk CLI.
wsk -v package bind /whisk.system/cloudant CloudantPackage -p username 'cloudantUsername' -p password 'cloudantPassword'
-p host 'yourUserName.cloudant.com' -p dbname 'complaints'
- Create a OpenWhisk
Trigger.
wsk trigger create yourTriggerName --feed /yourNameSpace/CloudantPackage/changes
- Create a rule to connect your action (step 1) and trigger (step 3)
wsk rule create myRule yourTriggerName yourActionName
- Open the SmartFollowup app in
XCode.app. Go to thebluemixCredentials.plistfile and add values for ,
-
Do
pod installin the application. And openBlueShopping.xcworkspace -
Run the application and Login using AppID.
-
Go to the feedback page and send feedback.
-
You will get push notifications as feedback response.
Copyright 2017-2018 IBM Corporation
Licensed under the Apache License, Version 2.0 (the "License").
Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license. `

