Ably

Learn how to use Ably with Composio

Overview

SLUG: ABLY

Description

Ably is a real-time messaging platform helping developers build live features, including chat and data synchronization, with global scalability and robust reliability for modern applications

Authentication Details

generic_api_key
stringRequired

Connecting to Ably

Create an auth config

Use the dashboard to create an auth config for the Ably toolkit. This allows you to connect multiple Ably accounts to Composio for agents to use.

1

Select App

Navigate to the Ably toolkit page and click “Setup Integration”.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Integration”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using API Key

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5ably_auth_config_id = "ac_YOUR_ABLY_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/app
7
8composio = Composio()
9
10def authenticate_toolkit(user_id: str, auth_config_id: str):
11 # Replace this with a method to retrieve an API key from the user.
12 # Or supply your own.
13 user_api_key = input("[!] Enter API key")
14
15 connection_request = composio.connected_accounts.initiate(
16 user_id=user_id,
17 auth_config_id=auth_config_id,
18 config={"auth_scheme": "API_KEY", "val": user_api_key}
19 )
20
21 # API Key authentication is immediate - no redirect needed
22 print(f"Successfully connected Ably for user {user_id}")
23 print(f"Connection status: {connection_request.status}")
24
25 return connection_request.id
26
27
28connection_id = authenticate_toolkit(user_id, ably_auth_config_id)
29
30# You can verify the connection using:
31connected_account = composio.connected_accounts.get(connection_id)
32print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Ably toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["ABLY"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Query Batch Presence

Description

This tool enables querying the presence states of multiple channels in a single api request. the api retrieves the member presence details of the specified channels in parallel.

Action Parameters

channels
stringRequired
separator
stringDefaults to ,

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Query Batch Presence History

Description

This tool enables querying presence history for multiple channels in a single api request. it uses the get endpoint at https://rest.ably.io/presence to retrieve the member presence history details of the specified channels in parallel.

Action Parameters

channels
arrayRequired
direction
stringDefaults to backwards
end
integer
limit
integerDefaults to 100
start
integer

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Ably Channel

Description

Creates a new channel or retrieves an existing channel in ably. this tool allows you to programmatically create and initialize channels for real-time messaging. since ably creates channels implicitly when first used, this action publishes an empty initialization message to create/activate the channel.

Action Parameters

channel_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Channel Subscription

Description

This tool allows you to unsubscribe devices or clients from push notifications for specific channels. the operation is asynchronous, so immediate requests after deletion may briefly still return the subscription.

Action Parameters

channel
string
client_id
string
device_id
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Channel Details

Description

This tool retrieves metadata and details for a specific channel in ably. it returns a channeldetails object containing information about the channel's status, occupancy, and other metadata. the endpoint provides visibility into channel activity, including metrics such as connections, presence, publishers, and subscribers, and requires appropriate permissions.

Action Parameters

channel_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Channel History

Description

This tool retrieves the message history for a specified ably channel. it uses the get /channels/{channelid}/messages endpoint to return a paginated list of messages in chronological order, subject to parameters such as 'channelid', 'limit', 'direction', 'start', and 'end'. the tool is useful for auditing, recovering missed messages, analyzing channel activity, and debugging message flows. authentication is required via basic or token authentication.

Action Parameters

channel_id
stringRequired
direction
stringDefaults to backwards
end
integer
limit
integerDefaults to 100
start
integer

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Channel Presence History

Description

This tool retrieves the history of presence messages for a specified channel in ably. it allows you to query presence events on a channel within a given time period.

Action Parameters

channel_id
stringRequired
direction
stringDefaults to backwards
end
integer
limit
integerDefaults to 100
start
integer

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Ably Service Time

Description

This tool retrieves the current server time from ably's service in milliseconds since the epoch. it is particularly useful for time synchronization and generating valid tokenrequest timestamps to prevent replay attacks. the endpoint supports multiple content types, handles http errors, network issues, and is a fundamental tool for ensuring accurate timing in ably applications.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Application Stats

Description

This tool retrieves your application's usage statistics from ably. the stats endpoint returns a paginated list of your application's usage statistics by minute, hour, day, or month. it supports optional parameters such as start, end, direction, limit, and unit to filter and format the returned data. the stats include metrics for: - message counts and data transferred - connection counts - channel usage - api request counts - push notification metrics - token request counts

Action Parameters

direction
stringDefaults to backwards
end
integer
limit
integerDefaults to 100
start
integer
unit
stringDefaults to minute

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Push Channel Subscriptions

Description

This tool retrieves a list of all push notification channel subscriptions. it allows you to view all active push notification subscriptions for channels in your ably application. allows filtering by channel, deviceid, and clientid, supports pagination with limit parameter, and returns detailed push notification subscription information including channel, deviceid, and clientid.

Action Parameters

channel
string
client_id
string
concat_filters
boolean
device_id
string
limit
integerDefaults to 100

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Publish Message to Channel

Description

This tool will allow users to publish a message to a specified ably channel using a post request. it covers the essentials like channel name, message data, optional event name/type, and additional metadata for push notifications. it is an independent and fundamental operation within ably's real-time messaging platform.

Action Parameters

channel_id
stringRequired
client_id
string
event_name
string
message_data
stringRequired
message_id
string
push_notification
object

Action Response

data
objectRequired
error
string
successful
booleanRequired