Use Cases #
- Connect to DingTalk, WeCom, etc., work like openClaw but with self-control
Introduction #
SmartChart supports connecting agents to DingTalk, WeCom and other enterprise IM platforms as group bots providing intelligent services. When the bot receives messages, it calls SmartChart’s Python agent dataset logic, supporting tool calling (file viewing, data inquiry, record writing, etc.), using ds_tool() for multi-agent collaboration.
Usage #
- Create dataset, type: Agent, connector: Python, name “sCraw”
prompt = """$prompt"""
system="""You are a professional digital assistant. Based on user needs, determine whether to call available tools.
### Available Tools
#### 1. Smart Q&A
If you determine the user has data inquiry needs, return:
{"tool":"SmartQA","msg":"your summarized question"}
#### 2. View File
For viewing local file content, return: {"tool":"ViewFile","path":"file_path","summary":"whether to summarize, empty if not needed"}
#### 3. Write Record
For writing local file content, return: {"tool":"Write","msg":"content to write"}
### Response Rules
#### Tool Call Scenarios
- When needs match tool capabilities: directly return corresponding tool JSON format
- No extra explanation text
#### Normal Response Scenarios
- When needs don't match any tool: respond normally
- Professional, concise, helpful style
#### Prohibited
- Don't explain "I'm calling a tool"
- Don't wrap explanations outside JSON
- Don't ask "should I use a tool?"
- Don't output tool judgment process
### Usage Examples
"""
base_path = 'xxxx/'
ds = ds_gpt('smtgpt',prompt, system=system, tool=1)
tool = ds.get('tool')
if tool:
if tool=='ViewFile':
summary = ds.get('summary')
ds=ds_read(base_path+ds['path'])
if summary:
ds=ds_gpt('smtgpt','Please summarize:'+ds)
elif tool=='Write':
ds=ds_save_doc(ds['msg'],base_path + 'output.docx')
elif tool=='SmartQA':
ds = ds_tool(ds,deep=1)
ds = ds_gpt('smtgpt',f'My question:{prompt}\nQ&A result{ds}, do not explain SQL, please summarize')
else:
ds = ds_tool(ds)
Bot Integration #
DingTalk Bot #
Create Bot Application #
Create a bot application in DingTalk Developer Console:
- Create application
- Get app credentials (Client ID and Client Secret)
- Create bot, set to Stream mode (default)
Create Bot Application Steps #
- Open Developer Console, login, select org
- Click “Application Development” in top menu
- Click “Create Application” in top right
- Get app credentials in application details -> “Application Info” -> copy Client ID (AppKey) and Client Secret (AppSecret)
- In application details -> “Bot & Message Push”, enable bot config, fill in bot info, click “Publish” Note: Message receive mode = Stream mode
Configure config #
In homepage -> avatar dropdown -> Service Configuration:
"DD_CLIENT_ID" :"dingrxxxxxxxxxxx",
"DD_CLIENT_SECRET" : "q-xxxxxxxxxxxxxx",
Start Service #
smartchart rundingdingbot