Giter Club home page Giter Club logo

ibm / cognitiveconcierge Goto Github PK

View Code? Open in Web Editor NEW
94.0 24.0 52.0 34.72 MB

WARNING: This repository is no longer maintained :warning: This repository will not be updated. The repository will be kept available in read-only mode.

Home Page: https://developer.ibm.com/patterns/build-a-cognitive-recommendation-app-with-swift/

License: Apache License 2.0

Makefile 0.67% Swift 98.51% Ruby 0.13% Shell 0.69%
ict bluemix swift ibm-bluemix ibm-cloud ios-app ios-swift ios-tutorial ibm-watson-services ibmcode

cognitiveconcierge's Introduction

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

Apache 2 Build Status

CognitiveConcierge

Watson Conversation is now Watson Assistant. Although some images in this code pattern may show the service as Watson Conversation, the steps and processes will still work.

CognitiveConcierge is an end-to-end Swift application sample with an iOS front end and a Kitura web framework back end. This application also demonstrates how to pull in a number of different Watson services to your Swift client and server side apps via the Watson Developer Cloud's Swift SDK, including Watson Assistant, Text to Speech, Speech to Text, and the Natural Language Understanding service.

Included Components

  • Watson Assistant service
  • Watson Text to Speech service
  • Watson Speech to Text service
  • Watson Natural Language Understanding service
  • Google Places API

Flow

Application Workflow

  1. The user deploys the server application to IBM Cloud.

  2. The user interacts with the iOS application.

  3. When the user performs an action, the iOS application will call the server application API, which uses Watson services and the Google Places API to provide recommendations to the user.

Prerequisites

  • Obtain a Google Places API Key for Web: For this project, you'll need an API Key from Google Places, so that the app has access to user reviews which will be sent to the Natural Language Understanding service for analysis. Instructions for obtaining a key can be found here. Once you have an API Key, go to Google's Developer Console, create a project, add your API key, and enable the Google Places API for iOS as well. Make note of the API key for later use in your server and iOS applications.

If you haven't done so yet, you also need to download and install the following:

Steps

Run the following steps to deploy the application:

1. Deploy the Server Application

There are 3 ways to deploy the server application:

a) Using the Deploy to Bluemix button

Clicking on the button below creates an IBM Cloud DevOps Toolchain and deploys this application to the IBM Cloud. The manifest.yml file [included in the repo] is parsed to obtain the name of the application, configuration details, and the list of services that should be provisioned. For further details on the structure of the manifest.yml file, see the Cloud Foundry documentation.

Deploy to Bluemix

Once deployment to the IBM Cloud is completed, you can view the deployed application and services from your IBM Cloud account.

b) Using the IBM Cloud command line interface

You can also manually deploy the Server Application to the IBM Cloud. While it isn't as magical as using the "Deploy to IBM Cloud" button above, manually deploying the app provides some insight as to what's happening behind the scenes. Remember that you'd need the IBM Cloud command line installed on your system to deploy the app to the IBM Cloud.

Execute the following command to clone the Git repository:

git clone https://github.com/IBM/CognitiveConcierge

Go to the project's root folder on your system and execute the Cloud-Scripts/services/services.sh script to create the services that CognitiveConcierge depends on. Please note that you should have logged on to the IBM Cloud before attempting to execute this script. For information on how to log in, see the IBM Cloud documentation.

Executing the Cloud-Scripts/services/services.sh script:

$ ./Cloud-Scripts/services/services.sh

c) Using the IBM Cloud GUI

If you'd like to create the services manually, or don't have the IBM Cloud CLI, you can create the following services:

Before deploying your application to the cloud, you will need to update it with the Google Places API Key. In the main.swift folder, update the value in the struct with your Google Places API Key.

After the services are created and you've updated this file, you can run the bx app push YOUR_APP_NAME command from the project's root folder (CognitiveConcierge) to deploy the server application to IBM Cloud.

Once the application is running on the IBM Cloud, you can access your application's assigned URL (i.e. route). To find the route, you can log on to your IBM Cloud account, or you can inspect the output from the execution of the bluemix app push or bx app show <application name> commands. The string value shown next to the urls field contains the assigned route. Use that route as the URL to access the sample server.

$ bx app show CognitiveConcierge
Invoking 'cf app CognitiveConcierge'...

Showing health and status for app CognitiveConcierge in org [email protected] / space dev as [email protected]...
OK

requested state: started
instances: 1/1
usage: 512M x 1 instances
urls: cognitiveconcierge-lazarlike-archaizer.mybluemix.net
last uploaded: Mon Jun 5 18:01:42 UTC 2017
stack: cflinuxfs2
buildpack: swift_buildpack

     state     since                    cpu    memory         disk           details
