public override async Task <string> CreateSkillConversationIdAsync(SkillConversationIdFactoryOptions options, CancellationToken cancellationToken)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            // Create the storage key based on the SkillConversationIdFactoryOptions
            var conversationReference = options.Activity.GetConversationReference();
            var storageKey            = $"{conversationReference.Conversation.Id}-{options.BotFrameworkSkill.Id}-{conversationReference.ChannelId}-skillconvo";

            // Create the SkillConversationReference
            var skillConversationReference = new SkillConversationReference
            {
                ConversationReference = conversationReference,
                OAuthScope            = options.FromBotOAuthScope,
            };

            // Store the SkillConversationReference
            var skillConversationInfo = new Dictionary <string, object> {
                { storageKey, JObject.FromObject(skillConversationReference) }
            };
            await _storage.WriteAsync(skillConversationInfo, cancellationToken).ConfigureAwait(false);

            // Return the storageKey (that will be also used as the conversation ID to call the skill)
            return(storageKey);
        }
Example #2
0
            public override Task <string> CreateSkillConversationIdAsync(SkillConversationIdFactoryOptions options, CancellationToken cancellationToken)
            {
                var skillConversationReference = new SkillConversationReference
                {
                    ConversationReference = options.Activity.GetConversationReference(),
                    OAuthScope            = options.FromBotOAuthScope
                };
                var key = $"{options.FromBotId}-{options.BotFrameworkSkill.AppId}-{skillConversationReference.ConversationReference.Conversation.Id}-{skillConversationReference.ConversationReference.ChannelId}-skillconvo";

                _conversationRefs.GetOrAdd(key, JsonConvert.SerializeObject(skillConversationReference));
                return(Task.FromResult(key));
            }
        /// <summary>
        /// Creates a new <see cref="SkillConversationReference"/>.
        /// </summary>
        /// <param name="options">Creation options to use when creating the <see cref="SkillConversationReference"/>.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>ID of the created <see cref="SkillConversationReference"/>.</returns>
        public override async Task <string> CreateSkillConversationIdAsync(
            SkillConversationIdFactoryOptions options,
            CancellationToken cancellationToken)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            // Create the storage key based on the SkillConversationIdFactoryOptions.
            var conversationReference = options.Activity.GetConversationReference();

            string skillConversationId = string.Join(
                "-",
                options.FromBotId,
                options.BotFrameworkSkill.AppId,
                conversationReference.Conversation.Id,
                conversationReference.ChannelId,
                "skillconvo");

            // Create the SkillConversationReference instance.
            var skillConversationReference = new SkillConversationReference
            {
                ConversationReference = conversationReference,
                OAuthScope            = options.FromBotOAuthScope
            };

            // Store the SkillConversationReference using the skillConversationId as a key.
            var skillConversationInfo = new Dictionary <string, object>
            {
                {
                    skillConversationId, JObject.FromObject(skillConversationReference)
                }
            };

            await _storage.WriteAsync(skillConversationInfo, cancellationToken).ConfigureAwait(false);

            // Return the generated skillConversationId (that will be also used as the conversation ID to call the skill).
            return(skillConversationId);
        }