Bot is not responding to #Mention when sending message using Graph API - botframework

I have created and deployed a bot in Microsoft Teams. Bot Works properly and responds when user talks to the bot using #Mention (e.g. #mybot) in a channel. I just tried to send message to the bot using graph API call:
https://graph.microsoft.com/beta/teams/{group-id-for-teams}/channels/{channel-id}/messages
Method: POST
Content-type: application/json
Body:
"body": {
"contentType": "html",
"content": "Hello World <at id=\"0\">standupbot</at>"
},
"mentions": [
{
"id": 0,
"mentionText": "StandupBot",
"mentioned": {
"application": {
"id": "[my-bot-id]",
"displayName": "StandupBot",
"applicationIdentityType": "bot"
}
}
}
]
}
The Post request goes well, message is posted in my team and bot gets mentioned. But bot is not responding to the mention. However, if user manually mentions the bot in team then bot responds.
What is wrong here, Am i missing something or is it a bug? Please guide.
P.S: I am using Graph Explorer.

Related

Teams file consent card not sending "accept" activity to bot handler while implementing Teams Bot API , it is showing went wrong

We have a Teams bot installed for internal company use and it is capable of sending files to our users. Our application that handles the bot does not receive the file consent allow activity but decline activity is working fine , as said in the documentation we have implemented it .
will you pls help me out with the issue .
I'm using the proper documentation of Microsoft teams passing these values but not getting the result.
attachments": [{
"contentType": "application/vnd.microsoft.teams.card.file.consent",
"name": "result.txt",
"content": {
"description": "Text recognized from image",
"sizeInBytes": 4348,
"acceptContext": {
"resultId": "1a1e318d-8496-471b-9612-720ee4b1b592"
},
"declineContext": {
"resultId": "1a1e318d-8496-471b-9612-720ee4b1b592"
}
}
}]

Teams is not displaying my unfurl response

I have a Teams integration with link unfurling set up. I have the messaging endpoint pointed to a public ngrok URL and ngrok proxying a local node.js server that returns the example payload Microsoft has in it's documentation.
This is my endpoint (express.js):
app.post('/bot-test', (req, res) => {
res.send({
"composeExtension": {
"type": "result",
"attachmentLayout": "list",
"attachments": [
{
"contentType": "application/vnd.microsoft.teams.card.o365connector",
"content": {
"sections": [
{
"activityTitle": "[85069]: Create a cool app",
"activityImage": "https://placekitten.com/200/200"
},
{
"title": "Details",
"facts": [
{
"name": "Assigned to:",
"value": "[Larry Brown](mailto:larryb#example.com)"
},
{
"name": "State:",
"value": "Active"
}
]
}
]
}
}
]
}
});
});
When I post a URL in a message in Teams, I see it POST to that endpoint and it responds without errors, but nothing shows up in Teams. What's going wrong? I can't find any logs on Microsoft's side either. I would expect that Teams renders a card with the response payload.
Office 365 Connector cards are not supported for link unfurls ("Message extension previews" in MS parlance). Changing the response to a supported card type worked. Unfortunately, MS doesn't surface this problem anywhere and it just silently discards the response. I was able to find a somewhat useful error description by inspecting the network request that went out from the Teams web client, however.
See this for supported card types: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference

How to send a proactive message from a bot to a user

I am trying to send a message from a bot to a teams user who hasn't already installed the bot and doesn't need to install the bot via REST API.
I have tried following this document.
It clearly states:
"Sending a message to start a new conversation thread is different than sending a message in response to an existing conversation: when your bot starts a new a conversation, there is no pre-existing conversation to post the message to. In order to send a proactive message you need to:"
As far as I understand, this means that what I am trying to do is possible. I have tried to run this sample.
However, as far as I can tell it needs a conversation id. Without a conversation id it doesn't work.
I have tried to send a request like this with a bot network token ( which is normally used to respond to an activity request by the user):
POST /v3/conversations
{
"bot": {
"id": "28:10j12ou0d812-2o1098-c1mjojzldxcj-1098028n ",
"name": "The Bot"
},
"members": [
{
"id": "29:012d20j1cjo20211"
}
],
"channelData": {
"tenant": {
"id": "197231joe-1209j01821-012kdjoj"
}
}
}
However, it fails with the following message:
Send Message to https://graph.microsoft.com/v3/conversations failed: (401) {
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure. Invalid audience.",
"innerError": {
"request-id": "92922235-8c87-47ed-92bc-4ba17469611a",
"date": "2019-09-24T14:43:59"
}
}
}
I am guessing that this maybe because I didn't send MicrosoftAppCredentials.TrustServiceUrl first. But this is a c# call. How do I make the same call in REST API?
Please take a look at Bot Framework REST APIs documentation.
Here are steps to generate the access token which you could use to call Create Conversation APIs.
POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=MICROSOFT-APP-ID&client_secret=MICROSOFT-APP-PASSWORD&scope=https%3A%2F%2Fapi.botframework.com%2F.default

Twilio API not receiving current location via WhatsApp channel

I am currently building a bot using Twilio's WhatsApp integration with Twilio Studio. I need users to be able to share their current location with the bot, but found that if I send a location through WhatsApp, the body of the message that is sent to Twilio Studio is blank. I have tested other scenarios, such as sending a textual message, images, etc. and it all works fine, except when sharing location messages.
Does anyone know if WhatsApp location messages are currently not supported by Twilio?
Below is an example of the trigger message that is received by Twilio Studio whenever I send my current location through WhatsApp.
Thanks!
{
"contact": {
"channel": {
"address": "whatsapp:+34..."
}
},
"trigger": {
"message": {
"ApiVersion": "2010-04-01",
"SmsSid": "SM32631478ffaaf810cf5976df7586708f",
"SmsStatus": "received",
"SmsMessageSid": "SM32631478ffaaf810cf5976df7586708f",
"NumSegments": "1",
"From": "whatsapp:+34...",
"To": "whatsapp:+1...",
"MessageSid": "SM32631478ffaaf810cf5976df7586708f",
"Body": "",
"AccountSid": "ACc66461614830932cb12fdc6ab9d1d0a7",
"NumMedia": "0"
}
},
"widgets": {},
"flow": {
"flow_sid": "FWf8aae0f75a993b4a497aa6a569a54114",
"channel": {
"address": "whatsapp:+1..."
},
"sid": "FN522a44cadf024dc69d055c6690244db0"
}
}
If a location is present in your whatsApp text you can fetch it the same way you fetch your body
if (req.body.Latitude && req.body.Longitude) {
console.log('Whatsapp location received...');
console.log(req.body.Latitude + ', ' + req.body.Longitude);
}
I have just received an answer from Twilio that clarifies this is not something that Twilio supports at this stage. They do not currently have any ETA for when this feature will be available.

Integrating Microsoft team into my web app

I have a web app where if a user signs up, a notification is sent to the slack channel. I want to achieve the same thing in Microsoft team but I cant find any good resources. When a new user signs up, a message will be posted into the microsoft team group.Will it be possible to do this?
This can be easily achieved in Microsoft Teams using Connectors.
Here are the steps to post data to any channel:
In Microsoft Teams, choose the More options (⋯) button next to the
channel name in the list of channels and then choose Connectors.
Add an Incoming webhook and copy the webhook URL.
You can post Message Card given below to this URL using
Postman/Fiddler/Code.
{
"summary": "Alert!",
"themeColor": "0078D7",
"sections": [
{
"activityTitle": "Web app event",
"text": "Something happened in the web app!"
}],
"potentialAction": [
{
"#type": "OpenUri",
"name": "View event",
"targets": [
{ "os": "default", "uri": "http://mywebapp.com/path/to/event" }]
}]
}
You can also Build your own Connector with custom configurations.

Resources