microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
d6998dba88f6dead883a11ae04dd022867d250f1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Samples/Samples.Lights/LightsPrompt.cs

51lines · modecode

1using Microsoft.Teams.AI.Annotations;
2using Microsoft.Teams.Api.Activities;
3using Microsoft.Teams.Apps;
4using Microsoft.Teams.Apps.Extensions;
5
6namespace Samples.Lights;
7
8[Prompt]
9[Prompt.Description("manage light status")]
10[Prompt.Instructions(
11 "The following is a conversation with an AI assistant.",
12 "The assistant can turn the lights on or off.",
13 "The lights are currently off."
14)]
15public class LightsPrompt
16{
17 private IContext<IActivity> Context => _services.GetTeamsContext();
18 private readonly IServiceProvider _services;
19
20 public LightsPrompt(IServiceProvider provider)
21 {
22 _services = provider;
23 }
24
25 [Function]
26 [Function.Description("get the current light status")]
27 public bool GetLightStatus()
28 {
29 return State.From(Context).Status;
30 }
31
32 [Function]
33 [Function.Description("turn the lights on")]
34 public string LightsOn()
35 {
36 var state = State.From(Context);
37 state.Status = true;
38 state.Save(Context);
39 return "the lights are now on";
40 }
41
42 [Function]
43 [Function.Description("turn the lights off")]
44 public string LightsOff()
45 {
46 var state = State.From(Context);
47 state.Status = false;
48 state.Save(Context);
49 return "the lights are now off";
50 }
51}