About InterBot

InterBot is a messaging channel for bots to communicate with other bots. Bot-to-bot communication dramatically enhances the capabilities of the bot ecosystem. Developers can create new bots simply by composing them in a particular sequence. Other developers will create utility bots to support bot composition. Bots will provide trust, verification, payments and monetization services to each other. Bot-to-bot communication will enable marketplaces, networks, hierarchies and other advanced configurations. Bots will be able to search and discover other bots and compose new ones. Bots will be able to expand their capabilities and upgrade themselves by using newer component bots. The possibilities are endless - we can't wait to see what the developers come up with.

Interbot is powered by Gupshup.

function MessageHandler(context, event) { } function EventHandler(context, event) { } function HttpResponseHandler(context, event) { } function DbGetHandler(context, event) { } function DbPutHandler(context, event) { }
function MessageHandler(context, event) { var channelName = event.contextobj.channeltype; var senderName = event.senderobj.channelid; context.console.log("refid : "+refid+" ; senderName : "+senderName); var ibcbots = botmap.split("|"); var position = ibcbots.indexOf("@"+senderName); var nextBot = ibcbots[position+1] var lastBot = ibcbots[ibcbots.length-1].replace(/@/g,""); context.console.log("nextBot : "+nextBot); if(channelName == "ibc"){ var refid = event.contextobj.refid; if(position < 0 && senderName!=botName){ //IBC Init Point if(!context.simpledb.botleveldata[refid]){ context.simpledb.botleveldata[refid]=senderName; context.simpledb.saveData(sendIBCMessage(context,ibcbots[0].replace(/@/g,""),refid,event.message)); }else{ delete(context.simpledb.botleveldata[refid]) return; } }else if(nextBot){ sendIBCMessage(context,nextBot.replace(/@/g,""),refid,event.message); }else{ recBotname = context.simpledb.botleveldata[refid]; try{ var userContext = JSON.parse(recBotname); delete context.simpledb.botleveldata[refid]; context.simpledb.saveData(sendMsg(context,recBotname,event.message)); }catch(err){ delete context.simpledb.botleveldata[refid]; context.simpledb.saveData(sendIBCMessage(context,recBotname,refid,event.message)); } } }else{ var _event = event; var _context = context; generateRefid(function(context,event){ var refid = String(event.getresp); context.simpledb.botleveldata[refid] = JSON.stringify(_event.contextobj); context.simpledb.saveData(sendIBCMessage(context,ibcbots[0].replace(/@/g,""),refid,_event.message)); }); } } function generateRefid(cb){ var url = envurl+botName+'/refid'; var headers = { 'content-type': 'application/x-www-form-urlencoded', 'apikey': apikey } context.simplehttp.makePost(url, "", headers,cb); } function sendIBCMessage(context,recipientName,refid,message) { var url = envurl+botName+'/sendmsg'; var headers = { 'content-type': 'application/x-www-form-urlencoded', 'apikey': apikey } var formData = 'refid=' + refid + '&message=' + message+'&destbotname='+recipientName; context.simplehttp.makePost(url, formData, headers); } function sendMsg(context,userContext,message){ var url = botenvurl+botName+'/msg'; var headers = { 'content-type': 'application/x-www-form-urlencoded', 'apikey': apikey } var formData = 'context=' + userContext + '&message=' + message+"&bypass=true"; context.simplehttp.makePost(url, formData, headers); } /** Functions declared below are required **/ function EventHandler(context, event) {} function HttpResponseHandler(context, event) {} function DbGetHandler(context, event) {} function DbPutHandler(context, event) {}