diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index f8fee1821f..e8551ffc55 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -13471,6 +13471,9 @@ paths: signing_secret_set: type: boolean description: agents answer in Slack only when the instance sets SLACK_SIGNING_SECRET + bot_name: + type: string + description: the bot's Slack handle; absent when Slack can't be reached channels: type: array items: diff --git a/backend/windmill-api/src/slack_agents.rs b/backend/windmill-api/src/slack_agents.rs index 7a975206ab..d77af87e42 100644 --- a/backend/windmill-api/src/slack_agents.rs +++ b/backend/windmill-api/src/slack_agents.rs @@ -84,6 +84,8 @@ struct AgentSlack { slack_team_name: Option, /// Agents answer only when the instance verifies Slack's request signatures. signing_secret_set: bool, + /// The bot's Slack handle, what people mention; `None` when Slack can't be reached. + bot_name: Option, channels: Vec, } @@ -117,7 +119,17 @@ async fn list_agent_channels( let signing_secret_set = crate::SLACK_SIGNING_SECRET.is_some(); #[cfg(not(feature = "oauth2"))] let signing_secret_set = false; - Ok(Json(AgentSlack { slack_team_name, signing_secret_set, channels })) + let bot_name = match slack_team_name { + Some(_) => bot_name(&db, &w_id).await, + None => None, + }; + Ok(Json(AgentSlack { slack_team_name, signing_secret_set, bot_name, channels })) +} + +async fn bot_name(db: &DB, w_id: &str) -> Option { + let token = bot_token(db, w_id).await.ok()?; + let res = slack_call(&token, "auth.test", &[]).await.ok()?; + res["user"].as_str().map(str::to_string) } #[derive(Deserialize)] diff --git a/frontend/src/lib/components/flows/content/AgentUsePanel.svelte b/frontend/src/lib/components/flows/content/AgentUsePanel.svelte index 2d8a682e58..ae01b183a9 100644 --- a/frontend/src/lib/components/flows/content/AgentUsePanel.svelte +++ b/frontend/src/lib/components/flows/content/AgentUsePanel.svelte @@ -1,13 +1,20 @@ + (token = e.detail)} + newTokenWorkspace={workspace} + newTokenLabel={`agent-${$userStore?.username ?? 'superadmin'}-${generateRandomString(4)}`} + scopes={[`jobs:run:agents:${agentPath}`]} +/> +
- - + tab, (t) => (pickedTab = t)} wrapperClass="flex-none w-full"> + {#if chat} + + {/if} {#snippet content()} @@ -160,22 +224,26 @@
Ask it anywhere - In {slackTeamName}, mention the Windmill bot and start your message with the agent's - name, in a channel or in a direct message. Follow-ups in the same thread go to the - same agent. + In {slackTeamName}, mention the bot and start your message with the agent's name, in a + channel or in a direct message. Follow-ups in the same thread that mention the bot go + to the same agent.
{handle} your question@{botName ?? 'Windmill'} {handle} your question + + {handle} matches the last part of the agent's path. Use the whole path, + +{agentPath}, when two agents share that name. +
Default in these channels - Mentions of the Windmill bot in these channels go to this agent without its name. + Mentions of the bot in these channels go to this agent without its name. {#if channels.length === 0} No channel yet. @@ -231,26 +299,58 @@ -
- Send a message - - Returns the id of the run. Runs that share a memory_id are one conversation, - so reuse it for follow-ups and pick a new one to start over. The run is the token owner's, - with their permissions. - - -
-
- Read the answer - - Poll until completed is true; the answer is the result's - output. - - -
- - Create a token in your account settings. + + Each call runs the agent as the token's owner and returns the id of the run.{#if chat}{' '}Calls that share a memory_id are one conversation: reuse it for + follow-ups and pick a new one to start over.{/if} + + + + + + {#snippet content()} + + + + + + Then poll {resultUrl}/{id} until completed is + true; the answer is the result's output. + + + + + + + + + {/snippet} +
{/snippet} diff --git a/frontend/src/routes/(root)/(logged)/agents/get/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/agents/get/[...path]/+page.svelte index b46c0ad7b1..e37dc2764d 100644 --- a/frontend/src/routes/(root)/(logged)/agents/get/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/agents/get/[...path]/+page.svelte @@ -213,7 +213,9 @@ agentPath={path} workspace={ws} isAdmin={!!($userStore?.is_admin || $userStore?.is_super_admin)} + chat={chatAvailable} slackTeamName={slack.current?.slack_team_name} + botName={slack.current?.bot_name} signingSecretSet={slack.current?.signing_secret_set ?? true} channels={slack.current?.channels ?? []} onChanged={() => slack.refetch()}