alibabacloud-rds-copilot

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Alibaba Cloud RDS Copilot Intelligent Operations Assistant

阿里云RDS Copilot智能运维助手

This skill serves as an intelligent agent for Alibaba Cloud RDS Copilot in conversations, helping users with RDS-related intelligent Q&A, SQL optimization, instance operations, and troubleshooting.
本技能是对话场景下的阿里云RDS Copilot智能Agent,可帮助用户处理RDS相关的智能问答、SQL优化、实例操作以及故障排查问题。

Scenario Description

场景说明

Architecture:
Alibaba Cloud CLI + RdsAi OpenAPI
Main features:
  • Understand user's natural language requests (Chinese or English), identify if related to RDS Copilot
  • Directly call Alibaba Cloud CLI to execute
    aliyun rdsai chat-messages
    command for real-time RDS Copilot queries
  • When receiving results or user-pasted error messages, further explain, diagnose, and provide recommendations

架构:
Alibaba Cloud CLI + RdsAi OpenAPI
主要功能:
  • 理解用户的自然语言请求(中文或英文),识别是否与RDS Copilot相关
  • 直接调用阿里云CLI执行
    aliyun rdsai chat-messages
    命令,实时查询RDS Copilot
  • 收到结果或用户粘贴的报错信息时,进一步解释、诊断并提供建议

Installation

安装

Pre-check: Alibaba Cloud CLI must be installed
This skill uses Alibaba Cloud CLI to call RdsAi OpenAPI. You need to install and configure Alibaba Cloud CLI first.
预检查:必须安装阿里云CLI
本技能使用阿里云CLI调用RdsAi OpenAPI,你需要先安装并配置阿里云CLI。

macOS Installation

macOS安装

bash
undefined
bash
undefined

Option 1: Install via Homebrew (recommended)

选项1:通过Homebrew安装(推荐)

brew install aliyun-cli
brew install aliyun-cli

Option 2: Install via PKG package

选项2:通过PKG安装包安装

curl -O https://aliyuncli.alicdn.com/aliyun-cli-latest.pkg sudo installer -pkg aliyun-cli-latest.pkg -target /
curl -O https://aliyuncli.alicdn.com/aliyun-cli-latest.pkg sudo installer -pkg aliyun-cli-latest.pkg -target /

Option 3: Install via one-click script

选项3:通过一键脚本安装

/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
undefined
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
undefined

Linux Installation

Linux安装

bash
undefined
bash
undefined

Install via one-click script

通过一键脚本安装

/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"

Or download TGZ package for manual installation

或者下载TGZ包手动安装

curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli.tgz tar xzvf aliyun-cli.tgz sudo mv aliyun /usr/local/bin/
undefined
curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli.tgz tar xzvf aliyun-cli.tgz sudo mv aliyun /usr/local/bin/
undefined

Verify Installation

验证安装

bash
aliyun version

bash
aliyun version

Credential Configuration

凭证配置

Option 1: Interactive Configuration (Recommended)

选项1:交互式配置(推荐)

bash
aliyun configure --profile rdsai
Follow the prompts to enter:
  • Access Key Id: Your AccessKey ID
  • Access Key Secret: Your AccessKey Secret
  • Default Region Id: cn-hangzhou (or other regions)
bash
aliyun configure --profile rdsai
按照提示输入:
  • Access Key Id:你的AccessKey ID
  • Access Key Secret:你的AccessKey Secret
  • Default Region Id:cn-hangzhou(或其他区域)

Option 2: Non-interactive Configuration

选项2:非交互式配置

bash
aliyun configure set \
  --profile rdsai \
  --mode AK \
  --access-key-id <yourAccessKeyID> \
  --access-key-secret <yourAccessKeySecret> \
  --region cn-hangzhou

bash
aliyun configure set \
  --profile rdsai \
  --mode AK \
  --access-key-id <yourAccessKeyID> \
  --access-key-secret <yourAccessKeySecret> \
  --region cn-hangzhou

Command Format

命令格式

Basic Command Structure

基础命令结构

bash
aliyun rdsai chat-messages \
  --query '<query content>' \
  --inputs RegionId=<region ID> Language=<language> Timezone=<timezone> [CustomAgentId=<custom agent ID>] \
  --event-mode separate \
  --endpoint rdsai.aliyuncs.com \
  --user-agent 'AlibabaCloud-Agent-Skills' \
  [--conversation-id '<conversation ID>']
bash
aliyun rdsai chat-messages \
  --query '<query content>' \
  --inputs RegionId=<region ID> Language=<language> Timezone=<timezone> [CustomAgentId=<custom agent ID>] \
  --event-mode separate \
  --endpoint rdsai.aliyuncs.com \
  --user-agent 'AlibabaCloud-Agent-Skills' \
  [--conversation-id '<conversation ID>']

Parameter Description

参数说明

