How To Send A Message From User To Bot In Microsoft Teams App?

%3CLINGO-SUB%20id%3D%22lingo-sub-967865%22%20slang%3D%22en-US%22%3EHow%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-967865%22%20slang%3D%22en-US%22%3E%3CP%3EHi.%20I'm%20able%20to%20send%20messages%20from%20Bot%20to%20user%20in%20Microsoft%20Teams%20app%20via%20Microsoft%20Bot's%20%22botbuilder%22%20Node.js%20SDK%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3Esession.send(message)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20I%20send%20the%20message%20on%20the%20other%20direction%20(from%20user%20to%20bot)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-967865%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-970304%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-970304%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F437032%22%20target%3D%22_blank%22%3E%40member11%3C%2FA%3E%20You%20could%20directly%20send%20a%20message%20to%20the%20bot%20using%20Teams%20client.%20What%20is%20that%20you%20are%20looking%20for%3F%20Could%20you%20please%20elaborate%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-970507%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-970507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F359599%22%20target%3D%22_blank%22%3E%40Gousia_Begum%3C%2FA%3E%26nbsp%3BI'm%20working%20on%20an%20integration%20between%20Microsoft%20Teams%20and%20Slack.%3C%2FP%3E%3CP%3EI'm%20building%20a%20Microsoft%20Teams%20application%20which%20is%20connected%20to%20a%20Microsoft%20Bot.%3C%2FP%3E%3CP%3EAdditionally%2C%20I%20created%20a%20server%20for%3A%3C%2FP%3E%3CP%3E1.%20Listening%20to%20messages%20which%20were%20sent%20by%20users%20in%20%3CSTRONG%3ESlack%3C%2FSTRONG%3E%20(via%20Slack%20webhooks)%3C%2FP%3E%3CP%3E2.%20Posting%20them%20in%20Microsoft%20Teams%20conversation%20as%20a%20user%20message%20to%20the%20bot%20(outgoing%20message)%3C%2FP%3E%3CP%3EI%20cannot%20accomplish%20item%20number%202.%3C%2FP%3E%3CP%3EI%20receive%20messages%20from%20Slack%20(which%20were%20sent%20by%20a%20Slack%20user)%20to%20my%20server%20and%20I%20wish%20to%20post%20them%20in%20Microsoft%20Teams%20%3CSTRONG%3Eas%20messages%20from%20the%20user%20to%20the%20bot%3C%2FSTRONG%3E%20and%20I'm%20not%20able%20to%20do%20so.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-978662%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-978662%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F437032%22%20target%3D%22_blank%22%3E%40member11%3C%2FA%3E%26nbsp%3BI've%20not%20done%20this%20via%20Node%20(js)%20but%20I've%20got%20it%20working%20fine%20in%20C%23%2C%20sending%20on%20a%20schedule%20from%20an%20Azure%20function.%20Here's%20the%20gist%20of%20what%20you%20need%20(see%20the%20replies)%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F42749982%2Finitiate-a-message-from-bot-to-user-on-botframework%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F42749982%2Finitiate-a-message-from-bot-to-user-on-botframework%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-987363%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-987363%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F150%22%20target%3D%22_blank%22%3E%40Hilton%20Giesenow%3C%2FA%3E.%20Actually%20I'm%20looking%20for%20another%20behaviour...%3C%2FP%3E%3CP%3EIn%20the%20example%20you%20sent%20the%20new%20message%20arrived%20from%20%22consoleBot%22%20while%20I'd%20like%20to%20send%20it%20as%20%22User%22.%3C%2FP%3E%3CP%3EIn%20such%20case%20the%20message%20would%20be%20displayed%20inside%20a%20blue%20bubble%20and%20it'd%20look%20like%20the%20user%20sent%20it.%3C%2FP%3E%3CP%3EThe%20UX%20is%20crucial%20in%20this%20use%20case.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-987369%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-987369%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F437032%22%20target%3D%22_blank%22%3E%40member11%3C%2FA%3E%26nbsp%3Bahh%2C%20I%20see%20now%20-%20that%20makes%20sense%20given%20what%20you're%20trying%20to%20do%20-%20this%20is%20totally%20the%20wrong%20path%20we're%20done.%20What%20you'd%20want%20is%20the%20use%20the%20Teams%20API%2C%20with%20delegated%20permissions%2C%20to%20post%20on%20behalf%20of%20the%20user.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20the%20way%2C%20are%20you%20aware%20of%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fm.io%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fm.io%2F%3C%2FA%3E%26nbsp%3B%3F%20I%20think%20they%20already%20do%20something%20similar%20to%20what%20you're%20trying%20to%20achieve%2C%20just%20fyi.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-998247%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-998247%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20again%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F150%22%20target%3D%22_blank%22%3E%40Hilton%20Giesenow%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fm.io%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fm.io%3C%2FA%3E%20posts%20messages%20solely%20by%20the%20bot%20while%20I'm%20willing%20to%20post%20messages%20as%20the%20user%20without%20using%20Teams'%20UI...%20Unfortunately%2C%26nbsp%3B%3CSPAN%3ETeams%20API%20doesn't%20allow%20posting%20on%20behalf%20of%20the%20user%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1013581%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Send%20A%20Message%20From%20User%20To%20Bot%20In%20Microsoft%20Teams%20App%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1013581%22%20slang%3D%22en-US%22%3E%3CP%3EA%20related%20answer%20on%20StackOverflow%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F58788187%2Fhow-to-post-a-message-on-behalf-of-the-user-in-microsoft-teams-app%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F58788187%2Fhow-to-post-a-message-on-behalf-of-the-user-in-microsoft-teams-app%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi. I'm able to send messages from Bot to user in Microsoft Teams app via Microsoft Bot's "botbuilder" Node.js SDK:

 

 

session.send(message);

 

 

How can I send the message on the other direction (from user to bot)

7 Replies

@member11 You could directly send a message to the bot using Teams client. What is that you are looking for? Could you please elaborate?

@Gousia_Begum I'm working on an integration between Microsoft Teams and Slack.

I'm building a Microsoft Teams application which is connected to a Microsoft Bot.

Additionally, I created a server for:

1. Listening to messages which were sent by users in Slack (via Slack webhooks)

2. Posting them in Microsoft Teams conversation as a user message to the bot (outgoing message)

I cannot accomplish item number 2.

I receive messages from Slack (which were sent by a Slack user) to my server and I wish to post them in Microsoft Teams as messages from the user to the bot and I'm not able to do so.

@member11 I've not done this via Node (js) but I've got it working fine in C#, sending on a schedule from an Azure function. Here's the gist of what you need (see the replies): https://stackoverflow.com/questions/42749982/initiate-a-message-from-bot-to-user-on-botframework

Thank you @Hilton Giesenow. Actually I'm looking for another behaviour...

In the example you sent the new message arrived from "consoleBot" while I'd like to send it as "User".

In such case the message would be displayed inside a blue bubble and it'd look like the user sent it.

The UX is crucial in this use case.

 

@member11 ahh, I see now - that makes sense given what you're trying to do - this is totally the wrong path we're done. What you'd want is the use the Teams API, with delegated permissions, to post on behalf of the user.

 

By the way, are you aware of https://m.io/ ? I think they already do something similar to what you're trying to achieve, just fyi.

Thanks again @Hilton Giesenow https://m.io posts messages solely by the bot while I'm willing to post messages as the user without using Teams' UI... Unfortunately, Teams API doesn't allow posting on behalf of the user