Code Monkey home page Code Monkey logo

smartfollowup's Introduction

SmartFollowup

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.

Requirements

  • iOS 10
  • Xcode 8.+
  • Swift 3.+
  • Cocoapods

Setup Bluemix and Cloudant.

Complete the steps:

Go to https://console.ng.bluemix.net and Log in. Click on Catalog on the top bar.

  1. On the left pane click on Mobile below Apps. Create a Push notification service.

  2. Create an Mobile Foundation service.

  3. Click on Catalog on the top bar. On the left pane click on Watson below Services.Create a Watson Tone Analyzer Service.

  4. Create a database named mood in your Cloudant. In the mood database, create a view named new_view and design named moodPick.

  5. Click the new design document you have created in step 3 and update it with the following lines. Do not have to change the _id and _rev values.

{
  "_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"
}

  1. 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."
}
  1. In your Cloudant, create one more database named complaints. This will be used in iOS application

Configure Push service

Go to your push service and add iOS configuration. Please follow the doc here to create iOS certificates

Setup the OpenWhisk.

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 your mood database in Cloudant.

  • cloudantPermissionKey - Your Cloudant cloudantPermission Key. This is for accessing your mood database in Cloudant.

  • cloudantPermissionPassword - Your Cloudant cloudantPermission Password. This is for accessing your mood database in Cloudant.

  1. Open the OpenWhisk Web Editor, and create swift action. Replace the content of the action with BlueShoping.swift
  2. 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'
  1. Create a OpenWhisk Trigger.
wsk trigger create yourTriggerName --feed /yourNameSpace/CloudantPackage/changes
  1. Create a rule to connect your action (step 1) and trigger (step 3)
wsk rule create myRule yourTriggerName yourActionName
  1. Open the SmartFollowup app in XCode.app. Go to the bluemixCredentials.plist file and add values for ,

  1. Do pod install in the application. And open BlueShopping.xcworkspace

  2. Run the application and Login using AppID.

  3. Go to the feedback page and send feedback.

  4. You will get push notifications as feedback response.

License

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. `

smartfollowup's People

Contributors

ananthakrish avatar

Watchers

 avatar  avatar  avatar

Forkers

abhishekraja1

smartfollowup's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.