Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[repo] docs: revamp getting started docs #1127

Merged
merged 73 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5d0a2d9
overview and quickstart dotnet
singhk97 Dec 13, 2023
3790556
add js quickstart
singhk97 Dec 13, 2023
30b9145
fixes
singhk97 Dec 13, 2023
8d6e447
fix
singhk97 Dec 13, 2023
95cebbc
refactor
singhk97 Dec 13, 2023
970c44d
formatting fix
singhk97 Dec 13, 2023
b50fed3
fix
singhk97 Dec 13, 2023
584313c
fix
singhk97 Dec 13, 2023
28110a4
fix dotnet quickstart
singhk97 Dec 14, 2023
b4e76e3
fix
singhk97 Dec 14, 2023
cc6b28e
Merge branch 'main' into kavin/docs-revamp
singhk97 Jan 3, 2024
478fffa
Update README.md
singhk97 Jan 3, 2024
0dde239
samples
singhk97 Jan 3, 2024
1af4c24
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 3, 2024
876c6e1
Update 00.OVERVIEW.md
singhk97 Jan 3, 2024
6f3ce30
Update 00.OVERVIEW.md
singhk97 Jan 3, 2024
4a862c7
italicize
singhk97 Jan 3, 2024
085009d
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 3, 2024
13837b6
fix
singhk97 Jan 3, 2024
48acdd0
fix
singhk97 Jan 3, 2024
27d583e
Update 00.OVERVIEW.md
singhk97 Jan 3, 2024
a16f1bc
make it less verbose
singhk97 Jan 3, 2024
fa9470c
Update 01.QUICKSTART.md
singhk97 Jan 3, 2024
e833b0e
migration overview
singhk97 Jan 3, 2024
a5aecbe
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 3, 2024
5d98277
simplify
singhk97 Jan 3, 2024
21a6a28
Update 00.OVERVIEW.md
singhk97 Jan 3, 2024
df11fe6
Update 00.OVERVIEW.md
singhk97 Jan 3, 2024
3d00109
fix
singhk97 Jan 3, 2024
fbf4399
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 3, 2024
ae35c07
js docs
singhk97 Jan 3, 2024
6b7c150
Update 01.JS.md
singhk97 Jan 3, 2024
eacd919
Update 01.JS.md
singhk97 Jan 3, 2024
9e765d6
changes
singhk97 Jan 4, 2024
6e44fb3
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 4, 2024
b144384
updates
singhk97 Jan 4, 2024
c19585b
Update 01.JS.md
singhk97 Jan 4, 2024
5fc8dce
Update 02.DOTNET.md
singhk97 Jan 4, 2024
9ea3b93
Update 00.OVERVIEW.md
singhk97 Jan 4, 2024
da7a3a3
Update 00.OVERVIEW.md
singhk97 Jan 4, 2024
c13df21
dotnet migration
singhk97 Jan 4, 2024
1c31c77
Update 00.OVERVIEW.md
singhk97 Jan 4, 2024
0a3c4d2
Update 01.JS.md
singhk97 Jan 4, 2024
bb949f5
Update 02.DOTNET.md
singhk97 Jan 4, 2024
f4d3432
Update 02.DOTNET.md
singhk97 Jan 4, 2024
577b146
Update 02.DOTNET.md
singhk97 Jan 4, 2024
9a6ee66
update getting started
singhk97 Jan 5, 2024
c1edeed
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 5, 2024
350aec0
update reference links
singhk97 Jan 5, 2024
c454065
Merge branch 'main' into kavin/docs-revamp
singhk97 Jan 5, 2024
e151b79
update dotnet docs
singhk97 Jan 5, 2024
94f44f2
Update README.md
singhk97 Jan 5, 2024
d457204
Update README.md
singhk97 Jan 5, 2024
ed4efa3
update c# readme
singhk97 Jan 5, 2024
953b37a
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 5, 2024
545da11
Update README.md
singhk97 Jan 8, 2024
ae890a0
Update README.md
singhk97 Jan 8, 2024
e6d45c3
Update README.md
singhk97 Jan 8, 2024
1aeb753
refactor js sample docs
singhk97 Jan 8, 2024
abf92a4
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 8, 2024
a8d3289
removing duplicate sample instructions
singhk97 Jan 8, 2024
f8efc18
update js samples readme
singhk97 Jan 8, 2024
7330524
update link
singhk97 Jan 8, 2024
17e768f
fix navigation formatting
singhk97 Jan 8, 2024
d4e334a
update formatting
singhk97 Jan 8, 2024
ab14a44
fix
singhk97 Jan 8, 2024
b0b13e2
Merge branch 'main' into kavin/docs-revamp
singhk97 Jan 8, 2024
df33980
rename files to remove ordering
singhk97 Jan 8, 2024
8b724ad
Merge branch 'kavin/docs-revamp' of https://github.com/microsoft/team…
singhk97 Jan 8, 2024
c4684b1
turn concept
singhk97 Jan 8, 2024
552c021
Update README.md
singhk97 Jan 8, 2024
71ffd3e
Update README.md
singhk97 Jan 8, 2024
94efc34
Update README.md
singhk97 Jan 8, 2024
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
154 changes: 5 additions & 149 deletions dotnet/packages/Microsoft.TeamsAI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,157 +7,13 @@ This SDK is specifically designed to assist you in creating bots capable of inte
Requirements:

