/// <summary> /// Creates a connector client with the given message activity for the given party as the /// recipient. If this party has an ID of a specific user (ChannelAccount is valid), then /// the that user is set as the recipient. Otherwise, the whole channel is addressed. /// </summary> /// <param name="serviceUrl">The service URL of the channel of the party to send the message to.</param> /// <param name="newMessageActivity">The message activity to send.</param> /// <returns>A bundle containing a newly created connector client (that is used to send /// the message and the message activity (the content of the message).</returns> public static ConnectorClientAndMessageBundle CreateConnectorClientAndMessageActivity( string serviceUrl, IMessageActivity newMessageActivity) { ConnectorClient newConnectorClient = new ConnectorClient(new Uri(serviceUrl)); ConnectorClientAndMessageBundle bundle = new ConnectorClientAndMessageBundle() { connectorClient = newConnectorClient, messageActivity = newMessageActivity }; return(bundle); }
/// <summary> /// Creates a connector client with the given message activity for the given party as the /// recipient. If this party has an ID of a specific user (ChannelAccount is valid), then /// the that user is set as the recipient. Otherwise, the whole channel is addressed. /// </summary> /// <param name="serviceUrl">The service URL of the channel of the party to send the message to.</param> /// <param name="newMessageActivity">The message activity to send.</param> /// <param name="appId">The bot application ID (optional).</param> /// <param name="appPassword">The bot password (optional).</param> /// <returns>A bundle containing a newly created connector client (that is used to send /// the message and the message activity (the content of the message).</returns> public static ConnectorClientAndMessageBundle CreateConnectorClientAndMessageActivity( string serviceUrl, IMessageActivity newMessageActivity, string appId = null, string appPassword = null) { ConnectorClient newConnectorClient = null; if (string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appPassword)) { newConnectorClient = new ConnectorClient(new Uri(serviceUrl)); } else { newConnectorClient = new ConnectorClient(new Uri(serviceUrl), new MicrosoftAppCredentials(appId, appPassword)); } ConnectorClientAndMessageBundle bundle = new ConnectorClientAndMessageBundle() { connectorClient = newConnectorClient, messageActivity = newMessageActivity }; return(bundle); }