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
Related
Currently, I have a chat-bot app that sends the message on the channel.
Also, it is capable of tagging a user. The below code is responsible for sending user mentioned message.
await turnContext.sendActivity(
{
text: `Hello <at>#${members[0].dispName}</at>`,
entities: [
{
type: 'mention',
mentioned: {
id: members[0].userName,
name: members[0].dispName,
},
text: `<at>#${members[0].dispName}</at>`,
}
],
});
Further, I am trying to mention the Team Tag. Is there a way I can pass the team-id or something else to mention the Tag
Note: Team tag means - tag in a team
Now you can create/Get teams tags using Beta Graph API.
Reference doc: Create teamworkTag - Microsoft Graph beta | Microsoft Docs
You can also get the created tags using below Beta Graph API:
GET /teams/{team-Id}/tags
List teamworkTags - Microsoft Graph beta | Microsoft Docs
You can also send the message with mentioning teams tag using below API
Post request: https://graph.microsoft.com/v1.0/teams/{team id}/channels/{channel id}/messages
Message body:
{
"subject": "This is very urgent!",
"importance": "urgent",
"body": {
"contentType": "html",
"content": "Programmatically mentioning of Tagged users <at id=\"0\">String_1234</at>"
},
"mentions": [
{
"id": 0,
"mentionText": "String_1234",
"mentioned": {
"tag": {
"#odata.type": "#microsoft.graph.teamworkTagIdentity",
"id": ""/*tag id*/,
"displayName": ""/* tag name*/
}
}
}
]
}
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.
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.
I've found the following documentation on how to send email using Office 365 rest API.
This is the example given on the doucmentation:
POST https://outlook.office.com/api/v2.0/me/sendmail
{
"Message": {
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
},
"SaveToSentItems": "false"
}
This works fine if the user authorizes the application to act on it's behalf. However, I am using client crednetial to build a daemon application that acts on behalf of all users in the given tenant hence "POST https://outlook.office.com/api/v2.0/me/sendmail" couldn't work because its is referencing the "me" and can't tell which user is sending the email.
I would appericiate if you can help with sample example. FYI: I am using Java but your answer doesn't have to be in Java.
Replace the /me bit of the URL with /users/<userid>. You can not use /me for any API call with a token from client credentials.
I have setup an Alexa Smart Home Skill, all settings done, oauth2 processed done and skill is enabled on my Amazon Echo device. Lambda function is setup and linked to the skill. When I "Discover Devices" I can see the payload hit my Lambda function in the log. I am literally returning via the context.succeed() method the following JSON with a test appliance. However Echo tells me that it fails to find any devices.
{
"header": {
"messageId": "42e0bf9c-18e2-424f-bb11-f8a12df1a79e",
"name": "DiscoverAppliancesResponse",
"namespace": "Alexa.ConnectedHome.Discovery",
"payloadVersion": "2"
},
"payload": {
"discoveredAppliances": [
{
"actions": [
"incrementPercentage",
"decrementPercentage",
"setPercentage",
"turnOn",
"turnOff"
],
"applianceId": "0d6884ab-030e-8ff4-ffffaa15c06e0453",
"friendlyDescription": "Study Light connected to Loxone Kit",
"friendlyName": "Study Light",
"isReachable": true,
"manufacturerName": "Loxone",
"modelName": "Spot"
}
]
}
}
Does the above payload look correct?
According to https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/smart-home-skill-api-reference#discovery-messages the version attribute is required. Your response seems to be missing that attribute.
In my (very short) experience with this, even the smallest mistake in the response would generate a silent error like the one you are experiencing.
I had the same problem. If you are creating discovery for "Entertainment Device", make sure you have wrapped the output in 'event' key for context.succeed
var payload = {
endpoints:
[
{
"endpointId": "My-id",
"manufacturerName": "Manufacturer",
"friendlyName": "Living room TV",
"description": "65in LED TV from Demo AV Company",
"displayCategories": [ ],
"cookie": {
"data": "e.g. ip address",
},
"capabilities":
[
{
"interface": "Alexa.Speaker",
"version": "1.0",
"type": "AlexaInterface"
},
]
}
]
};
var header = request.directive.header;
header.name = "Discover.Response";
context.succeed({ event: {
header: header, payload: payload
} });
Although, in the sample code, this is never mentioned and an incorrect example is given (https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/steps-to-create-a-smart-home-skill). However, the response body provided includes the "event" key.
Recreating lambda function helped me fix the issue. I also set "Enable trigger" check button while creating, though I'm not sure if that matters. After that my device provided by skill was found successfully.
Edit: Answer was wrong. Only useful information was this
This context.fail syntax is actually deprecated. Look up the Lambda context object properties, it should look more like "callback(null, resultObj)" now.
Did you include the return statement in your function?
return {
"header": header,
"payload": payload
}
It was missing in the example and after adding it, I was able to 'discover' my device.