I can't show message in Teams after success API request

%3CLINGO-SUB%20id%3D%22lingo-sub-2439260%22%20slang%3D%22en-US%22%3EI%20can't%20show%20message%20in%20Teams%20after%20success%20API%20request%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2439260%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22%22%3EI%20made%20new%20conversation%20as%20API%20with%20my%20bot%20in%20Teams%20with%20DirectLine%20chanel%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E%3CSPAN%3E%22https%3A%2F%2Fdirectline.botframework.com%2Fv3%2Fdirectline%2Fconversations%22%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eand%20made%20sucsses%20request%20with%20message%3C%2FSPAN%3E%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E%3CSPAN%3E%22https%3A%2F%2Fdirectline.botframework.com%2Fv3%2Fdirectline%2Fconversations%2FBl1AgRQB1zz7xx8NrdFNe2-m%2Factivities%22%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAnd%20have%20correct%20answer%20200OK%20with%20ID%20%3A%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CP%3E%22id%22%3CSPAN%3E%3A%20%3C%2FSPAN%3E%22Bl1AgRQB1zz7xx8NrdFNe2-m%7C0000030%22%3C%2FP%3E%3C%2FDIV%3E%3CDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FDIV%3E%3CP%3EBut%20in%20Teams%20nothing%20events%2C%20not%20any%20messages.%3C%2FP%3E%3CP%3EWhy%20probably%20reason%20of%20this%20behaviour%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22not%20view%20message%20in%20teams.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F288067i316E120E9DFB8136%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22not%20view%20message%20in%20teams.png%22%20alt%3D%22not%20view%20message%20in%20teams.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2439260%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeamsBot%20BotFrameworkAPI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2445707%22%20slang%3D%22en-US%22%3ERe%3A%20I%20can't%20show%20message%20in%20Teams%20after%20success%20API%20request%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2445707%22%20slang%3D%22en-US%22%3ESorry%2C%20I%20didn't%20quite%20understand%20what%20documents%20you%20mean.%20In%20general%2C%20my%20problem%20is%20that%20I%20need%20to%20send%20a%20private%20message%20to%20a%20user%20in%20Teams%20via%20a%20bot%20via%20an%20https%20request.%20And%20although%20all%20requests%20seem%20to%20be%20executed%20correctly%2C%20messages%20do%20not%20come.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2456514%22%20slang%3D%22en-US%22%3ERe%3A%20I%20can't%20show%20message%20in%20Teams%20after%20success%20API%20request%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2456514%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1076719%22%20target%3D%22_blank%22%3E%40Vladimir_Anokhin%3C%2FA%3E%20Please%20let%20us%20know%20if%20your%20issue%20has%20been%20resolved.%3C%2FLINGO-BODY%3E
New Contributor

I made new conversation as API with my bot in Teams with DirectLine chanel

"https://directline.botframework.com/v3/directline/conversations" 

and made sucsses request with message

"https://directline.botframework.com/v3/directline/conversations/Bl1AgRQB1zz7xx8NrdFNe2-m/activities" 

And have correct answer 200OK with ID :

 

"id": "Bl1AgRQB1zz7xx8NrdFNe2-m|0000030"

 

But in Teams nothing events, not any messages.

Why probably reason of this behaviour?

not view message in teams.png

5 Replies

@Vladimir_Anokhin Thanks for reaching out us, Could you please share which document you are using and share more details about your issue.

Sorry, I didn't quite understand what documents you mean. In general, my problem is that I need to send a private message to a user in Teams via a bot via an https request. And although all requests seem to be executed correctly, messages do not come.

@Vladimir_Anokhin Could you please go through the documentation and try with sample. If you find any further issue please share manifest file so that we can repro from our end.

@Vladimir_Anokhin Please let us know if your issue has been resolved.
I found right way:

1 step - take information from bot's index.js about the participants in the conversation with the bot and save it to yourself - this can be done by sending a request from the bot to your script
const axios = require('axios');
axios.get('https://My_server/My_script.php', {
params: {
'context': context
}
})
.then(function (response) {
console.log(response);
})

2 step - get Bearer token via request
https://login.microsoftonline.com/common/oauth2/v2.0/token
Use Application ID and secret key in parameters
Note - token's life is 1 day, will get new if need

3 step - with token to create new conversation with user send request
https://smba.trafficmanager.net/emea/v3/conversations
WARNING - look at the exact url in the data that you received from the bot in step 1 - it may differ!

with body (all parameters you should save in yours base in step 1) :
{
"bot": {
"id": "BotID",
"name": "NameBot"

},
"isGroup": false,
"members": [
{
"id": "UserID",
"name": "User Name"
}
],
"tenantId":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"topicName": "News Alert"
}
In answer you must get ID of new conversation - save it too

And finally - step 4 - send message to user with request
https://smba.trafficmanager.net/amer/v3/conversations/[CONFERSATION_ID]/activities

WARNING - look at the exact url in the data that you received from the bot in step 1 - it may differ!

and body like this or others variants of fields (don't forget use token which you got in step 2)


{
"type": "message",
"channelId": "msteams",
"conversation": {"id": "CONVERSATION_ID"},

"from":{"id": "BotID","name": "NameBot"},
"recipient":{"id": "UserID",
"name": "UserName"
},
"text": "Hi userName! Welcome from API.",
"channelData": {
"notification": {
"alert": true
}
},
"textFormat":"plain"}

I hope this helps someone lose a little less time than it does me :) .
@Chetana-MSFT , thank you for yours attention.
www.000webhost.com