11//
22// Adds meta information about the bot, and exposes them at a public endpoint
33//
4- module . exports = function ( controller ) {
4+ module . exports = function ( controller , bot ) {
55
66 //
77 // OVERRIDE WITH YOUR BOT INFORMATION
@@ -21,10 +21,10 @@ module.exports = function (controller) {
2121 "support-contact" : "Stève Sfartz <mailto:stsfartz@cisco.com>" ,
2222
2323 // Messaging platform
24- "plaform" : "ciscospark" ,
24+ "plaform" : bot . type ,
2525
2626 // the precise bot identity is loaded asynchronously, as /people/me request - issued by "BotKit CiscoSparkBot.js" - returns
27- "identity" : "convos@sparkbot.io " ,
27+ "identity" : "unknown " ,
2828
2929 // Endpoint where to check the bot is alive
3030 "healthcheck" : "https://" + controller . config . public_address + process . env . HEALTHCHECK_ROUTE ,
@@ -37,14 +37,18 @@ module.exports = function (controller) {
3737 // Adding a metadata endpoint
3838 //
3939 controller . webserver . get ( process . env . BOTCOMMONS_ROUTE , function ( req , res ) {
40+ // As the identity is load asynchronously from Cisco Spark token, we need to check until it's fetched
41+ if ( ( botcommons . identity == "unknown" ) && ( bot . botkit . identity ) ) {
42+ botcommons . identity = bot . botkit . identity . emails [ 0 ] ;
43+ }
4044 res . json ( botcommons ) ;
4145 } ) ;
4246 console . log ( "CiscoSpark: Bot metadata available at: " + process . env . BOTCOMMONS_ROUTE ) ;
4347
4448 //
4549 // .botcommons skill
4650 //
47- controller . hears ( [ / ^ \. a b o u t $ / , / ^ \. c o m m o n s $ / , / ^ \. b o t $ / , / ^ \. p i n g $ / ] , 'direct_message,direct_mention' , function ( bot , message ) {
51+ controller . hears ( [ / ^ \a b o u t $ / , / ^ \b o t c o m m o n s $ / , / ^ \. c o m m o n s $ / , / ^ \. b o t $ / ] , 'direct_message,direct_mention' , function ( bot , message ) {
4852
4953 // Return metadata
5054 var metadata = '{\n'
0 commit comments