IMPORTANT: Parameter Confirmation — Before executing any command, Determine user intent: SQL writing/optimization, SQL diagnosis, instance parameter tuning, troubleshooting, performance analysis, query instance list, etc. Collect necessary parameters (use default values if not specified).
ParameterRequired/OptionalDescriptionDefault
--query
RequiredUser query content-
--inputs RegionId=
OptionalAlibaba Cloud region ID
cn-hangzhou
--inputs Language=
OptionalLanguage
zh-CN
--inputs Timezone=
OptionalTimezone
Asia/Shanghai
--inputs CustomAgentId=
OptionalCustom Agent IDNone
--event-mode
OptionalEvent mode
separate
--endpoint
RequiredAPI endpoint
rdsai.aliyuncs.com
--conversation-id
OptionalConversation ID for multi-turn dialogueNone
--region
OptionalRegion for API callCredential default region
--profile
OptionalSpecify credential profile nameDefault profile
--user-agent
RequiredCustom User-Agent
AlibabaCloud-Agent-Skills

重要提示:参数确认 — 执行任何命令前, 明确用户意图:SQL编写/优化、SQL诊断、实例参数调优、故障排查、性能分析、查询实例列表等。 收集必要参数(未指定时使用默认值)。
参数必填/可选说明默认值
--query
必填用户查询内容-
--inputs RegionId=
可选阿里云区域ID
cn-hangzhou
--inputs Language=
可选语言
zh-CN
--inputs Timezone=
可选时区
Asia/Shanghai
--inputs CustomAgentId=
可选自定义Agent ID
--event-mode
可选事件模式
separate
--endpoint
必填API endpoint
rdsai.aliyuncs.com
--conversation-id
可选多轮对话的会话ID
--region
可选API调用的区域凭证默认区域
--profile
可选指定凭证配置名称默认配置
--user-agent
必填自定义User-Agent
AlibabaCloud-Agent-Skills

RAM Permissions

RAM权限

This skill requires the following RAM permissions. See references/ram-policies.md for details.
PermissionDescription
rdsai:ChatMessages
Call RDS AI Assistant API

本技能需要以下RAM权限。详情查看references/ram-policies.md
权限说明
rdsai:ChatMessages
调用RDS AI助手API

Core Workflow

核心工作流程

1. Confirm Task Type and Parameters

1. 确认任务类型和参数

Determine user intent: SQL writing/optimization, SQL diagnosis, instance parameter tuning, troubleshooting, performance analysis, query instance list, etc.
Collect necessary parameters (use default values if not specified):
  • RegionId
    : Region ID (default
    cn-hangzhou
    )
  • Language
    : Language (default
    zh-CN
    )
  • Timezone
    : Timezone (default
    Asia/Shanghai
    )
  • CustomAgentId
    : Custom Agent ID (optional)
  • --conversation-id
    : Conversation ID for multi-turn dialogue (optional)
明确用户意图:SQL编写/优化、SQL诊断、实例参数调优、故障排查、性能分析、查询实例列表等。
收集必要参数(未指定时使用默认值):
  • RegionId
    :区域ID(默认
    cn-hangzhou
  • Language
    :语言(默认
    zh-CN
  • Timezone
    :时区(默认
    Asia/Shanghai
  • CustomAgentId
    :自定义Agent ID(可选)
  • --conversation-id
    :多轮对话的会话ID(可选)

2. Construct Command and Call CLI

2. 构建命令并调用CLI

bash
undefined
bash
undefined

Basic query

基础查询

aliyun rdsai chat-messages
--query 'List RDS MySQL instances in Hangzhou region'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'List RDS MySQL instances in Hangzhou region'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'

Troubleshooting example

故障排查示例

aliyun rdsai chat-messages
--query 'RDS instance rm-bp1xxx connection timeout, error Too many connections, please help troubleshoot. Instance is in Hangzhou region.'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'RDS instance rm-bp1xxx connection timeout, error Too many connections, please help troubleshoot. Instance is in Hangzhou region.'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'

Query with Beijing region

北京区域查询

aliyun rdsai chat-messages
--query 'Optimize this SQL: SELECT * FROM users WHERE name LIKE "%test%"'
--inputs RegionId=cn-beijing Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'Optimize this SQL: SELECT * FROM users WHERE name LIKE "%test%"'
--inputs RegionId=cn-beijing Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'

Multi-turn dialogue (using ConversationId from previous response)

多轮对话(使用上一次返回的ConversationId)

aliyun rdsai chat-messages
--query 'Continue analyzing the above issue'
--conversation-id '<ConversationId from previous response>'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'Continue analyzing the above issue'
--conversation-id '<ConversationId from previous response>'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'

Using custom Agent

使用自定义Agent

aliyun rdsai chat-messages
--query 'Analyze database performance'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai CustomAgentId=your-custom-agent-id
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
undefined
aliyun rdsai chat-messages
--query 'Analyze database performance'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai CustomAgentId=your-custom-agent-id
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
undefined

3. Parse Results and Follow-up Processing

3. 解析结果与后续处理

  • Explain RDS Copilot's response to the user in natural language
  • If the response contains SQL or operational steps, assess risks and warn:
    • Avoid executing high-risk statements directly in production (e.g., large table
      DELETE
      /
      UPDATE
      / schema changes)
    • Recommend validating in test environment or adding backup/condition restrictions
  • If continuing the conversation, record the
    ConversationId
    from the response for the next query

  • 用自然语言向用户解释RDS Copilot的响应
  • 如果响应包含SQL或操作步骤,评估风险并给出警告:
    • 避免直接在生产环境执行高危语句(例如大表
      DELETE
      /
      UPDATE
      /结构变更)
    • 建议在测试环境验证或添加备份/条件限制
  • 如果需要继续对话,记录响应中的
    ConversationId
    用于下一次查询

Output Format

输出格式

Alibaba Cloud CLI returns JSON format responses (streaming multiple JSON events):
json
{"data":{"ConversationId":"8227be22-xxxx-xxxx-xxxx-xxxxxxxxxxxx","Event":"workflow_started","MessageId":"a79c881c-xxxx-xxxx-xxxx-xxxxxxxxxxxx",...}}
{"data":{"Answer":"<partial answer content>","Event":"message",...}}
{"data":{"Event":"workflow_finished",...}}
Key fields:
  • ConversationId
    : Conversation ID (for multi-turn dialogue)
  • Answer
    : AI assistant's response content
  • Event
    : Event type (workflow_started, message, workflow_finished)

阿里云CLI返回JSON格式响应(流式返回多个JSON事件):
json
{"data":{"ConversationId":"8227be22-xxxx-xxxx-xxxx-xxxxxxxxxxxx","Event":"workflow_started","MessageId":"a79c881c-xxxx-xxxx-xxxx-xxxxxxxxxxxx",...}}
{"data":{"Answer":"<partial answer content>","Event":"message",...}}
{"data":{"Event":"workflow_finished",...}}
关键字段:
  • ConversationId
    :会话ID(用于多轮对话)
  • Answer
    :AI助手的响应内容
  • Event
    :事件类型(workflow_started、message、workflow_finished)

Success Verification

成功验证

  1. CLI installation successful:
    aliyun version
    shows version number
  2. Credential configured correctly:
    aliyun configure list
    shows configured credentials
  3. API call successful: Response contains
    ConversationId
    and
    Answer
    in JSON format
  4. Response content valid: Answer is relevant to the query content
See references/verification-method.md for detailed verification steps.

  1. CLI安装成功
    aliyun version
    返回版本号
  2. 凭证配置正确
    aliyun configure list
    显示已配置的凭证
  3. API调用成功:响应中包含JSON格式的
    ConversationId
    Answer
  4. 响应内容有效:回答与查询内容相关
详细验证步骤查看references/verification-method.md

Cleanup

清理

This skill only performs read-only query operations, does not create any cloud resources, no cleanup required.

本技能仅执行只读查询操作,不会创建任何云资源,无需清理。

API and Command List

API和命令列表

See references/related-apis.md for details.
ProductAPI ActionCLI CommandDescription
RdsAiChatMessages
aliyun rdsai chat-messages
RDS AI Assistant dialogue API

详情查看references/related-apis.md
产品API ActionCLI命令说明
RdsAiChatMessages
aliyun rdsai chat-messages
RDS AI助手对话API

Best Practices

最佳实践

  1. Use multi-turn dialogue: For complex issues, use
    --conversation-id
    for context-aware multi-turn conversations
  2. Specify correct region: Set
    RegionId
    parameter based on the RDS instance's region
  3. Be cautious in production: SQL recommendations from RDS Copilot should be validated in test environment first
  4. Save conversation ID: Save the returned
    ConversationId
    if you need to follow up or continue analysis
  5. Use configuration file: Recommend using
    aliyun configure
    to configure credentials, avoid exposing sensitive information in command line
  6. Use --profile: You can configure multiple credential profiles and switch between accounts using
    --profile

  1. 使用多轮对话:针对复杂问题,使用
    --conversation-id
    实现带上下文的多轮对话
  2. 指定正确区域:根据RDS实例所在区域设置
    RegionId
    参数
  3. 生产环境谨慎操作:RDS Copilot给出的SQL建议需要先在测试环境验证
  4. 保存会话ID:如果需要跟进或继续分析,保存返回的
    ConversationId
  5. 使用配置文件:推荐使用
    aliyun configure
    配置凭证,避免在命令行暴露敏感信息
  6. 使用--profile参数:可以配置多个凭证配置,通过
    --profile
    在不同账号间切换

Reference Links

参考链接

Reference DocumentDescription
Alibaba Cloud CLI DocumentationAlibaba Cloud CLI User Guide
references/related-apis.mdAPI and Command List
references/ram-policies.mdRAM Policy Configuration
references/verification-method.mdVerification Methods
references/acceptance-criteria.mdAcceptance Criteria
参考文档说明
阿里云CLI文档阿里云CLI用户指南
references/related-apis.mdAPI和命令列表
references/ram-policies.mdRAM策略配置
references/verification-method.md验证方法
references/acceptance-criteria.md验收标准