Sample Manifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://statics.teams.microsoft.com/sdk/v1.2/manifest/MicrosoftTeams.schema.json", | |
"manifestVersion": "1.2", | |
"version": "1.0.0", | |
"id": "235d4bb2-1b66-4d27-a14b-af64882c0062", | |
"packageName": "com.bridgeoc.teamsbot", | |
"developer": { | |
"name": "Bridge Communications", | |
"websiteUrl": "https://www.bridgeoc.com", | |
"privacyUrl": "https://www.bridgeoc.com/privacy.htm", | |
"termsOfUseUrl": "https://www.bridgeoc.com/privacy.htm" | |
}, | |
"icons": { | |
"color": "color.png", | |
"outline": "outline.png" | |
}, | |
"name": { | |
"short": "All The Gifs", | |
"full": "All the Gifs" | |
}, | |
"description": { | |
"short": "An unrestricted GIF conversation addon", | |
"full": "A more robust GIF conversation addon that has no limitations on the searches returned." | |
}, | |
"accentColor": "#FEAE25", | |
"composeExtensions": [{ | |
"botId": "834ead96-f0c6-428a-b325-61f7a97cbaf6", | |
"canUpdateConfiguration": false, | |
"commands": [{ | |
"id": "searchCmd", | |
"description": "Search for your Gif", | |
"title": "Search", | |
"initialRun": true, | |
"parameters": [{ | |
"name": "searchKeyword", | |
"description": "Enter your search keywords", | |
"title": "Keywords" | |
}] | |
}] | |
}], | |
"permissions": [ | |
"identity", | |
"messageTeamMembers" | |
], | |
"validDomains": [ | |
"*.bridgeoc.com" | |
] | |
} |
Sample Node.js Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var util = require("util"); | |
var restify = require('restify'); | |
var builder = require('botbuilder'); | |
var teams = require('botbuilder-teams'); | |
var connector = new teams.TeamsChatConnector({ | |
appId: "834ead96-f0c6-428a-b325-61f7a97cbaf6", | |
appPassword: "your app password from azure Bot Channel Registration" | |
}); | |
var server = restify.createServer(); | |
server.listen(3113, function () { | |
console.log('%s listening to %s', server.name, util.inspect(server.address())); | |
}); | |
// this will reset and allow to receive from any tenants | |
connector.resetAllowedTenants(); | |
var bot = new builder.UniversalBot(connector); | |
server.post('/api/composeExtension', connector.listen()); | |
server.post('/api/messages', connector.listen()); | |
server.post('/', connector.listen()); | |
var composeExtensionHandler = function (event, query, callback) { | |
// parameters should be identical to manifest | |
console.log("Query Running"); | |
var attachments = []; | |
var gifKey = "Your Gify Key" | |
console.log("Building Card"); | |
var url = "https://api.giphy.com/v1/gifs/search?api_key=" + gifKey + "&q=" + query.parameters[0].value + "&limit=100&offset=0&rating=NSFW&lang=en"; | |
if (query.parameters[0].value == undefined | query.parameters[0].value == '') | |
{ | |
url = "https://api.giphy.com/v1/gifs/search?api_key=" + gifKey + "&q=deadpool&limit=10&offset=0&rating=NSFW&lang=en"; | |
} | |
request(url, { | |
json: true | |
}, (err, res, body) => { | |
if (err) { | |
return console.log(err); | |
} | |
var data = body; | |
for (var o of data.data) { | |
try { | |
console.log(o.title); | |
var logo = { | |
alt: o.title, | |
url: o.images.downsized_large.url | |
}; | |
var card = new builder.HeroCard() | |
.title("Title: " + o.title) | |
.text("Displaying: " + o.title) | |
.subtitle("Rating: " + o.rating) | |
.images([logo]) | |
.buttons([{ | |
type: "openUrl", | |
title: "View Image", | |
value: o.images.downsized_large.url | |
}]); | |
attachments.push(card.toAttachment()); | |
} catch (err) { | |
console.log(err); | |
} | |
}; | |
var response = teams.ComposeExtensionResponse | |
.result('list') | |
.attachments(attachments) | |
.toResponse(); | |
// Send the response to teams | |
callback(null, response, 200); | |
//} | |
}); | |
}; | |
connector.onQuery('searchCmd', composeExtensionHandler); | |
var composeInvoke = function (event) { | |
console.log(event); | |
}; | |
connector.onInvoke('composeInvoke'); |
Doug Routledge
Teams, Skype for Business, SQL, Exchange, UC, Full Stack Developer
![]()
Doug is the co-found of Bridge Communications, and also leads the development team.
|