webex/webex-js-sdk

ReferenceError: window is not defined

lukascamargo opened this issue · 5 comments

Expected Behavior

When creating a meeting for a roomId at Webex Teams, it should start the meeting using the desktop application.

const webex = Webex.init({
                    config: {
                        meetings: {
                            deviceType: 'DESKTOP'
                        }
                    },
                    credentials: {
                        access_token: process.env.ACCESS_TOKEN
                    }
});

const room = await bot.api.rooms.create({title: 'teste do controller'});

await bot.api.memberships.create({
                    roomId: room.id,
                    personId: message.personId
 });

webex.meetings.on('meeting:added', (addedMeetingEvent) => {
                    if(addedMeetingEvent.type === 'INCOMING' || addedMeetingEvent.type === 'JOIN') {
                        const addedMeeting = addedMeetingEvent.meeting;

                        addedMeeting.acknowledge(addedMeetingEvent.type)
                            .then(() => {
                                this.joinMeeting(addedMeeting);
                            });
                        
                    }
                });

                if(!webex.meetings.registered) {
                    webex.meetings.register()
                        .then(() => webex.meetings.syncMeetings())
                        .then(() => {
                            webex.meetings.create({roomId: room.id}).then((meeting) => {
                                return this.joinMeeting(meeting);
                            })
                            .catch((error) => {
                                console.error('Error to create meeting', error);
                            });
                        })
                        .catch((error) => {
                            console.log('Error to register', error);
                        });
 }

joinMeeting = (meeting) => {
        return meeting.join().then(() => {
            const mediaSettings = {
                receiveVideo: true,
                receiveAudio: true,
                receiveShare: false,
                sendVideo: true,
                sendAudio: true,
                sendShare: false
            };

            return meeting.getMediaStreams(mediaSettings).then((mediaStreams) => {
                const [localStream, localShare] = mediaStreams;

                meeting.addMedia({
                    localShare,
                    localStream,
                    mediaSettings
                })
            });

        });
    }

Current Behavior

At the meetings.create function an error pops out and nothing happens. The error is "window is not defined"

Error to create meeting ReferenceError: window is not defined at Object.MediaUtil.createPeerConnection (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/media/util.js:23:3) at new MediaProperties (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/media/properties.js:38:42) at new Meeting (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meeting/index.js:622:29) at Meetings._callee$ (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meetings/index.js:619:27) at tryCatch (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/regenerator-runtime/runtime.js:62:40) at Generator.invoke [as _invoke] (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/regenerator-runtime/runtime.js:296:22) at Generator.prototype.<computed> [as next] (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/regenerator-runtime/runtime.js:114:21) at step (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30) at /Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14 at new Promise (<anonymous>) at new F (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/core-js/library/modules/_export.js:36:28) at Meetings.<anonymous> (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12) at Meetings.createMeeting (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meetings/index.js:694:22) at Meetings.create (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meetings/index.js:585:21) at /Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/features/bot_dialog.js:117:44 at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:97:5)Error to create meeting ReferenceError: window is not defined at Object.MediaUtil.createPeerConnection (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/media/util.js:23:3) at new MediaProperties (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/media/properties.js:38:42) at new Meeting (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meeting/index.js:622:29) at Meetings._callee$ (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meetings/index.js:619:27) at tryCatch (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/regenerator-runtime/runtime.js:62:40) at Generator.invoke [as _invoke] (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/regenerator-runtime/runtime.js:296:22) at Generator.prototype.<computed> [as next] (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/regenerator-runtime/runtime.js:114:21) at step (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30) at /Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14 at new Promise (<anonymous>) at new F (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/core-js/library/modules/_export.js:36:28) at Meetings.<anonymous> (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12) at Meetings.createMeeting (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meetings/index.js:694:22) at Meetings.create (/Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/node_modules/@webex/plugin-meetings/dist/meetings/index.js:585:21) at /Users/lukasfialho/GitFiles/NTT/BIC/bic-bot-teams/features/bot_dialog.js:117:44 at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:97:5)

Steps to Reproduce

  1. I am using Botkit and Webex library, even knowing that the Botkit have access to webex APIs
    2.This is a BOT inside Webex Teams. The BOT creates a room and then creates the meeting

Environment Details

  • SDK Version: 1.80.178
  • Node/Browser Version: v13.12.0
  • NPM Version: 6.14.4

Hello @lukasfialho,

In this described case, it appears as though you are attempting to utilize the functionality of the Meetings Plugin from a NodeJS Instance. Unfortunately, the meetings plugin can only be utilized via Browser instances due to its reliance on browser APIs at its core. The above logic, should work in the case that it was migrated and converted to a browser instance and was properly bundled for browser usage.

Let us know if our understanding of the described case is correct or if there are any other additional questions in relation to this GitHub Issue.

Edit:
Did you happen to find documentation that described the provided use case?

Hello @InteractiveTimmy ,

I tried so hard to make this work in the NodeJS instance and yet it didn't work. That's why I opened this issue, as a last resource. But thank you for your response.

Is there a way that this can be a new feature in the future?

Managing and modifying meetings via NodeJS could definitely be placed as a feature request. I'll communicate the details of this GitHub Issue with our Project Manager to determine if and how we can add this to our roadmap. We may also have a feature similar to this available for early field trials. We will update this case shortly with the details.

Hello again @lukasfialho,

Use the following link to submit a feature request to our project leads: https://ciscocollabcustomer.ideas.aha.io/

This will provided the feature request directly to our project manager for review. We will proceed with closing this issue for now, as the feature request process appears to be the solution. If you need additional support or have other questions in regards to this case, feel free to reach out to our support team via chat or other mediums listed here.

If I can second this as a feature request, I would certainly like to.

The ability to leverage Webex Meeting capabilities on the backend would be a big benefit, as we're trying to find efficient ways of augmenting Webex meetings with Integrations. @InteractiveTimmy you mentioned that a similar feature may be available for Early Field Trials. If that's the case, I'd like to discuss the possibility of joining in on those trials as soon as possible.