Python API wrapper for Rocket.Chat's REST API, enabling developers to programmatically interact with Rocket.Chat servers for chat automation, bot development, and integration purposes
—
Rocket.Chat integrations management for creating and managing webhooks and other integration types. Supports both incoming and outgoing webhooks with script execution capabilities.
def integrations_create(
self,
integrations_type,
name,
enabled,
username,
channel,
script_enabled,
event=None,
urls=None,
**kwargs
):
"""
Create a new integration.
Parameters:
- integrations_type (str): Integration type ('webhook-incoming' or 'webhook-outgoing')
- name (str): Integration name
- enabled (bool): Whether integration is enabled
- username (str): Username for integration messages
- channel (str): Target channel
- script_enabled (bool): Enable script execution
- event (str, optional): Event type for outgoing webhooks
- urls (list, optional): URLs for outgoing webhooks
Returns:
requests.Response: Integration creation result
"""def integrations_get(self, integration_id, **kwargs):
"""
Retrieve integration by ID.
Parameters:
- integration_id (str): Integration ID
Returns:
requests.Response: Integration details
"""
def integrations_list(self, **kwargs):
"""
List all integrations on the server.
Returns:
requests.Response: List of integrations
"""
def integrations_history(self, integration_id, **kwargs):
"""
Get history of the specified integration.
Parameters:
- integration_id (str): Integration ID
Returns:
requests.Response: Integration execution history
"""def integrations_update(
self,
integrations_type,
name,
enabled,
username,
channel,
script_enabled,
integration_id,
**kwargs
):
"""
Update an existing integration.
Parameters:
- integrations_type (str): Integration type
- name (str): Integration name
- enabled (bool): Whether integration is enabled
- username (str): Username for integration messages
- channel (str): Target channel
- script_enabled (bool): Enable script execution
- integration_id (str): Integration ID to update
Returns:
requests.Response: Update result
"""
def integrations_remove(self, integrations_type, integration_id, **kwargs):
"""
Remove an integration from the server.
Parameters:
- integrations_type (str): Integration type
- integration_id (str): Integration ID
Returns:
requests.Response: Removal result
"""IntegrationTypes = [
"webhook-incoming", # Incoming webhooks
"webhook-outgoing" # Outgoing webhooks
]# Create incoming webhook
webhook = rocket.integrations_create(
integrations_type='webhook-incoming',
name='GitHub Integration',
enabled=True,
username='github-bot',
channel='general',
script_enabled=True
)
# Create outgoing webhook
outgoing = rocket.integrations_create(
integrations_type='webhook-outgoing',
name='Notification Bot',
enabled=True,
username='notify-bot',
channel='alerts',
script_enabled=True,
event='sendMessage',
urls=['https://example.com/webhook']
)
# List all integrations
integrations = rocket.integrations_list()
# Update integration
rocket.integrations_update(
integrations_type='webhook-incoming',
name='Updated GitHub Integration',
enabled=True,
username='github-bot',
channel='development',
script_enabled=True,
integration_id='integration_id_here'
)Install with Tessl CLI
npx tessl i tessl/pypi-rocketchat-a-p-i