SOLVED

How to have app send message to channel without configuring connector

%3CLINGO-SUB%20id%3D%22lingo-sub-1238724%22%20slang%3D%22en-US%22%3EHow%20to%20have%20app%20send%20message%20to%20channel%20without%20configuring%20connector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1238724%22%20slang%3D%22en-US%22%3E%3CP%3EI%20know%20it%20is%20possible%20as%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsupport.monday.com%2Fhc%2Fen-us%2Farticles%2F360010359819-Microsoft-Teams-Integration%3Fsource%3Dsearch%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMonday.com%3C%2FA%3E%26nbsp%3Band%20Smartsheet%20integrations%20both%20do%20this.%20You%20can%20configure%20the%20app%20by%20allowing%20%60adminconsent%60%20and%20then%20selecting%20(on%20the%20web-service%20not%20in%20teams)%20which%20team%20%26amp%3B%20channel%20to%20have%20the%20service%20post%20to.%20Then%20the%20web%20application%20is%20able%20to%20make%20posts%20into%20that%20channel%20without%20the%20user%20configuring%20a%20connector%2Fwebhook.%26nbsp%3B%20In%20addition%20when%20I%20look%20into%20the%20channel%20that%20was%20mapped%2C%20there%20is%20no%20connector%20configured.%3CBR%20%2F%3E%3CBR%20%2F%3EThese%20apps%20have%20the%20exact%20functionality%20I'm%20looking%20for%2C%20and%20so%20far%20the%20only%20way%20to%20do%20this%20that%20I%20know%20of%20is%20to%20use%20the%20%2Fmessages%20graph%20api%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fchannel-post-messages%3Fview%3Dgraph-rest-beta%26amp%3Btabs%3Dhttp%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Efound%20here%3C%2FA%3E%26nbsp%3Bor%20to%20configure%20a%20connector.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20%2Fmessages%20api%20cannot%20be%20used%20by%20the%20application%20as%20far%20as%20I%20can%20tell.%20Though%20Monday.com%20appears%20to%20have%20a%20disclaimer%20that%20they%20are%20utilizing%20the%20beta%20features%20of%20the%20graph%20api.%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20how%20can%20I%20have%20my%20Teams%20app%20send%20a%20message%20to%20a%20specific%20channel%20within%20an%20organization%20without%20having%20to%20have%20the%20user%20configure%20a%20connector%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202020-03-19%20at%2012.06.25%20PM.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F178196iC6C0270D467738BD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Screen%20Shot%202020-03-19%20at%2012.06.25%20PM.png%22%20alt%3D%22Screen%20Shot%202020-03-19%20at%2012.06.25%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1238724%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EChannels%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMessages%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1240914%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20app%20send%20message%20to%20channel%20without%20configuring%20connector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1240914%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F567036%22%20target%3D%22_blank%22%3E%40adamhouck%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20could%20send%20message%20in%20a%20team%20from%20your%20app%20by%20doing%20a%20POST%20API%20call%20to%20below%20endpoint.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fbot-service%2Frest-api%2Fbot-framework-rest-connector-send-and-receive-messages%3Fview%3Dazure-bot-service-3.0%22%20data-linktype%3D%22absolute-path%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CCODE%3E%7BserviceURL%7D%2Fv3%2Fconversations%2F%7BconversationId%7D%2Factivities%2F%7BactivityId%7D%3C%2FCODE%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWhen%20bot%20is%20added%20into%20a%20group%2Fteam%20ConversationUpdate%20event%20is%20called%20in%20bot%20framework.%20You%20can%20cache%20the%20user%20details%20and%20serviceURL.%20And%20you%20can%20use%20these%20detail%20to%20post%20a%20message%20in%20teams%20or%20group.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1249797%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20app%20send%20message%20to%20channel%20without%20configuring%20connector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1249797%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F451628%22%20target%3D%22_blank%22%3E%40subhasish-MSFT%3C%2FA%3E%26nbsp%3B%20thank%20you%2C%20this%20is%20exactly%20what%20I%20was%20looking%20for.%20At%20first%20I%20dismissed%20this%20approach%20because%20I%20didn't%20realize%20a%26nbsp%3B%3CSPAN%3EConversationUpdate%20event%20was%20fired%20when%20the%20app%20was%20installed%2C%20I%20thought%20it%20needed%20direct%20user%20input.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThat%20being%20said%20i%3C%2FSPAN%3E%3CSPAN%3Ef%20I%20save%20the%20Conversation%20Reference%20from%20the%20initial%20app%20installation%2C%20can%20I%20use%20that%20indefinitely%20to%20post%20in%20other%20channels%20of%20the%20Team%2C%20or%20will%20it%20expire%20at%20some%20point%20like%20an%20Oauth%20Token%3F%3C%2FSPAN%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1254411%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20app%20send%20message%20to%20channel%20without%20configuring%20connector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1254411%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F567036%22%20target%3D%22_blank%22%3E%40adamhouck%3C%2FA%3E%26nbsp%3B%2C%20You%20have%20to%20store%20the%20team%20Id%2C%20tenant%20Id%2C%20conversation%20Id(in%20case%20of%20personal%20scope).%20These%20are%20unique%20Ids%20and%20can%20be%20stored%20indefinite%20time.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1262943%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20app%20send%20message%20to%20channel%20without%20configuring%20connector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1262943%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F451628%22%20target%3D%22_blank%22%3E%40subhasish-MSFT%3C%2FA%3E%26nbsp%3BThank%20you%2C%20I%20successfully%20implemented%20this%20based%20off%20the%20Microsoft%20example%20here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FBotBuilder-Samples%2Ftree%2Fmaster%2Fsamples%2Fjavascript_nodejs%2F16.proactive-messages%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2FBotBuilder-Samples%2Ftree%2Fmaster%2Fsamples%2Fjavascript_nodejs%2F16.proactive-messages%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EBut%20I%20can't%20seem%20to%20authenticate%20correctly%20after%20restarting%20my%20server%20when%20using%20a%20saved%20conversation%20reference.%26nbsp%3B%20I%20did%20put%20in%20a%20call%20to%20%60MicrosoftAppCredentials.trustServiceURL()%60%20as%20the%20example%20shows.%26nbsp%3B%20Is%20there%20something%20else%20I%20am%20missing%20to%20authenticate%20after%20re-instantiating%20the%20%60BotFrameworkAdapter%60%20on%20server%20restart%20with%20a%20saved%20conversation%20reference%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%7B%20Error%3A%20Authorization%20has%20been%20denied%20for%20this%20request.%3CBR%20%2F%3Eat%20new%20RestError%20(.....%2Fnode_modules%2F%40azure%2Fms-rest-js%2Flib%2FrestError.ts%3A18%3A5)%3CBR%20%2F%3Eat%20....%2Fnode_modules%2F%40azure%2Fms-rest-js%2Flib%2Fpolicies%2FdeserializationPolicy.ts%3A117%3A27%3CBR%20%2F%3Eat%20%3CANONYMOUS%3E%3CBR%20%2F%3Eat%20process._tickDomainCallback%20(internal%2Fprocess%2Fnext_tick.js%3A229%3A7)%3CBR%20%2F%3Ecode%3A%20undefined%2C%3CBR%20%2F%3EstatusCode%3A%20401%2C%3CBR%20%2F%3Erequest%3A%3CBR%20%2F%3EWebResource%20%7B%3CBR%20%2F%3EstreamResponseBody%3A%20false%2C%3CBR%20%2F%3Eurl%3A%20'%3CA%20href%3D%22https%3A%2F%2Fsmba.trafficmanager.net%2Famer%2Fv3%2Fconversations%2F%7Bconvo%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsmba.trafficmanager.net%2Famer%2Fv3%2Fconversations%2F%7Bconvo%3C%2FA%3E%20ID%7D%2540thread.skype%2Factivities%2F%7BactiviyID%7D'%2C%3CBR%20%2F%3Emethod%3A%20'POST'%2C%3CBR%20%2F%3Eheaders%3A%20HttpHeaders%20%7B%20_headersMap%3A%20%5BObject%5D%20%7D%2C%3CBR%20%2F%3Ebody%3A%20'%7B%22type%22%3A%22message%22%2C%22serviceUrl%22%3A%22%3CA%20href%3D%22https%3A%2F%2Fsmba.trafficmanager.net%2Famer%2F%26quot%3B%2C%26quot%3BchannelId%26quot%3B%3A%26quot%3Bmsteams%26quot%3B%2C%26quot%3Bfrom%26quot%3B%3A%7B%26quot%3Bid%26quot%3B%3A%26quot%3B%7BID%7D%26quot%3B%2C%26quot%3Bname%26quot%3B%3A%26quot%3BCrossLead%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsmba.trafficmanager.net%2Famer%2F%22%2C%22channelId%22%3A%22msteams%22%2C%22from%22%3A%7B%22id%22%3A%22%7BID%7D%22%2C%22name%22%3A%22CrossLead%3C%2FA%3E%20Dev%20Local%22%7D%2C%22conversation%22%3A%7B%22isGroup%22%3Atrue%2C%22conversationType%22%3A%22channel%22%2C%22id%22%3A%22%7BID%7D%22%2C%22tenantId%22%3A%22%7BID%7D%22%7D%2C%22recipient%22%3A%7B%22id%22%3A%22%7BID%7D%22%2C%22aadObjectId%22%3A%22%7BID%7D%22%7D%2C%22text%22%3A%22The%20bot%20encountered%20an%20error%20or%20bug.%22%2C%22inputHint%22%3A%22acceptingInput%22%2C%22replyToId%22%3A%22%7BID%7D%22%7D'%2C%3CBR%20%2F%3Equery%3A%20undefined%2C%3CBR%20%2F%3EformData%3A%20undefined%2C%3CBR%20%2F%3EwithCredentials%3A%20false%2C%3CBR%20%2F%3EabortSignal%3A%20undefined%2C%3CBR%20%2F%3Etimeout%3A%200%2C%3CBR%20%2F%3EonUploadProgress%3A%20undefined%2C%3CBR%20%2F%3EonDownloadProgress%3A%20undefined%2C%3CBR%20%2F%3EoperationSpec%3A%3CBR%20%2F%3E%7B%20httpMethod%3A%20'POST'%2C%3CBR%20%2F%3Epath%3A%20'v3%2Fconversations%2F%7BconversationId%7D%2Factivities%2F%7BactivityId%7D'%2C%3CBR%20%2F%3EurlParameters%3A%20%5BArray%5D%2C%3CBR%20%2F%3ErequestBody%3A%20%5BObject%5D%2C%3CBR%20%2F%3Eresponses%3A%20%5BObject%5D%2C%3CBR%20%2F%3Eserializer%3A%20%5BObject%5D%20%7D%20%7D%2C%3CBR%20%2F%3Eresponse%3A%3CBR%20%2F%3E%7B%20body%3A%20'%7B%22message%22%3A%22Authorization%20has%20been%20denied%20for%20this%20request.%22%7D'%2C%3CBR%20%2F%3Eheaders%3A%20HttpHeaders%20%7B%20_headersMap%3A%20%5BObject%5D%20%7D%2C%3CBR%20%2F%3Estatus%3A%20401%20%7D%2C%3CBR%20%2F%3Ebody%3A%20%7B%20message%3A%20'Authorization%20has%20been%20denied%20for%20this%20request.'%20%7D%20%7D%3C%2FANONYMOUS%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Econst%20msBotAdapter%20%3D%20new%20BotFrameworkAdapter(%7B%3CBR%20%2F%3EappId%3A%20%7BID%20as%20string%7D%3CBR%20%2F%3EappPassword%3A%20%7BID%20as%20string%7D%2C%3CBR%20%2F%3E%7D)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FSome%20people%20also%20said%20to%20do%20this%2C%20but%20never%20used%20it%20anywhere.%20It%20doesn't%20seem%20to%20help%3CBR%20%2F%3Econst%20msCreditials%20%3D%20new%20MicrosoftAppCredentials(%3CBR%20%2F%3E%7BID%20as%20string%7D%2C%3CBR%20%2F%3E%7BID%20as%20string%7D%3CBR%20%2F%3E)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FSave%20Conversation%20Reference%20from%20when%20the%20app%20was%20installed%20into%20teams%3CBR%20%2F%3Econst%20conversationReference%3A%20%7B%3CBR%20%2F%3E%5Bkey%3A%20string%5D%3A%20Partial%3CCONVERSATIONREFERENCE%3E%3B%3CBR%20%2F%3E%7D%20%3D%20%7B%3CBR%20%2F%3EactivityId%3A%20'%7Bactivity%20ID%7D'%2C%3CBR%20%2F%3E%2F%2F%40ts-ignore%3CBR%20%2F%3Euser%3A%20%7B%3CBR%20%2F%3Eid%3A%3CBR%20%2F%3E'%7BID%7D'%2C%3CBR%20%2F%3EaadObjectId%3A%20'%7BID%7D'%2C%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3Ebot%3A%20%7B%3CBR%20%2F%3Eid%3A%20'%7BBot%20Id%7D'%2C%3CBR%20%2F%3Ename%3A%20'%7BBot%20Name%7D'%2C%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%2F%2F%40ts-ignore%3CBR%20%2F%3Econversation%3A%20%7B%3CBR%20%2F%3EisGroup%3A%20true%2C%3CBR%20%2F%3EconversationType%3A%20'channel'%2C%3CBR%20%2F%3EtenantId%3A%20'%7Btenant%20ID%7D'%2C%3CBR%20%2F%3Eid%3A%20'19%3A%7BID%7D%40thread.skype'%2C%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3EchannelId%3A%20'msteams'%2C%3CBR%20%2F%3EserviceUrl%3A%20'%3CA%20href%3D%22https%3A%2F%2Fsmba.trafficmanager.net%2Famer%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsmba.trafficmanager.net%2Famer%2F%3C%2FA%3E'%2C%3CBR%20%2F%3E%7D%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Econst%20postMessage%20%3D%20async%20()%20%3D%26gt%3B%20%7B%3CBR%20%2F%3EMicrosoftAppCredentials.trustServiceUrl(conversationReference.serviceUrl)%3B%3CBR%20%2F%3Eawait%20msBotAdapter.continueConversation(%3CBR%20%2F%3EconversationReference%20as%20any%2C%3CBR%20%2F%3Easync%20turnContext%20%3D%26gt%3B%20%7B%3CBR%20%2F%3E%2F%2F%20If%20you%20encounter%20permission-related%20errors%20when%20sending%20this%20message%2C%20see%3CBR%20%2F%3E%2F%2F%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2FBotTrustServiceUrl%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Faka.ms%2FBotTrustServiceUrl%3C%2FA%3E%3CBR%20%2F%3Eawait%20turnContext.sendActivity('test%20message)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E)%3B%3CBR%20%2F%3E%7D%3C%2FCONVERSATIONREFERENCE%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1268209%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20have%20app%20send%20message%20to%20channel%20without%20configuring%20connector%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1268209%22%20slang%3D%22en-US%22%3E%3CP%3ETurns%20out%20it%20was%20due%20to%20using%20an%20outdated%20dependency%2C%20%60botbuilder%60%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fbotframework-sdk%23readme%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2Fbotframework-sdk%23readme%3C%2FA%3E%26nbsp%3Bthough%20I%20was%20only%20on%204.7.2%20and%20the%20latest%20was%204.8.0.%3CBR%20%2F%3E%3CBR%20%2F%3EWe%20will%20probably%20forgo%20these%20dependencies%20in%20favor%20of%20working%20with%20the%20REST%20API's%20directly%20like%20Stackoverflow.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.blog%2F2019%2F11%2F04%2Fa-technical-deep-dive-into-our-ms-teams-integration%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.blog%2F2019%2F11%2F04%2Fa-technical-deep-dive-into-our-ms-teams-integration%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHaving%20our%20teams%20integration%20totally%20fail%20due%20to%20a%20slightly%20newer%20version%20of%20the%20botframework%20package%20coming%20out%20is%20not%20a%20longterm%20option.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I know it is possible as Monday.com and Smartsheet integrations both do this. You can configure the app by allowing `adminconsent` and then selecting (on the web-service not in teams) which team & channel to have the service post to. Then the web application is able to make posts into that channel without the user configuring a connector/webhook.  In addition when I look into the channel that was mapped, there is no connector configured.

These apps have the exact functionality I'm looking for, and so far the only way to do this that I know of is to use the /messages graph api found here or to configure a connector.

The /messages api cannot be used by the application as far as I can tell. Though Monday.com appears to have a disclaimer that they are utilizing the beta features of the graph api.

So how can I have my Teams app send a message to a specific channel within an organization without having to have the user configure a connector?

Screen Shot 2020-03-19 at 12.06.25 PM.png

5 Replies
Highlighted
Best Response confirmed by adamhouck (Occasional Contributor)
Solution

@adamhouck,

 

You could send message in a team from your app by doing a POST API call to below endpoint.

{serviceURL}/v3/conversations/{conversationId}/activities/{activityId} 

 

When bot is added into a group/team ConversationUpdate event is called in bot framework. You can cache the user details and serviceURL. And you can use these detail to post a message in teams or group.

Highlighted

@subhasish-MSFT  thank you, this is exactly what I was looking for. At first I dismissed this approach because I didn't realize a ConversationUpdate event was fired when the app was installed, I thought it needed direct user input.

 

That being said if I save the Conversation Reference from the initial app installation, can I use that indefinitely to post in other channels of the Team, or will it expire at some point like an Oauth Token?

Highlighted

@adamhouck , You have to store the team Id, tenant Id, conversation Id(in case of personal scope). These are unique Ids and can be stored indefinite time.  

Highlighted

@subhasish-MSFT Thank you, I successfully implemented this based off the Microsoft example here https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/16.proactive-m... 

But I can't seem to authenticate correctly after restarting my server when using a saved conversation reference.  I did put in a call to `MicrosoftAppCredentials.trustServiceURL()` as the example shows.  Is there something else I am missing to authenticate after re-instantiating the `BotFrameworkAdapter` on server restart with a saved conversation reference?

{ Error: Authorization has been denied for this request.
at new RestError (...../node_modules/@azure/ms-rest-js/lib/restError.ts:18:5)
at ..../node_modules/@azure/ms-rest-js/lib/policies/deserializationPolicy.ts:117:27
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
code: undefined,
statusCode: 401,
request:
WebResource {
streamResponseBody: false,
url: 'https://smba.trafficmanager.net/amer/v3/conversations/{convo ID}%40thread.skype/activities/{activiyID}',
method: 'POST',
headers: HttpHeaders { _headersMap: [Object] },
body: '{"type":"message","serviceUrl":"https://smba.trafficmanager.net/amer/","channelId":"msteams","from":{"id":"{ID}","name":"CrossLead Dev Local"},"conversation":{"isGroup":true,"conversationType":"channel","id":"{ID}","tenantId":"{ID}"},"recipient":{"id":"{ID}","aadObjectId":"{ID}"},"text":"The bot encountered an error or bug.","inputHint":"acceptingInput","replyToId":"{ID}"}',
query: undefined,
formData: undefined,
withCredentials: false,
abortSignal: undefined,
timeout: 0,
onUploadProgress: undefined,
onDownloadProgress: undefined,
operationSpec:
{ httpMethod: 'POST',
path: 'v3/conversations/{conversationId}/activities/{activityId}',
urlParameters: [Array],
requestBody: [Object],
responses: [Object],
serializer: [Object] } },
response:
{ body: '{"message":"Authorization has been denied for this request."}',
headers: HttpHeaders { _headersMap: [Object] },
status: 401 },
body: { message: 'Authorization has been denied for this request.' } }


const msBotAdapter = new BotFrameworkAdapter({
appId: {ID as string}
appPassword: {ID as string},
});

//Some people also said to do this, but never used it anywhere. It doesn't seem to help
const msCreditials = new MicrosoftAppCredentials(
{ID as string},
{ID as string}
);

//Save Conversation Reference from when the app was installed into teams
const conversationReference: {
[key: string]: Partial<ConversationReference>;
} = {
activityId: '{activity ID}',
//@ts-ignore
user: {
id:
'{ID}',
aadObjectId: '{ID}',
},
bot: {
id: '{Bot Id}',
name: '{Bot Name}',
},
//@ts-ignore
conversation: {
isGroup: true,
conversationType: 'channel',
tenantId: '{tenant ID}',
id: '19:{ID}@thread.skype',
},
channelId: 'msteams',
serviceUrl: 'https://smba.trafficmanager.net/amer/',
};


const postMessage = async () => {
MicrosoftAppCredentials.trustServiceUrl(conversationReference.serviceUrl);
await msBotAdapter.continueConversation(
conversationReference as any,
async turnContext => {
// If you encounter permission-related errors when sending this message, see
// https://aka.ms/BotTrustServiceUrl
await turnContext.sendActivity('test message);
}
);
}




Highlighted

Turns out it was due to using an outdated dependency, `botbuilder` https://github.com/microsoft/botframework-sdk#readme though I was only on 4.7.2 and the latest was 4.8.0.

We will probably forgo these dependencies in favor of working with the REST API's directly like Stackoverflow. https://stackoverflow.blog/2019/11/04/a-technical-deep-dive-into-our-ms-teams-integration/

 

Having our teams integration totally fail due to a slightly newer version of the botframework package coming out is not a longterm option.