コード例 #1
0
 public static async Task <ConversationResourceResponse> CreateConversationAsync(this IConversations operations, ConversationParameters parameters, Dictionary <string, List <string> > customHeaders, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateConversationWithHttpMessagesAsync(parameters, customHeaders, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
コード例 #2
0
 /// <summary>
 /// CreateConversation
 /// </summary>
 /// Create a new Conversation.
 ///
 /// POST to this method with a
 /// * Bot being the bot creating the conversation
 /// * IsGroup set to true if this is not a direct message (default is false)
 /// * Members array contining the members you want to have be in the
 /// conversation.
 ///
 /// The return value is a ResourceResponse which contains a conversation id
 /// which is suitable for use
 /// in the message payload and REST API uris.
 ///
 /// Most channels only support the semantics of bots initiating a direct
 /// message conversation.  An example of how to do that would be:
 ///
 /// ```
 /// var resource = await connector.conversations.CreateConversation(new
 /// ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new
 /// ChannelAccount("user1") } );
 /// await connect.Conversations.SendToConversationAsync(resource.Id, new
 /// Activity() ... ) ;
 ///
 /// ```
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='parameters'>
 /// Parameters to create the conversation from
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ResourceResponse> CreateConversationAsync(this IConversations operations, ConversationParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateConversationWithHttpMessagesAsync(parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(await _result.HandleErrorAsync <ResourceResponse>().ConfigureAwait(false));;
     }
 }
コード例 #3
0
        public static async Task <ConversationResourceResponse> CreateOrGetDirectConversation(
            this IConversations conversationClient,
            ChannelAccount bot,
            ChannelAccount user,
            string tenantId)
        {
            var result = await conversationClient.CreateConversationWithHttpMessagesAsync(new ConversationParameters()
            {
                Bot         = bot,
                ChannelData = JObject.FromObject(
                    new Microsoft.Bot.Connector.Teams.Models.TeamsChannelData
                {
                    Tenant = new Microsoft.Bot.Connector.Teams.Models.TenantInfo
                    {
                        Id = tenantId
                    }
                },
                    JsonSerializer.Create(new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                })),
                Members = new List <ChannelAccount>()
                {
                    user
                }
            });

            return(result.Body);
        }
コード例 #4
0
        /// <summary>
        /// Create a new direct conversation between a bot and a user
        /// </summary>
        /// <param name='operations'>The operations group for this extension method.</param>
        /// <param name='botAddress'>Bot to create conversation from</param>
        /// <param name='userAddress'>User to create conversation with</param>
        /// <param name="activity">(OPTIONAL) initial message to send to the new conversation</param>
        /// <param name='cancellationToken'>The cancellation token</param>
        public static async Task <ConversationResourceResponse> CreateDirectConversationAsync(this IConversations operations, string botAddress, string userAddress, Activity activity = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.CreateConversationWithHttpMessagesAsync(GetDirectParameters(botAddress, userAddress, activity), null, cancellationToken).ConfigureAwait(false);

            var res = _result.Body;

            MicrosoftAppCredentials.TrustServiceUrl(res.ServiceUrl);
            return(res);
        }
コード例 #5
0
        /// <summary>
        /// Create a new direct conversation between a bot and a user
        /// </summary>
        /// <param name='operations'>The operations group for this extension method.</param>
        /// <param name='bot'>Bot to create conversation from</param>
        /// <param name='user'>User to create conversation with</param>
        /// <param name="activity">(OPTIONAL) initial message to send to the new conversation</param>
        /// <param name='cancellationToken'>The cancellation token.</param>
        public static async Task <ConversationResourceResponse> CreateDirectConversationAsync(this IConversations operations, ChannelAccount bot, ChannelAccount user, Activity activity = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.CreateConversationWithHttpMessagesAsync(GetDirectParameters(bot, user, activity), null, cancellationToken).ConfigureAwait(false);

            var res = await _result.HandleErrorAsync <ConversationResourceResponse>().ConfigureAwait(false);

            MicrosoftAppCredentials.TrustServiceUrl(res.ServiceUrl);
            return(res);
        }
コード例 #6
0
        /// <summary>
        /// CreateConversation
        /// </summary>
        /// Create a new Conversation.
        ///
        /// POST to this method with a
        /// * Bot being the bot creating the conversation
        /// * IsGroup set to true if this is not a direct message (default is false)
        /// * Members array contining the members you want to have be in the
        /// conversation.
        ///
        /// The return value is a ResourceResponse which contains a conversation id
        /// which is suitable for use
        /// in the message payload and REST API uris.
        ///
        /// Most channels only support the semantics of bots initiating a direct
        /// message conversation.  An example of how to do that would be:
        ///
        /// ```
        /// var resource = await connector.conversations.CreateConversation(new
        /// ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new
        /// ChannelAccount("user1") } );
        /// await connect.Conversations.SendToConversationAsync(resource.Id, new
        /// Activity() ... ) ;
        ///
        /// ```
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='parameters'>
        /// Parameters to create the conversation from
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <ConversationResourceResponse> CreateConversationAsync(this IConversations operations, ConversationParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var _result = await operations.CreateConversationWithHttpMessagesAsync(parameters, null, cancellationToken).ConfigureAwait(false))
            {
                var res = await _result.HandleErrorAsync <ConversationResourceResponse>().ConfigureAwait(false);

                MicrosoftAppCredentials.TrustServiceUrl(res.ServiceUrl);
                return(res);
            }
        }
コード例 #7
0
        /// <summary>
        /// Create a new direct conversation between a bot and a user
        /// </summary>
        /// <param name='operations'>The operations group for this extension method.</param>
        /// <param name='botAddress'>Bot to create conversation from</param>
        /// <param name='userAddress'>User to create conversation with</param>
        /// <param name='cancellationToken'>The cancellation token</param>
        public static async Task <ResourceResponse> CreateDirectConversationAsync(this IConversations operations, string botAddress, string userAddress, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.CreateConversationWithHttpMessagesAsync(GetDirectParameters(botAddress, userAddress), null, cancellationToken).ConfigureAwait(false);

            return(await _result.HandleErrorAsync <ResourceResponse>().ConfigureAwait(false));
        }
コード例 #8
0
        /// <summary>
        /// Create a new direct conversation between a bot and a user
        /// </summary>
        /// <param name='operations'>The operations group for this extension method.</param>
        /// <param name='bot'>Bot to create conversation from</param>
        /// <param name='user'>User to create conversation with</param>
        /// <param name='cancellationToken'>The cancellation token.</param>
        public static async Task <ResourceResponse> CreateDirectConversationAsync(this IConversations operations, ChannelAccount bot, ChannelAccount user, CancellationToken cancellationToken = default(CancellationToken))
        {
            var _result = await operations.CreateConversationWithHttpMessagesAsync(GetDirectParameters(bot, user), null, cancellationToken).ConfigureAwait(false);

            return(_result.HandleError <ResourceResponse>());
        }
コード例 #9
0
        /// <summary>
        /// Create a new direct conversation between a bot and a user.
        /// </summary>
        /// <param name='operations'>The operations group for this extension method.</param>
        /// <param name='bot'>Bot to create conversation from.</param>
        /// <param name='user'>User to create conversation with.</param>
        /// <param name="activity">(OPTIONAL) initial message to send to the new conversation.</param>
        /// <param name='cancellationToken'>The cancellation token.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task <ConversationResourceResponse> CreateDirectConversationAsync(this IConversations operations, ChannelAccount bot, ChannelAccount user, Activity activity = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await operations.CreateConversationWithHttpMessagesAsync(GetDirectParameters(bot, user, activity), null, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }