Home

Newbie: Using V3 SDK TeamsChat connector with node async/await?

%3CLINGO-SUB%20id%3D%22lingo-sub-818030%22%20slang%3D%22en-US%22%3ENewbie%3A%20Using%20V3%20SDK%20TeamsChat%20connector%20with%20node%20async%2Fawait%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-818030%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20It%20looks%20like%26nbsp%3B%3CSTRONG%3EV3%3C%2FSTRONG%3ESDK%20TeamsChat%20connector's%20listen%20method%20needs%20to%20be%20used%20to%20process%20messages%20something%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Eapp.post('%2Fapi%2Fmessages'%2C%20(req%2C%20res)%20%3D%26gt%3B%20%7B%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%26nbsp%3B%20%26nbsp%3Bconsole.log('Chat%20message%20received!')%3B%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%26nbsp%3B%20%26nbsp%3B%3CSTRONG%3Econnector.listen()%3B%3C%2FSTRONG%3E%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3E%7D)%3B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20I%20need%20to%20use%20it%20with%20async%2Fawait%20as%20it%20is%20possible%20with%20%3CSTRONG%3EV4%3C%2FSTRONG%3E%26nbsp%3BSDK%20BotFramework%20Adapter%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CEM%3E%3CSPAN%20class%3D%22pl-smi%22%3Eserver%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3Epost%3C%2FSPAN%3E(%3CSPAN%20class%3D%22pl-s%22%3E%3CSPAN%20class%3D%22pl-pds%22%3E'%3C%2FSPAN%3E%2Fapi%2Fmessages%3CSPAN%20class%3D%22pl-pds%22%3E'%3C%2FSPAN%3E%3C%2FSPAN%3E%2C%20(%3CSPAN%20class%3D%22pl-smi%22%3Ereq%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22pl-smi%22%3Eres%3C%2FSPAN%3E)%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%26gt%3B%3C%2FSPAN%3E%7B%3C%2FEM%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CEM%3E%3CSPAN%20class%3D%22pl-smi%22%3Eadapter%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3EprocessActivity%3C%2FSPAN%3E(req%2C%20res%2C%20%3CSTRONG%3E%3CSPAN%20class%3D%22pl-k%22%3Easync%3C%2FSPAN%3E%3C%2FSTRONG%3E(%3CSPAN%20class%3D%22pl-smi%22%3Econtext%3C%2FSPAN%3E)%20%3CSPAN%20class%3D%22pl-k%22%3E%3D%26gt%3B%3C%2FSPAN%3E%7B%3C%2FEM%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CEM%3E%3CSPAN%20class%3D%22pl-c%22%3E%2F%2F%20Route%20to%20main%20dialog.%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CEM%3E%3CSTRONG%3E%3CSPAN%20class%3D%22pl-k%22%3Eawait%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20class%3D%22pl-smi%22%3Ebot%3C%2FSPAN%3E.%3CSPAN%20class%3D%22pl-en%22%3Erun%3C%2FSPAN%3E(context)%3B%3C%2FEM%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CEM%3E%7D)%3B%3C%2FEM%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%7D)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20V3%20TeamsChat%20connector%20be%20used%20(if%20at%20all)%20in%20this%20way%3F%20Is%20there%20a%20sample%20to%20refer%20to%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%20and%20regards%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-818030%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBot%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-822700%22%20slang%3D%22en-US%22%3ERe%3A%20Newbie%3A%20Using%20V3%20SDK%20TeamsChat%20connector%20with%20node%20async%2Fawait%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-822700%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F386475%22%20target%3D%22_blank%22%3E%40NKM122205%3C%2FA%3E%26nbsp%3B%20Could%20you%20please%20take%20a%20look%20at%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F48612574%2Frunning-async-functions-in-microsoft-bot-builder-with-node-js%2F48612654%2348612654%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERunning%20Async%20functions%20in%20Microsoft%20Bot%20Builder%20(Node%20JS)%3F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
NKM122205
Occasional Contributor

Hi,

 

  It looks like V3 SDK TeamsChat connector's listen method needs to be used to process messages something like this:

 

app.post('/api/messages', (req, res) => {
   console.log('Chat message received!');
   connector.listen();
});

 

But I need to use it with async/await as it is possible with V4 SDK BotFramework Adapter:

 

server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async (context) => {
// Route to main dialog.
await bot.run(context);
});

});

 

How can V3 TeamsChat connector be used (if at all) in this way? Is there a sample to refer to?

 

Thanks in advance and regards

 

 

 

 

1 Reply
Highlighted
Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies