microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Samples/Samples.Lights/LightsPrompt.cs
51lines · modecode
| 1 | using Microsoft.Teams.AI.Annotations; |
| 2 | using Microsoft.Teams.Api.Activities; |
| 3 | using Microsoft.Teams.Apps; |
| 4 | using Microsoft.Teams.Apps.Extensions; |
| 5 | |
| 6 | namespace 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 | )] |
| 15 | public 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 | } |