 import CloudFoundryEnv
 import KituraBot
 import KituraBotFacebookMessenger
+import KituraBotMobileAPI
 //import CloudFoundryDeploymentTracker
 
 // Disable all buffering of stdout

    // OpenWhisk chain will use a specific KituraBotPushAction to send back to KituraBot in a asyncronous way the response message to send back to client
    
    //1.b return immediate Syncronouse response or return nil to do not send back any Syncronous response message
    return responseMessage
}
        
        
///3.b [Optional] Activate Async Push Back cross channel functionality
bot.exposeAsyncPush(securityToken: Configuration.pushApiSecurityToken, webHookPath: "/botPushApi") { (channelName: String, senderId: String, message: String) -> (channelName: String, message: String)? in
    //The implementation of exposePushBack method in KituraBot class will automatically expose REST interface to be called by the Async logic (i.e. KituraBotPushAction)
    
    var responseChannelName = channelName
    var responseMessage = message
    
    //3.c [Optional] implement optional logic to eventually notify back the user on different channels
    //responseChannelName = "..."
    
    ///3.d [Optional] send back Async response message
    //responseMessage = "..."
    
    //3.e return new channel and message or return nil to use the passed channel and message
    //return (responseChannelName, responseMessage)
    
    return nil
}

do {
    //2.1 Add Facebook Messenger channel
    try bot.addChannel(channelName: "FacebookEcho", channel: KituraBotFacebookMessenger(appSecret: Configuration.appSecret, validationToken: Configuration.validationToken, pageAccessToken: Configuration.pageAccessToken, webHookPath: "/webhook"))

    //2.2 Add MobileApp channel (use Push Notification for Asyncronous response message
    try bot.addChannel(channelName: "MobileAppEcho", channel: KituraBotMobileAPI(securityToken: Configuration.mobileApiSecurityToken, webHookPath: "/mobileapi"))

    //2.3 Add Slack, Skype etc. channels
    //try bot.addChannel(channelName: "SlackEcho1", KituraBotSlack(slackConfig: "xxx", webHookPath: "/echo1slackcommand"))
    //try bot.addChannel(channelName: "SkypeEcho1", KituraBotSkype(skypeConfig: "xxx", webHookPath: "/echo1skypewebhook"))
} catch is KituraBotError {
    Log.error("Oops... something wrong on Bot Channel name")
}
