public async Task <IActionResult> AuthenticateAsync(string id, IConfiguration configuration)
        {
            try {
                // create an adapter and context to load the state
                var adapter = new Microsoft.Bot.Builder.Adapters.BotFrameworkAdapter(new ConfigurationCredentialProvider(configuration));
                var context = new TurnContext(adapter, new Activity()
                {
                    From = new ChannelAccount(id),
                    Type = "event",
                    Text = "authenticated"
                });

                // load the state and set the Authenticated property
                var state = context.GetConversationState <AuthenticationState>();
                state.Authenticated = true;

                // Message the bot that authentication has taken place
                var bot = new AgentBot();
                await bot.OnTurn(context);

                return(Ok());
            } catch (Exception ex) {
                return(BadRequest(ex));
            }
        }
示例#2
0
        public void GetConversationState()
        {
            // Arrange
            _target.ChatId = 156;
            // Act
            var result = _target.GetConversationState <DummyState>();

            // Assert
            Check.That(result).IsInstanceOf <DummyState>();
            Check.That(result.ChatId).Equals(156);
        }