Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file modified msteams-platform/assets/downloads/MicrosoftTeams-Screens.pdf
Binary file not shown.
Binary file modified msteams-platform/assets/downloads/MicrosoftTeams-Tabs.pdf
Binary file not shown.
105 changes: 88 additions & 17 deletions msteams-platform/concepts/bots/bots-conversations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: Send and receive messages with a bot
description: Describes how to send and receive messages with bots in Microsoft Teams
keywords: teams bots messages
ms.date: 03/02/2018
---

# Have a conversation with a Microsoft Teams bot

A conversation is a series of messages sent between your bot and one or more users. Bots in Microsoft Teams allow sending messages in either personal conversations with a single user (also known as one-on-one or 1:1 chats) or a group conversation in a Teams channel.
Expand Down Expand Up @@ -287,21 +287,21 @@ You can use the `session.connector.update` method in the Bot Builder SDK to upda

```js
function sendCardUpdate(bot, session, originalMessage, address) {
var origAttachment = originalMessage.data.attachments[0];
origAttachment.content.subtitle = 'Assigned to Larry Jin';

var updatedMsg = new builder.Message()
.address(address)
.textFormat(builder.TextFormat.markdown)
.addAttachment(origAttachment)
.toMessage();

session.connector.update(updatedMsg, function(err, addresses) {
if (err) {
console.log(`Could not update the message`);
}
});

var origAttachment = originalMessage.data.attachments[0];
origAttachment.content.subtitle = 'Assigned to Larry Jin';

var updatedMsg = new builder.Message()
.address(address)
.textFormat(builder.TextFormat.markdown)
.addAttachment(origAttachment)
.toMessage();

session.connector.update(updatedMsg, function(err, addresses) {
if (err) {
console.log(`Could not update the message`);
}
});
}
```

Expand All @@ -314,4 +314,75 @@ You can create a 1:1 conversation with a user or start a new reply chain in a ch

## Deleting messages

At this point, there is no way for you to delete messages via your bot. You can update content in your message (see [Updating messages](#updating-messages) earlier in this topic), but there is no platform support to delete messages from users or your bot.
Messages can be deleted using the connectors [`delete()`](https://docs.botframework.com/en-us/node/builder/chat-reference/interfaces/_botbuilder_d_.iconnector.html#delete) method in the [BotBuilder SDK](https://docs.microsoft.com/en-us/bot-framework/bot-builder-overview-getstarted).

```TypeScript
bot.dialog('BotDeleteMessage', function (session: builder.Session) {
var msg = new teams.TeamsMessage(session).text("Bot will delete this message in 5 sec.")
bot.send(msg, function (err, response) {
if (err) {
console.log(err);
session.endDialog();
}

console.log('Proactive message response:');
console.log(response);
console.log('---------------------------------------------------')
setTimeout(function () {
var activityId: string = null;
var messageAddress: builder.IChatConnectorAddress = null;
if (response[0]){
messageAddress = response[0];
activityId = messageAddress.id;
}

if (activityId == null)
{
console.log('Message failed to send.');
session.endDialog();
return;
}

// Bot delete message
let address: builder.IChatConnectorAddress = {
channelId: 'msteams',
user: messageAddress.user,
bot: messageAddress.bot,
id : activityId,
serviceUrl : (<builder.IChatConnectorAddress>session.message.address).serviceUrl,
conversation: {
id: session.message.address.conversation.id
}
};

connector.delete(address, function (err) {
if (err)
{
console.log(err);
}
else
{
console.log("Message: " + activityId + " deleted successfully.");
}

// Try editing deleted message would fail
var newMsg = new builder.Message().address(address).text("To edit message.");
connector.update(newMsg.toMessage(), function (err, address) {
if (err)
{
console.log(err);
console.log('Deleted message can not be edited.');
}
else
{
console.log("There is something wrong. Message: " + activityId + " edited successfully.");
console.log(address);
}

session.endDialog();
});
});
}, 5000);
});
})
```
5 changes: 3 additions & 2 deletions msteams-platform/resources/microsoft-graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
title: Use Microsoft Graph in tab pages
description: Explains how to use the Microsoft Graph APIs in Microsoft Teams tab pages
keywords: teams graph tabs
ms.date: 03/02/2018
---

# Use Microsoft Graph in your Microsoft Teams tab pages

You might want to use [Microsoft Graph](https://developer.microsoft.com/en-us/graph/) in your [configuration](~/concepts/tabs/tabs-configuration) and [content](~/concepts/tabs/tabs-content) pages. For example, you might want to access the user's profile information, calendar, or files.

To use the Microsoft Graph APIs, you must [get an access token](https://developer.microsoft.com/en-us/graph/docs/concepts/auth_overview). When your app is running in Microsoft Teams, the only difference is that you must drive the authentication flow, as described in [Authenticate a user](~/concepts/authentication/authentication).
To use the Microsoft Graph APIs, you must [get an access token](https://developer.microsoft.com/en-us/graph/docs/concepts/auth_overview). When your app is running in Microsoft Teams, the only difference is that you must drive the authentication flow, as described in [Authentication](~/concepts/authentication/authentication).

Be careful if you use the Microsoft Graph APIs for [team resources](https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/group), rather than those for the current user, because the two have different consent models. Typically, users can directly consent to your Microsoft Teams app within a specific team. However, currently an admin must also consent to your app (as registered in Azure Active Directory) using these group APIs, at which point the app then has API access to all the groups or teams for each user. (See [Group permissions](https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference#group-permissions) for more information.) You should therefore ensure that your Microsoft Teams app handles not having the permissions it needs, and that it respects the user's intention about the teams in which it should operate.
Microsoft Teams also has [APIs for Microsoft Graph](https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/teams_api_overview). However, there are currently some limitations to be aware of; in particular, be careful if you use the Microsoft Graph APIs for [team resources](https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/group), rather than those for the current user, because the two have different consent models. Typically, users can directly consent to your Microsoft Teams app within a specific team. However, currently an admin must also consent to your app (as registered in Azure Active Directory) using these group APIs, at which point the app then has API access to all the groups or teams for each user. (See [Group permissions](https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference#group-permissions) for more information.) You should therefore ensure that your Microsoft Teams app handles not having the permissions it needs, and that it respects the user's intention about the teams in which it should operate.