#0   running   2017-06-05 11:05:41 AM   0.3%   6.4M of 512M   269.8M of 1G

2. Update Assistant Service

  • The Watson Assistant service enables you to add a conversational natural language interface to your applications. The Watson Assistant service requires some initial workspace configuration. Go to the IBM Cloud dashboard and launch the Watson Assistant service. It should be named along the lines of CognitiveConcierge-Assistant. Populate the workspace by clicking the upload button, and then select the JSON file at Resources/conversationWorkspace.json. Take note of the workspace ID for later use in the iOS application.

3. Run the iOS Application

Install the necessary dependencies

  • From Terminal, navigate into the CognitiveConcierge/CognitiveConcierge-iOS folder, and run the following command to install the necessary dependencies (this may take some time):
carthage update --platform iOS
pod install

Update configuration for iOS app

  • Open the CognitiveConcierge.xcworkspace file in Xcode 9.4 from your terminal using open CognitiveConcierge.xcworkspace, or by double-clicking it in Finder.

  • Update CognitiveConcierge.plist file: One way to persist data in Swift is through property list or .plist files. You will need to open this file and add the credentials for all of the services you created earlier, as well as the Google Places API Key mentioned in the Prerequisites section. You can find these services in the Bluemix dashboard. Click the service name you're interested in, and then click Service Credentials. If there is no Credential created, click New Credential. If your Assistant service uses an API Key, remove the ConversationUsername and ConversationPassword keys from the file; if not, remove the ConversationIamApiKey key.

  • Update bluemix.plist file:

    • If you're running the server application locally, you should set the isLocal value to YES; if you set the value to NO, then you will be accessing the server instance running on the IBM Cloud.
    • To get the appRouteRemote value, you should go to your application's page on the IBM Cloud. There, you will find a View App button towards the top right. Clicking on it should open up your app in a new tab, and the url for this page is your route, which maps to the appRouteRemote key in the plist. Make sure to include the http:// protocol in your appRouteRemote and to exclude a forward slash at the end of the url.
    • You can also use the command bx app env CognitiveConcierge, in which appRouteRemote is the value in the uris key.
     {
      "VCAP_APPLICATION": {
       "application_id": "3d06c0e7-1fff-4dbf-b0cb-b289770eccfe",
       "application_name": "CognitiveConcierge",
       "application_uris": [
        "cognitiveconcierge-lazarlike-archaizer.mybluemix.net"
       ],
       "application_version": "3ef63168-35f5-4517-84e9-e8f19c8f34b4",
       "limits": {
        "disk": 1024,
        "fds": 16384,
        "mem": 512
       },
       "name": "CognitiveConcierge",
       "space_id": "2b3083b9-7ef9-4d55-9741-34433be4cea1",
       "space_name": "dev",
       "uris": [
        "cognitiveconcierge-lazarlike-archaizer.mybluemix.net"
       ],
       "users": null,
       "version": "3ef63168-35f5-4517-84e9-e8f19c8f34b4"
      }
     }
    
     Running Environment Variable Groups:
     BLUEMIX_REGION: ibm:yp:us-south
    
     Staging Environment Variable Groups:
     BLUEMIX_REGION: ibm:yp:us-south

Running the application

Press the Run button in Xcode to build and run the project in the simulator or on your iPhone!

Running the Kitura-based server locally

Before building the CognitiveConcierge-Server application, first update the credentials in the config/nlu-creds file for local development.

You can then build the CognitiveConcierge-Server by going to the CognitiveConcierge-Server directory of the cloned repository and running swift build. To start the Kitura-based server for the CognitiveConcierge app on your local system, go to the CognitiveConcierge-Server directory of the cloned repository and run .build/debug/CognitiveConcierge. You should also update the bluemix.plist and CognitiveConcierge.plist file in the Xcode project in order to have the iOS app connect to this local server. See the Update configuration for iOS app section for details.

CognitiveConcierge App video

cognitive concierge video

Learn More About

Troubleshooting

  • If the deployment for server application stage fails, redeploy the pipeline stage.
  • If the IOS application is not able to connect to Watson Services, recheck the credential values in CognitiveConcierge.plist and bluemix.plist files.

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

cognitiveconcierge's People

Contributors

bvennam avatar dolph avatar glennrfisher avatar imgbot[bot] avatar ishangulhane avatar kant avatar ljbennett62 avatar rolivieri avatar sanjeevghimire avatar schen22 avatar stevemart avatar tanmayb123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cognitiveconcierge's Issues

Problem with swift version of framework and with downloading WDC sdk

$ carthage update --platform iOS
*** Downloading ios-sdk.framework binary at "v0.10.0"
*** Skipped installing ios-sdk.framework binary due to the error:
	"Incompatible Swift version - framework was built with 3.0.1 and the local version is 3.0.2."
