/// <summary>
        /// Gets an instance of <see cref="IQnAMakerClient"/>.
        /// </summary>
        /// <param name="dc">The <see cref="DialogContext"/> used to access state.</param>
        /// <returns>An instance of <see cref="IQnAMakerClient"/>.</returns>
        protected virtual Task <IQnAMakerClient> GetQnAMakerClientAsync(DialogContext dc)
        {
            var qnaClient = dc.Context.TurnState.Get <IQnAMakerClient>();

            if (qnaClient != null)
            {
                // return mock client
                return(Task.FromResult(qnaClient));
            }

            var(epKey, error)            = EndpointKey.TryGetValue(dc.State);
            var(hn, error2)              = HostName.TryGetValue(dc.State);
            var(kbId, error3)            = KnowledgeBaseId.TryGetValue(dc.State);
            var(logPersonalInfo, error4) = LogPersonalInformation.TryGetValue(dc.State);

            var endpoint = new QnAMakerEndpoint
            {
                EndpointKey = epKey ?? throw new InvalidOperationException($"Unable to get a value for {nameof(EndpointKey)} from state. {error}"),
                                    Host = hn ?? throw new InvalidOperationException($"Unable to a get value for {nameof(HostName)} from state. {error2}"),
                                                 KnowledgeBaseId = kbId ?? throw new InvalidOperationException($"Unable to get a value for {nameof(KnowledgeBaseId)} from state. {error3}")
            };

            return(Task.FromResult <IQnAMakerClient>(new QnAMaker(endpoint, new QnAMakerOptions(), HttpClient, TelemetryClient, logPersonalInfo)));
        }
    }