Setup Instructions
Access Token
The Silverstream API is currently in a waiting list phase, and we are selectively approving only a limited number of use cases that align with our goals and capabilities.
To request access:
Visit Silverstream.ai/contact.
Select Web Agent APIs Waiting List from the dropdown menu.
Provide your details, including a brief description of your intended use case.
Submit your request.
Alternatively, you can contact us directly at hello@Silverstream.ai with your request and use case description.
Our team carefully reviews each application and will contact you if your use case is approved. Only approved requests will receive access tokens and further onboarding instructions. We are actively working to expand access to a broader range of users in the near future. Stay tuned for updates as we scale our offering!
SDK Installation
The Silverriver SDK is in beta and undergoing active development. We recommend checking the PyP page frequently for updates.
To install the latest beta version, run: pip install silverriver==0.1.37b7
If you’ve already installed the SDK, keep it updated by running: pip install --upgrade silverriver
After installation, initialize the SDK with your API token:
from silverriver import SilverRiver
client = SilverRiver(api_token="your_api_token_here")
Replace "your_api_token_here" with the token provided during onboarding.
Key Concepts and Terminology
The Silverstream platform supports the development, deployment, and monitoring of intelligent agents through specialized tools and APIs. Below are the key components and their purpose.
Note: Modules shown in opaque are work in progress and will be available in future updates.
Development Phase Tools
AI-Friendly Browser (Browser API): Simplifies webpage understanding for developers by converting complex web structures into an LLM-readable format.
RAG Database (WIP): Enhances the agent’s ability to understand the structure of a company’s own website, using custom training and retrieval techniques.
SOTA Agent (Intelligence API): Provide a base decision-making framework that can be tailored to a business’s tone and interaction style.
Deployment Phase Tools
Privacy and Safety Infrastructure: Ensures sensitive user data (PII) is replaced with realistic placeholders to maintain both privacy and functionality.
Messaging Integrations: Connect agents to messaging apps (e.g., Slack, Telegram, WhatsApp) for direct interaction.
Web-Browsing Agents LLM Router (WIP): Dynamically selects the most efficient model for handling complex tasks, improving performance during large-scale deployments.
Monitoring Phase Tools
Analytics and Golden Paths: Monitor agent performance on critical user flows, ensuring reliability and identifying regressions.
Automated QA Testing: Continuously tests defined workflows to prevent performance drops after changes or updates. Access available in beta here
API Reference Documentation link
Code Example: Interacting with the Silverstream API using Slack and a Browser Session
This Python script demonstrates how to:
Set up a Slack bot for user-agent communication.
Create a browser session using the Silverstream API.
Send actions to the browser and handle responses.
What You Need to Do Before Running This Example
Install Python
If you don’t have Python installed, download it here and follow the instructions to install it.
Get API Keys
You’ll need three things:
CRUX_API_KEY: The key to access Silverstream’s API.
SLACK_BOT_TOKEN: A token to connect your Slack bot.
SLACK_CHANNEL: The ID of the Slack channel where the bot will send and receive messages.
To obtain the SLACK_BOT_TOKEN:
Go to Slack API and create a new app.
Under “OAuth & Permissions”, you will find "OAuth Tokens". Install the app in your workspace, and when you have installed it you will see now the "Bot User OAuth Token". This token is used to authenticate your bot to send and receive messages in your Slack workspace.
Copy the "Bot User OAuth Token": this is our SLACK_BOT_TOKEN .
Here the official Slack guide to create a bot and retrieve the token here - api.slack.com/tutorials/tracks/getting-a-token
To obtain the SLACK_CHANNEL ID:
Open Slack and go to the channel where you want to interact with the bot.
Click on the channel name, then go to “About”
Scroll to the bottom, and you’ll see the Channel ID.
Install Required Tools
Open your terminal (or command prompt) and type: pip install silverriver==0.1.37b7
After installing SilverRiver, run the following command to install the other necessary libraries: pip install slack-sdk tabulate python-dotenv silverriver
Setup the environment Open your terminal and type the following commands to create a new folder for your project and navigate into it:
mkdir slack_browser_project cd slack_browser_project
Run this command in the terminal to create the .env file and edit it:
nano .env
Once the nano editor opens, type the following:
CRUX_API_KEY=your_crux_api_key SLACK_BOT_TOKEN=your_slack_bot_token SLACK_CHANNEL=your_slack_channel_id
Replace your_crux_api_key, your_slack_bot_token, and your_slack_channel_id with the actual values. Press CTRL + O to save the file (it will prompt you to confirm the file name, just press Enter).
Then press CTRL + X to exit the editor.
Run this command in the terminal to create the python example file we will run:
nano example.py
Once the nano editor opens, type the following:
import os
import time
import dotenv
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
from tabulate import tabulate
from silverriver.client import Crux
from silverriver.interfaces import SupportedModes
from silverriver.interfaces.chat import AgentChatInterface
from silverriver.interfaces.data_models import Observation, BrowserObservation, HUMAN_ROLE, ChatMessage, ASSISTANT_ROLE
from Silverstream.modules.auth import get_env_var
# Define the Slack chat interface
class SlackChat(AgentChatInterface):
def __init__(self, slack_token, channel):
self.chat_history = []
self.slack_client = WebClient(token=slack_token)
self.channel = channel
self.last_timestamp = None
def render(self):
table = []
for msg in self.chat_history:
table.append((msg.role, time.strftime('%H:%M:%S', time.localtime(msg.timestamp)), msg.message))
print("\n" + tabulate(table, ["Role", "Time", "Message"], tablefmt="grid") + "\n")
def _send_slack_msg(self, message):
ret = self.slack_client.chat_postMessage(channel=self.channel, text=message)
self.last_timestamp = float(ret["ts"])
def _add_message_to_history(self, role, message):
self.chat_history.append(ChatMessage(role=role, message=message, timestamp=time.time()))
def _get_slack_message(self):
params = {"channel": self.channel, "limit": 1}
if self.last_timestamp:
params["oldest"] = self.last_timestamp
messages = self.slack_client.conversations_history(**params)["messages"]
if not messages:
return
message, = messages
self.last_timestamp = float(message["ts"])
return message["text"]
def send_message_to_user(self, message):
self._send_slack_msg(message)
self._add_message_to_history(ASSISTANT_ROLE, message)
def send_message_to_assistant(self, message):
self._add_message_to_history(HUMAN_ROLE, message)
def wait_for_user_message(self):
self.render()
while True:
try:
message = self._get_slack_message()
except SlackApiError as e:
print(f"Error getting messages: {e}")
else:
if message:
break
time.sleep(1)
self._add_message_to_history(HUMAN_ROLE, message)
return message
# Function to enhance observations with chat history
def augment_observation(observation: BrowserObservation, chat_history: list[ChatMessage]) -> Observation:
return Observation(
**dict(observation),
chat_messages=chat_history,
last_action_error="",
)
# Main script
def main():
dotenv.load_dotenv(dotenv_path=".env")
client = Crux(os.environ["CRUX_API_KEY"])
chat = SlackChat(
slack_token=get_env_var("SLACK_BOT_TOKEN"),
channel=get_env_var("SLACK_CHANNEL"),
)
browser_session, browser_obs, browser_meta = client.create_browser_session(
start_url="https://www.google.com", chat=chat)
chat.send_message_to_user("Hello! I'm ready to assist you. What would you like me to do?")
chat.wait_for_user_message()
while True:
obs = augment_observation(browser_obs, chat.chat_history)
action = client.get_action(obs, mode=SupportedModes.FLASH, interactive=True)
try:
browser_obs = browser_session.execute(action.code)
except Exception as e:
chat.send_message_to_user(f"An error occurred: {e}")
continue
if chat.chat_history[-1].message.lower() == "exit":
break
if __name__ == "__main__":
main()
Start the python script by typing:
python slack_browser_example.py
What Happens Next?
The script will start and connect to Slack.
Open your Slack channel and send a message to interact with the bot.
Type exit in the Slack channel to stop the script.
Support Channels
For developer support, feel free to contact us through: