No description, website, or topics provided.
Swift Ruby Objective-C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Barnabot.xcodeproj fix merge Feb 15, 2017
Barnabot fix merge Feb 15, 2017
BarnabotTests persisted userData Feb 15, 2017
fastlane fastlane deploy Feb 15, 2017
.gitignore gitignore update Feb 15, 2017
.travis.yml fix version Jan 31, 2017
Barnabot.podspec fastlane deploy Feb 15, 2017
Gemfile fix test' Jan 30, 2017
LICENSE Initial commit Jan 25, 2017
README.md Update README.md Feb 16, 2017

README.md

Build Status

BarnaBot

class ChatViewController: JSQMessagesViewController, BBSessionDelegate {

    
    let botBuilder : BBBuilder = BBBuilder("Barnabot")
       let botSession : BBSession = BBSession.sharedInstance

    func send(_ msg: String) {
            print("send from BBSessionDelegate")
            let message = JSQMessage(senderId: botBuilder.botName, senderDisplayName:   botBuilder.botName, date: Date.init(), text: msg as String!)
            self.messages.append(message!)
            self.finishSendingMessage(animated: true)
        }

    // TODO inutile
       func receive(_ msg : String) {
            botSession.receive(msg)
        }

    override func viewDidLoad() {
    
    botBuilder
            .dialog(path: "/", dialog: BBDialog(waterfall: [{(session : BBSession, next : BBDialog?) -> Void in
                if let name = session.userData["name"] {
                    if let _next = next {
                        _next.next(session, nil)
                    }
                } else {
                    session.beginDialog(path: "/profile")
                }
                },
                {(session : BBSession, next : BBDialog?) -> Void in
                    if let name = session.userData["name"] {
                        //session.send(format: "Hello %s!", args: name as AnyObject)
                        session.send("Hello \(name)!")
                    }
                }]))
            .dialog(path: "/profile", dialog : BBDialog(waterfall: [{(session : BBSession, next : BBDialog?) -> Void in

                print("/profile dialog")
                session.promptText("Hi! What is your name?")

                },{(session : BBSession, next : BBDialog?) -> Void in

                    session.userData.updateValue(session.result, forKey: "name")
                    session.endDialog()

                }]))

        botSession.botBuilder = botBuilder
        botSession.delegate = self
    
    }//viewDidLoad

    override func viewDidAppear(_ animated: Bool) {
            botSession.beginConversation()
        }

}