*** Checking out ios-sdk at "v0.10.0"
*** xcodebuild output can be found in /var/folders/5g/80t605ps16xc2n03ldw25gmm0000gp/T/carthage-xcodebuild.YhpVMD.log
xcodebuild timed out while trying to read WatsonDeveloperCloud.xcodeproj 😭

Carthage update fails because of a timeout.

"Use legacy swift version" error when building in Xcode 8.2

The latest repo has been updated to Swift 3, but does not build. I get this error:

Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly

Carthage update command fails while trying via brew

FYI..
The command : carthage update --platform iOS fails with an error show below post the brew update and brew install carthage. Works fine when carthage is installed via .pkg

dyld: Library not loaded: @rpath/CarthageKit.framework/CarthageKit
Referenced from: /usr/local/bin/carthage
Reason: image not found
Abort trap: 6

May be the same issue mentioned in this link

Carthage issue building the first time

Wouldn't build on my machine, with unhelpful NSInternalInconsistencyException error when running carthage update --platform iOS step.

Tracked it down, and for some reason Carthage was pulling the wrong version of the Watson ios-sdk. Changed Cartfile to this, and it fixed the build process:

# cartfile contents
github "watson-developer-cloud/ios-sdk" == 0.8.2

Selecting Restaurants collection cell error

When select the restaurants Collection cell I'm getting this error:

RestKit was compiled with optimization - stepping may behave oddly; variables may not be available.

Any suggest ?

Sentiment data does not look accurate

To reproduce --

  • Occasion: Anniversary
  • Location: Las Vegas
  • Restaurant: Grand Lux Cafe (5th option)

Note that positive sentiments include "kids", and negative includes "husband". That was unexpected for the anniversary occasion.

image

iOS Build failed due to SpeechRecognitionResults

After cloning and following the steps provided, the iOS build failed. I tried to look through some of the errors and i found in /Controllers/MessagesViewController/MessageViewModel on line 220. I get an error related to SpeechRecognitionResults. Specifically results.bestTranscript, looking through the documentation(https://www.ibm.com/watson/developercloud/speech-to-text/api/v1/#recognize_sessionless_nonmp12) and scrolling down to SpeechRecognitionResults object. There is no .bestTranscript

Am i the only one who is having this problem?

Compilation error

Hi there,

After doing necessary carthage update and pod install, it shows compilation error.
screen shot 2017-11-02 at 2 50 39 pm

Tutorial is flawed

Trying to follow along in the tutorial:
https://github.com/IBM-MIL/CognitiveConcierge

step:
4. Once the project is cloned, open up the .xcodeproj file that was created for you in ICT under Local Server Repository. Edit the Sources/restaurant-recommendations/main.swift file's Constants struct with your own Google API Key for Web.

Can't edit 'main.swift' because it DOESN'T EXIST.

How can the tutorial be this far off?

It looks like there was an update a few days ago to the code.... don't they cross-check code updates to the actual tutorial so that they are in sync ?

Very frustrating and disappointing.

:(

Deploy to IBM Cloud button doesn't provision the required services

The manifest.yml file [included in the repo] is parsed to obtain the name of the application, configuration details, and the list of services that should be provisioned.
There are no services listed in manifest.yml and therefore no service instances are provisioned after deployment has completed. Looks like the instructions need to be updated.

Image not found for AssistantV1 framework

When you run the latest version, you will get the following error:

dyld: Library not loaded: @rpath/AssistantV1.framework/AssistantV1 Referenced from: /Users/tanmaybakshi/Library/Developer/CoreSimulator/Devices/A43DC0EF-27AD-4EE0-9F49-994C2E482ED8/data/Containers/Bundle/Application/7A2E5529-B725-48EB-8F76-99F678020532/CognitiveConcierge.app/CognitiveConcierge Reason: image not found

Because of the conversationv1 to assistantv1 change.

carthage update --platform iOS fails

Following the instructions

From Terminal, change directories into the YourProjectName/CognitiveConcierge-iOS folder and run the following command to install the necessary dependencies (This may take some time):

this error is raised:

$ carthage update --platform iOS
*** Cloning swift-sdk
*** Cloning Starscream
*** Checking out Starscream at "3.0.5"
*** Checking out swift-sdk at "v0.29.0"
*** xcodebuild output can be found in /var/folders/cs/560yb9sn0xv9h_gw47z5l1140000gn/T/carthage-xcodebuild.W7WOKH.log
*** Downloading swift-sdk.framework binary at "v0.29.0"
*** Skipped building Starscream due to the error:
Dependency "Starscream" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/daltoniam/Starscream/issues/new

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.