Exemple #1
0
        public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default)
        {
            var userPhrase         = _turnContextPoweredObjectsFactory.ExtractUserPhraseFrom(turnContext);
            var botPersistentState = _turnContextPoweredObjectsFactory.CreateBotPersistentState(turnContext);
            var partner            = _turnContextPoweredObjectsFactory.CreateConversationPartner(turnContext);

            if (turnContext.Activity.Type == ActivityTypes.Message)
            {
                var messageActivity = await _activityFactory.CreateMessageActivityAsync(
                    botPersistentState,
                    userPhrase,
                    partner,
                    cancellationToken);

                await messageActivity.HandleAsync(cancellationToken);
            }
            else
            {
                partner.AppendToResponse(Roles.Narrator, $"{turnContext.Activity.Type} event detected");
            }

            await partner.RespondAsync(cancellationToken);

            await botPersistentState.CommitChangesAsync(cancellationToken);
        }
Exemple #2
0
        public async Task Receives(RecognitionResultDto recognitionResultDto)
        {
            _player = new FakePlayer();
            _userPhrase.RecognizeIntentAsync(Arg.Any <CancellationToken>()).Returns(recognitionResultDto);

            var messageActivity = await _activityFactory.CreateMessageActivityAsync(
                _botPersistentState, _userPhrase, _player, CancellationToken.None);

            await messageActivity.HandleAsync(CancellationToken.None);
        }