-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzoomBot.js
67 lines (59 loc) · 2.16 KB
/
zoomBot.js
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
/******************************************************************************
* Dependencies
******************************************************************************/
import axios from 'axios'
import 'dotenv/config'
import promptSync from 'prompt-sync'
const prompt = promptSync()
/******************************************************************************
* Custom Axios Instance
******************************************************************************/
const recall = axios.create({
baseURL: 'https://api.recall.ai/api/v1',
headers: {
'authorization': `token ${process.env.RECALL_API_KEY}`,
'content-type': 'application/json'
},
timeout: 10000
})
/******************************************************************************
* Bot Functions
******************************************************************************/
const connectBot = async (meetingURL) => {
try {
const payload = {
// URL of the zoom meeting provided by the user.
meeting_url: meetingURL,
// Name of the bot
bot_name: "Transcription Bot",
// Specify AssemblyAI as the transcription provider.
transcription_options: { provider: 'assembly_ai' },
// Webhook URL that is provided via our .env file.
real_time_transcription: { destination_url: `${process.env.WEBHOOK_URL}/meeting_transcript` }
}
const response = await recall.post('/bot', payload)
const { data: { id } } = response
return id
} catch (err) {
console.error(err)
}
}
const leaveMeeting = async (meetingID) => {
try {
await recall.post(`/bot/${meetingID}/leave_call`)
} catch (err) {
console.error(err)
}
}
// Manage bot portion of the app.
const runApp = async () => {
const meetingURL = prompt('What is your meeting URL?: ')
const meetingID = await connectBot(meetingURL)
console.info(`Joining meeting: ${meetingID}`)
const endMeeting = prompt('Type "STOP" to end transcription: ')
if (endMeeting.toLowerCase() === 'stop') {
await leaveMeeting(meetingID)
}
}
// Initiate application
runApp()