-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstep4-complete.js
More file actions
89 lines (75 loc) · 2.81 KB
/
step4-complete.js
File metadata and controls
89 lines (75 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Posts a message to a Webex Teams space via a Bot account
* as a button in pressed in a custom in-room control
*
* Prep work:
* deploy the agenda.xml In-Room control to a CE 9.2+ device
*
* from a ssh session, type the commands below:
* > xConfiguration HttpClient Mode: On
* > xConfiguration HttpClient AllowInsecureHTTPS: True
*
*/
const xapi = require('xapi')
xapi.event.on('UserInterface Extensions Event Clicked Signal', (widgetId) => {
console.log(`new event from widget: ${widgetId}`)
let markdown = buildMarkdownForSession(widgetId)
push(markdown)
})
function buildMarkdownForSession(widgetId) {
let markdown = `no session found for widget identifier: ${widgetId}`
let session = sessions[widgetId]
if (session) {
console.log(`found session with id: ${widgetId}`)
markdown = `${session.day}, ${session.time}, ${session.location}`
markdown += `<br/>**\[${session.id}\] - ${session.title}**`
markdown += `<br/>_${session.description}_`
}
return markdown
}
const sessions = {}
sessions['DEVWKS-2074'] = {
id: 'DEVWKS-2074',
title: "Enhancement Meeting Rooms User Experience with xAPI and Macros",
description: "Join this workshop to go hands-on with xAPI (ie Webex Devices APIs and Cisco Collaboration Endpoint APIs). You'll learn to interact with a Webex Device from code, and implement an end-to-end In-Room Control by creating a custom interface and deploying Macros onto your device",
location: "Workshop 4",
type: "workshop",
day: "Monday",
time: "3:00PM",
duration: "45",
speaker: "Stève Sfartz",
href: "https://ciscolive.cisco.com/emea/learn/sessions/content-catalog/?search=2074#/"
}
function push(msg, cb) {
// Replace with your bot token
const token = "YTJkZDlmZjAtMGM3NS00MDUxLWIzNzItNmU0M2I2MDE0ZGRmODcwMTExZGUtNzU0"
// replace with a space your bot is part of
const roomId = "Y2lzY29zcGFyazovL3VzL1JPT00vYmEzlkNDktZmI5NTAxNDlhODVl"
// Post message
let payload = {
"markdown": msg,
"roomId": roomId
}
xapi.command(
'HttpClient Post',
{
Header: ["Content-Type: application/json", "Authorization: Bearer " + token],
Url: "https://api.ciscospark.com/v1/messages",
AllowInsecureHTTPS: "True"
},
JSON.stringify(payload))
.then((response) => {
if (response.StatusCode == 200) {
console.log("message pushed to Webex Teams")
if (cb) cb(null, response.StatusCode)
return
}
console.log("failed with status code: " + response.StatusCode)
if (cb) cb("failed with status code: " + response.StatusCode, response.StatusCode)
})
.catch((err) => {
console.log("failed with err: " + err.message)
if (cb) cb("Could not post message to Webex Teams")
})
}
console.log('listening...')