Ejemplo n.º 1
0
 /// <summary>
 /// SendConversationHistory() API for Skill.
 /// </summary>
 /// <remarks>
 /// Override this method to this method allows you to upload the historic activities to the conversation.
 ///
 /// Sender must ensure that the historic activities have unique ids and
 /// appropriate timestamps. The ids are used by the client to deal with
 /// duplicate activities and the timestamps are used by the client to render
 /// the activities in the right order.
 /// </remarks>
 /// <param name="claimsIdentity">claimsIdentity for the bot, should have AudienceClaim, AppIdClaim and ServiceUrlClaim.</param>
 /// <param name='conversationId'>Conversation ID.</param>
 /// <param name='transcript'>Transcript of activities.</param>
 /// <param name='cancellationToken'>The cancellation token.</param>
 /// <returns>task for a resource response.</returns>
 protected virtual Task <ResourceResponse> OnSendConversationHistoryAsync(ClaimsIdentity claimsIdentity, string conversationId, Transcript transcript, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Uploads the historic activities of the conversation.
        /// </summary>
        /// <param name="authHeader">The authentication header.</param>
        /// <param name="conversationId">The conversation Id.</param>
        /// <param name="transcript">Transcript of activities.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
        public async Task <ResourceResponse> HandleSendConversationHistoryAsync(string authHeader, string conversationId, Transcript transcript, CancellationToken cancellationToken = default)
        {
            var claimsIdentity = await AuthenticateAsync(authHeader).ConfigureAwait(false);

            return(await OnSendConversationHistoryAsync(claimsIdentity, conversationId, transcript, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// TBD.
        /// </summary>
        /// <param name="conversation"></param>
        /// <param name="code"></param>
        /// <param name="transcript"></param>
        /// <returns></returns>
        public static IEventActivity CreateHandoffCompleted(ConversationAccount conversation, string code, Transcript transcript)
        {
            var handoffEvent = CreateHandoffEvent(HandoffEventNames.HandoffResponse, code, conversation);

            if (transcript != null)
            {
                var attchment = new Attachment
                {
                    Content     = transcript,
                    ContentType = "application/json",
                    Name        = "Transcript",
                };
                handoffEvent.Attachments.Add(attchment);
            }

            return(handoffEvent);
        }
        /// <summary>
        /// Create handoff initiation event.
        /// </summary>
        /// <param name="turnContext">turn context.</param>
        /// <param name="handoffContext">agent hub-specific context.</param>
        /// <param name="transcript">transcript of the conversation.</param>
        /// <returns>handoff event.</returns>
        public static IEventActivity CreateHandoffInitiation(ITurnContext turnContext, object handoffContext, Transcript transcript = null)
        {
            var handoffEvent = CreateHandoffEvent(HandoffEventNames.InitiateHandoff, handoffContext, turnContext.Activity.Conversation);

            var conversationReference = turnContext.Activity.GetConversationReference();

            handoffEvent.From       = turnContext.Activity.From;
            handoffEvent.RelatesTo  = turnContext.Activity.GetConversationReference();
            handoffEvent.ReplyToId  = turnContext.Activity.Id;
            handoffEvent.ServiceUrl = turnContext.Activity.ServiceUrl;
            handoffEvent.ChannelId  = turnContext.Activity.ChannelId;

            if (transcript != null)
            {
                var bufferedActivities = transcript.Activities.Select(a => a.ApplyConversationReference(conversationReference)).ToArray();
                var attchment          = new Attachment
                {
                    Content     = new Transcript(bufferedActivities),
                    ContentType = "application/json",
                    Name        = "Transcript",
                };
                handoffEvent.Attachments.Add(attchment);
            }

            return(handoffEvent);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create handoff initiation event.
        /// </summary>
        /// <param name="turnContext">turn context.</param>
        /// <param name="handoffContext">agent hub-specific context.</param>
        /// <param name="transcript">transcript of the conversation.</param>
        /// <returns>handoff event.</returns>
        public static IEventActivity CreateHandoffInitiation(ITurnContext turnContext, object handoffContext, Transcript transcript = null)
        {
            if (turnContext == null)
            {
                throw new ArgumentNullException(nameof(turnContext));
            }

            var handoffEvent = CreateHandoffEvent(HandoffEventNames.InitiateHandoff, handoffContext, turnContext.Activity.Conversation);

            handoffEvent.From       = turnContext.Activity.From;
            handoffEvent.RelatesTo  = turnContext.Activity.GetConversationReference();
            handoffEvent.ReplyToId  = turnContext.Activity.Id;
            handoffEvent.ServiceUrl = turnContext.Activity.ServiceUrl;
            handoffEvent.ChannelId  = turnContext.Activity.ChannelId;

            if (transcript != null)
            {
                var attchment = new Attachment
                {
                    Content     = transcript,
                    ContentType = "application/json",
                    Name        = "Transcript",
                };
                handoffEvent.Attachments.Add(attchment);
            }

            return(handoffEvent);
        }