MCPcopy Index your code
hub / github.com/google/adk-python / main

Function main

contributing/samples/integrations/slack_agent/agent.py:25–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23
24
25async def main():
26 # 1. Setup your ADK agent
27 agent = LlmAgent(
28 name="slack_agent",
29 instruction=(
30 "You are a helpful Slack bot powered by Google ADK. Be concise and"
31 " friendly."
32 ),
33 )
34
35 # 2. Setup ADK Runner
36 runner = Runner(
37 agent=agent,
38 app_name="slack_app",
39 session_service=InMemorySessionService(),
40 auto_create_session=True,
41 )
42
43 # 3. Setup Slack Bolt App
44 # Ensure you have SLACK_BOT_TOKEN and SLACK_APP_TOKEN in your environment
45 slack_app = AsyncApp(token=os.environ.get("SLACK_BOT_TOKEN"))
46
47 # 4. Initialize SlackRunner
48 slack_runner = SlackRunner(runner=runner, slack_app=slack_app)
49
50 # 5. Start the Slack bot (using Socket Mode)
51 app_token = os.environ.get("SLACK_APP_TOKEN")
52 if not app_token:
53 print("SLACK_APP_TOKEN not found. Please set it for Socket Mode.")
54 return
55
56 print("Starting Slack bot...")
57 await slack_runner.start(app_token=app_token)
58
59
60if __name__ == "__main__":

Callers 1

agent.pyFile · 0.70

Calls 6

startMethod · 0.95
LlmAgentClass · 0.90
RunnerClass · 0.90
SlackRunnerClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected