protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { var conversationStateAccessors = ConversationState.CreateProperty <ConversationData>(nameof(ConversationData)); var conversationData = await conversationStateAccessors.GetAsync(turnContext, () => new ConversationData()); // Wait for recording to start. if ((TelephonyExtensions.IsTelephonyChannel(turnContext.Activity.ChannelId)) && (conversationData.RecordingState == RecordingState.Uninitialized)) { var waitText = $"Please wait while your call is setup."; await turnContext.SendActivityAsync( VoiceFactory.TextAndVoiceNoBargeIn(waitText), cancellationToken); return; } var userText = turnContext.Activity.Text; if (string.IsNullOrWhiteSpace(userText)) { return; } // Echo what the caller says string replyText = $"You said {userText}"; await turnContext.SendActivityAsync( VoiceFactory.TextAndVoice(replyText), cancellationToken); }
protected override async Task OnMembersAddedAsync(IList <ChannelAccount> membersAdded, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { foreach (var member in membersAdded) { if (member.Id != turnContext.Activity.Recipient.Id) { // Welcome message that will not be recorded // Played to minimize initial silence till call recording starts var welcome = "Hello and welcome."; await turnContext.SendActivityAsync( VoiceFactory.TextAndVoiceNoBargeIn(welcome), cancellationToken); // Start recording if Telephony channel if (TelephonyExtensions.IsTelephonyChannel(turnContext.Activity.ChannelId)) { await TelephonyExtensions.TryRecordingStart(turnContext, cancellationToken); } } } }