Camel.toolkits.slack toolkit
SlackToolkit
A class representing a toolkit for Slack operations.
This class provides methods for Slack operations such as creating a new channel, joining an existing channel, leaving a channel.
init
Initializes a new instance of the SlackToolkit class.
Parameters:
- timeout (Optional[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:
None
)
_login_slack
Authenticate using the Slack API.
Parameters:
- slack_token (str, optional): The Slack API token. If not provided, it attempts to retrieve the token from the environment variable SLACK_BOT_TOKEN or SLACK_USER_TOKEN.
- ssl (SSLContext, optional): SSL context for secure connections. Defaults to
None
.
Returns:
WebClient: A WebClient object for interacting with Slack API.
create_slack_channel
Creates a new slack channel, either public or private.
Parameters:
- name (str): Name of the public or private channel to create.
- is_private (bool, optional): Whether to create a private channel instead of a public one. Defaults to
True
.
Returns:
str: JSON string containing information about Slack channel created.
join_slack_channel
Joins an existing Slack channel.
Parameters:
- channel_id (str): The ID of the Slack channel to join.
Returns:
str: A confirmation message indicating whether join successfully or an error message.
leave_slack_channel
Leaves an existing Slack channel.
Parameters:
- channel_id (str): The ID of the Slack channel to leave.
Returns:
str: A confirmation message indicating whether leave successfully or an error message.
get_slack_channel_information
Returns:
str: JSON string containing information about Slack channels.
get_slack_channel_message
Retrieve messages from a Slack channel.
Parameters:
- channel_id (str): The ID of the Slack channel to retrieve messages from.
Returns:
str: JSON string containing filtered message data.
send_slack_message
Send a message to a Slack channel.
Parameters:
- message (str): The message to send.
- channel_id (str): The ID of the Slack channel to send message.
- user (Optional[str]): The user ID of the recipient. Defaults to
None
.
Returns:
str: A confirmation message indicating whether the message was sent successfully or an error message.
delete_slack_message
Delete a message to a Slack channel.
Parameters:
- time_stamp (str): Timestamp of the message to be deleted.
- channel_id (str): The ID of the Slack channel to delete message.
Returns:
str: A confirmation message indicating whether the message was delete successfully or an error message.
get_tools
Returns:
List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.