Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
TurnContext in microsoft bot builder is giving error when fetching data from WebSocket server

I want to show the response coming from WebSocket server to emulator that is Microsoft Bot Builder but I am having a issue that inside ws.addEventListener. Here is the code

ws.addEventListener('message',async function (event) {
                const msg = JSON.parse(event.data);
                if(msg.topic === 'aws/chat' && msg.contentType === 'application/json'){
                    const content = JSON.parse(msg.content);
                    switch(content.Type){
                        case 'MESSAGE':
                            try{
                                  if(content.ParticipantRole !== 'CUSTOMER'){
                                    responseMessage = `${content.DisplayName} : ${content.Content}`;
                                    console.log(`responseMessage :- ${responseMessage}`);
                                    await turnContext.sendActivity(responseMessage);
                                }
                            }catch(error){
                                console.log("Insise Error");
                                console.log(error);
                            }
                            break;
                        case 'Event':
                            if(content.ContentType.includes('ended')){
                                responseMessage = `Chat ended`;
                            }
                    }
                }
            });

When I debugged await turnContext.sendActivity(responseMessage) is loosing scope inside the listener function and not able to return the response to the emulator.

From WS server receiving response and getting printed in console with error.

responseMessage :- BOT : To speak to an agent, press or say # Insise Error TypeError: Cannot perform 'get' on a proxy that has been revoked at WebSocket. (D:\azure-bot\echo-bot\bots\stateManagementBot.js:155:59)

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!