steamship.agents.mixins.transports package#
Submodules#
steamship.agents.mixins.transports.slack module#
- class steamship.agents.mixins.transports.slack.SlackBlock(*, type: str | None = None, block_id: str | None = None, elements: List[SlackElement] | None = None)[source]#
Bases:
BaseModel
A Slack Block.
- elements: List[SlackElement] | None#
- class steamship.agents.mixins.transports.slack.SlackContextBehavior(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
Defines how history between agent and users is tracked.
These specifications are specifically in regard to how the agent interacts with Slack as it pertains to Agent Context.
- ENTIRE_CHANNEL = 'entire-channel'#
Agent context is per channel as a whole, which includes bot mentions sent to the top level channel, and across any thread in that channel.
- THREADS_ARE_NEW_CONVERSATIONS = 'threads-are-new-conversations'#
Agent context is thread-aware. The top level channel is treated as its own context, and threads have their own contexts.
- class steamship.agents.mixins.transports.slack.SlackElement(*, type: str | None = None, elements: List[SlackElement] | None = None, user_id: str | None = None, text: str | None = None)[source]#
Bases:
BaseModel
An element of a Slack Block.
- elements: List[SlackElement] | None#
- class steamship.agents.mixins.transports.slack.SlackEvent(*, type: str | None = None, user: str | None = None, channel: str | None = None, tab: str | None = None, event_ts: str | None = None, ts: str | None = None, thread_ts: str | None = None, item: str | None = None, client_msg_id: str | None = None, text: str | None = None, blocks: List[SlackBlock] | None = None, team: str | None = None, bot_id: str | None = None)[source]#
Bases:
BaseModel
A Slack Event as reported to the Bot.
- blocks: List[SlackBlock] | None#
- type: str | None#
- Common types are:
app_home_opened
app_mention,
reaction_added
message.channels - A message was posted to a channel
message.groups - A message was posted to a private channel
message.im - A message was posted to a DM
message.mpim - A message was posted to a Group DM
message.app_home - A message was posted to the “App Home” chat
hello - The client has connected to the server
See more at: https://api.slack.com/events
- class steamship.agents.mixins.transports.slack.SlackRequest(*, token: str | None = None, team_id: str | None = None, api_app_id: str | None = None, event: SlackEvent | None = None, type: str | None = None, event_id: str | None = None, event_time: int | None = None, event_context: str | None = None)[source]#
Bases:
BaseModel
The outer object presented when Slack sends a webhook notification.
https://api.slack.com/apis/connections/events-api#event-type-structure
- event: SlackEvent | None#
- class steamship.agents.mixins.transports.slack.SlackThreadingBehavior(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
Defines how responses from the agent will be delivered in response to user mentions.
- ALWAYS_THREADED = 'always-threaded'#
Responses from the bot will always be threaded. If the bot was mentioned at the top level of the channel, a new thread will be created for the response.
- FOLLOW_THREADS = 'follow-threads'#
If the bot is mentioned from the top-level channel, the response will be in the channel. If the bot is mentioned from within a thread, the response will be to that thread.
- class steamship.agents.mixins.transports.slack.SlackTransport(client: Steamship, config: SlackTransportConfig, agent_service: AgentService)[source]#
Bases:
Transport
Slack Transport Mixin for Steamship Agent to Slack interaction.
Current support: - Outputs: outputs: text, image, video, audio output - Inputs: text - Message-triggering events: direct mention, bot room entry
The included manifest file below will register a Slack bot which can be added to rooms and communicated with directly. As configured below, it will not receive messages that were not intended for it.
Integration flow:
Slack needs a different style of integration than Telegram, involving a two-way handshake.
The user:
Clicks a “Bot Manifest Link” which is generated by your Steamship Agent Instance This manifest link contains requested access as well as callback URL information.
Clicks “Accept” to create a Slack Bot using that manifest.
Clicks “Install” to install the Slack Bot to a workspace, accepting the permissions
Copy the Oauth Token from the “Settings > Install App” page.
Set the Oauth token for your agent using the set_slack_access_token POST method
At this point, (1) Slack knows about the Agent, and (2) the Agent knows about Slack.
Interacting with the Bot on Slack will trigger a request/response loop in the Agent.
- agent_service: AgentService#
- build_emit_func(chat_id: str, incoming_message_ts: str, thread_ts: str | None) Callable[[List[Block], Dict[str, Any]], None] [source]#
Return an EmitFun that sends messages to the appropriate Slack channel.
- config: SlackTransportConfig#
- get_slack_access_token() str | None [source]#
Return the Slack Access token, which permits the agent to post to Slack.
- class steamship.agents.mixins.transports.slack.SlackTransportConfig(*, slackApiBase: str = 'https://slack.com/api/', threadingBehavior: SlackThreadingBehavior = 'follow-threads', contextBehavior: SlackContextBehavior = 'entire-channel')[source]#
Bases:
Config
Configuration object for the SlackTransport.
- context_behavior: SlackContextBehavior#
- threading_behavior: SlackThreadingBehavior#
steamship.agents.mixins.transports.steamship_widget module#
- class steamship.agents.mixins.transports.steamship_widget.SteamshipWidgetTransport(client: Steamship, agent_service: AgentService)[source]#
Bases:
Transport
Experimental base class to encapsulate a Steamship web widget communication channel.
- answer(**payload) List[Block] [source]#
Endpoint that implements the contract for Steamship embeddable chat widgets. This is a PUBLIC endpoint since these webhooks do not pass a token.
steamship.agents.mixins.transports.telegram module#
- class steamship.agents.mixins.transports.telegram.TelegramTransport(client: Steamship, config: TelegramTransportConfig, agent_service: AgentService)[source]#
Bases:
Transport
Experimental base class to encapsulate a Telegram communication channel.
- agent_service: AgentService#
- config: TelegramTransportConfig#
- get_telegram_access_token() str | None [source]#
Return the Telegram Access token, which permits the agent to post to Telegram.
- instance_init()[source]#
The instance init method will be called ONCE by the engine when a new instance of a package or plugin has been created. By default, this does nothing.
- is_telegram_token_set() InvocableResponse[bool] [source]#
Return whether the Telegram token has been set as a way for a remote UI to check status.
- set_telegram_access_token(token: str) InvocableResponse[str] [source]#
Set the telegram access token.
steamship.agents.mixins.transports.transport module#
- class steamship.agents.mixins.transports.transport.Transport(client: Steamship)[source]#
Bases:
PackageMixin
,ABC
- client: Steamship#
Base class to encapsulate a communication channel mixin
Intended use is:
class MyBot(PackageService):
- def __init__(
self, client: Steamship, config: Dict[str, Any] = None, context: InvocationContext = None
- ):
super().__init__(client=client, config=config, context=context) self.set_default_agent(TestAgent()) self.add_mixin(
TelegramTransport(client=client, config=self.config, agent_service=self)
)