* [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
* [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) resource or an account with [OpenAI](https://platform.openai.com/)
* (Optional) [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) resource or an account with [OpenAI](https://platform.openai.com/)

## Getting Started: Migration vs New Project

If you're migrating an existing project, switching to add on the Teams AI Library layer is quick and simple. For a more-detailed walkthrough, see the [migration guide](https://github.com/microsoft/teams-ai/blob/main/getting-started/dotnet/00.MIGRATION.md). The basics are listed below.
## Getting Started

### Migration
### *IMPORTANT Migration code & steps below needs to be updated for C#

In your existing Teams bot, you'll need to add the Teams AI Library SDK package and import it into your bot code.

```bash
dotnet add package Microsoft.TeamsAI
```

Replace `BotActivityHandler` and `ApplicationTurnState` in your bot. Note that here, `TurnState` is constructed to include `ConversationState`, but can also have `UserState` and `TempState`.

`State.cs`:

```c#
namespace Application {
public class ApplicationTurnState : TurnState
{
public ApplicationTurnState()
{
ScopeDefaults[CONVERSATION_SCOPE] = new ConversationState();
}

public new ConversationState Conversation
{
get
{
TurnStateEntry? scope = GetScope(CONVERSATION_SCOPE);

if (scope == null)
{
throw new ArgumentException("TurnState hasn't been loaded. Call LoadStateAsync() first.");
}

return (ConversationState)scope.Value!;
}
set
{
TurnStateEntry? scope = GetScope(CONVERSATION_SCOPE);

if (scope == null)
{
throw new ArgumentException("TurnState hasn't been loaded. Call LoadStateAsync() first.");
}

scope.Replace(value!);
}
}
}

public class ConversationState : Record
{
public int Count
{
get => Get<int>("count");
set => Set("count", value);
}
}
}
```

`Program.cs`

```c#
using Application;

...

Application<ApplicationTurnState> app = new(new())
{
Storage = new MemoryStorage()
};
```

The rest of the code stays the same.

That's it!

Run your bot (with ngrok) and sideload your manifest to test.

For migrating specific features such as Message Extension and Adaptive Card capabilities, please see the [Migration Guide](https://github.com/microsoft/teams-ai/blob/main/getting-started/dotnet/00.MIGRATION.md).

### New Project

If you are starting a new project, you can use the [Teams AI Library SDK echobot sample](https://github.com/microsoft/teams-ai/tree/main/dotnet/samples/01.messaging.echoBot) as a starting point. You don't need to make any changes to the sample to get it running, but you can use it as your base setup. Echo Bot supports the Teams AI Library SDK out of the box.

You can either copy-paste the code into your own project, or clone the repo and run the Teams Toolkit features to explore.

### Optional ApplicationBuilder Class

You may also use the `ApplicationBuilder` class to instantiate your `Application` instance. This option provides greater readability and separates the management of the various configuration options (e.g., storage, turn state, AI module options, etc).

`Program.cs`:

```c#
// Old method:
// Application<ApplicationTurnState> app = new()
// {
// storage
// };

var app = new ApplicationBuilder<ApplicationTurnState>()
.WithStorage(storage)
.Build(); // this function internally calls the Application constructor
```

## AI Setup

The detailed steps for setting up your bot to use AI are in the [AI Setup Guide](https://github.com/microsoft/teams-ai/blob/main/getting-started/dotnet/01.AI-SETUP.md).

On top of your Microsoft App Id and password, you will need an OpenAI API key or an Azure OpenAI key and endpoint. You can get one from the [OpenAI platform](https://platform.openai.com/) or from [Azure OpenAI Service](https://azure.microsoft.com/en-us/products/ai-services/openai-service). Once you have your key, add it to `appsettings.Development.json` or `appsettings.json`.

### AI Prompt Manager
### *IMPORTANT AI Prompt Manager code needs to be updated to C#

```c#
PromptManager prompts = new(new()
{
PromptFolder = "./Prompts"
});

ActionPlanner<ApplicationTurnState> planner = new(
options: new(
model: sp.GetService<OpenAIModel>()!,
prompts: prompts,
defaultPrompt: async (context, state, planner) =>
{
PromptTemplate template = prompts.GetPrompt("default");
return await Task.FromResult(template);
}
)
{ LogRepairs = true }
);

// Define storage and application
// - Note that we're not passing a prompt for our AI options as we won't be chatting with the app.
MemoryStorage storage = new();
Application<ApplicationTurnState> app = new()
{
Storage = storage,
AI: new(planner)
};
```

For more information on how to create and use prompts, see [PROMPTS](https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/teams%20conversational%20ai/how-conversation-ai-get-started?tabs=javascript4%2Cjavascript1%2Cjavascript3%2Cjavascript2#:~:text=VectraDataSource%20and%20OpenAIEmbeddings%3A-,Prompt,-Prompts%20are%20pieces) and look at the [samples](https://github.com/microsoft/teams-ai/tree/main/dotnet/samples) numbered `04._.xxx`.

Happy coding!
To get started, take a look at the [getting started docs](https://github.com/microsoft/teams-ai/blob/main/getting-started/README.md).

## Migration

If you're migrating an existing project, switching to add on the Teams AI Library layer is quick and simple. See the [migration guide](https://github.com/microsoft/teams-ai/blob/main/getting-started/MIGRATION/DOTNET.md).
62 changes: 2 additions & 60 deletions dotnet/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ There are a few ways to get the application up and running. The latest way is us
#### Steps

1. Open the solution in Visual Studio. (For example `EchoBot.sln`).
- Ensure that you set the appropriate config values (ex Azure OpenAI API key). You can find specific instructions in the sample readme under the `Set up instructions` section. If you can't find this section, then it means that the bot does not need them.
- Ensure that you set the appropriate config values (ex Azure OpenAI API key). You can find specific instructions in the sample readme under the `Set up instructions` section. If you can't find this section, then it means there is no required config values to set.
2. In the debug dropdown menu, select `Dev Tunnels > Create A Tunnel` (Tunnel type: `Persistent` & Access: `Public`) or select an existing public dev tunnel.

![image](https://github.com/microsoft/teams-ai/assets/115390646/d7246d38-8276-4b2a-bc22-b72f36aa41b9)
Expand Down Expand Up @@ -96,65 +96,7 @@ There are a few ways to get the application up and running. The latest way is us

## List of Samples

Follow the above instructions to run the C# .NET samples. Here's a list of the samples:

### Basic Conversational Experience

#### [Echo Bot](/dotnet/samples/01.echoBot/)

A conversational bot that listens for specific commands and offers a simple conversational flow: echoing the user's message back to them.

This sample illustrates basic conversational bot behavior in Microsoft Teams and shows the Teams AI SDK's ability to scaffold conversational bot components.

#### [Search Command](/dotnet/samples/02.messageExtensions.a.searchCommand/)

A Message Extension (ME) built to search NuGet for a specific package and return the result as an Adaptive Card.

This sample illustrates the Teams AI SDK's ability to scaffold search-based Message Extensions and return Adaptive Card components.

#### [Type Ahead Bot](/dotnet/samples/03.adaptiveCards.a.typeAheadBot/)

A conversational bot that uses dynamic search to generate Adaptive Cards in Microsoft Teams.

This sample illustrates the Teams AI SDK's ability to scaffold conversational bot and Adaptive Card components.

### AI-Powered Experiences

#### [Chef Bot](/dotnet/samples/04.ai.a.teamsChefBot/)

A conversational bot for Microsoft Teams, designed as a helper bot for building Teams app. The bot uses the text-davinci-003 model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation.

This sample illustrates basic conversational bot behavior in Microsoft Teams. The bot is built to allow GPT to facilitate the conversation on its behalf, using only a natural language prompt file to guide it.

#### [GPT ME](/dotnet/samples/04.ai.b.messageExtensions.gptME/)

A Message Extension (ME) for Microsoft Teams that leverages the text-davinci-003 model to help users generate and update posts. The extension is designed to assist users in creating posts that are appropriate for a business environment.

This sample illustrates basic ME behavior in Microsoft Teams. The ME is built to allow GPT to facilitate the conversation by generating posts based on what the user requires. e.g., "Make my post sound more professional."

#### [Light Bot](/dotnet/samples/04.ai.c.actionMapping.lightBot/)

A conversational bot for Microsoft Teams, designed as an AI assistant. The bot connects to a third-party service to turn a light on or off.

This sample illustrates more complex conversational bot behavior in Microsoft Teams. The bot is built to allow GPT to facilitate the conversation on its behalf as well as manually defined responses, and maps user intents to user defined actions.

#### [List Generator AI Assistant](/dotnet/samples/04.ai.d.chainedActions.listBot/)

Similar to the Light On/Off sample, this is a conversational bot for Microsoft Teams, designed as an AI assistant. This bot showcases how to map intents to actions, but instead of returning text, it generates dynamically created Adaptive Cards as a response.

This sample illustrates complex conversational bot behavior in Microsoft Teams and showcases the richness of possibilities for responses.

#### [DevOps AI Assistant](/dotnet/samples/04.ai.e.chainedActions.devOpsBot/)

Similar to the List Generator AI Assistant sample, this is a conversational bot for Microsoft Teams, designed as an AI assistant. This bot showcases how to map intents to actions, but instead of returning text, it generates dynamically created Adaptive Cards as a response.

This sample illustrates complex conversational bot behavior in Microsoft Teams and showcases the richness of possibilities for responses.

#### [Twenty Questions](/dotnet/samples/04.e.twentyQuestions/)

A conversational bot for Microsoft Teams, designed as an AI assistant of the Ultimate Guessing Game!

This sample showcases the incredible capabilities of language models and the concept of user intent. Challenge your skills as the human player and try to guess a secret within 20 questions, while the AI-powered bot answers your queries about the secret.
You can find the list of samples in the [getting started docs](../../getting-started/SAMPLES.md).

## Miscellanous Resources

Expand Down
Loading
Loading