Send a voice notification to a specified mobile phone number based on the Volcengine voice service API.
Applicable Scenarios
- The user mentions "send a voice notification to {mobile phone number}" or "help me make a voice call to {mobile phone number}"
- The user mentions "send a voice notification to {mobile phone number} in {language}"
- The user mentions "send a {keyword} voice notification to {mobile phone number}"
- The user needs to notify important information by voice
Core Execution Flow
When you receive a request to send a voice notification, strictly follow these 4 steps in order:
Step 1: Extract the mobile phone number
Extract the 11-digit mobile phone number from the user's instruction. If the user has not provided a mobile phone number, ask the user first.
Step 2: Query the available number pools
Run the following command to query the number pools:
python3 scripts/voice_notify.py pool
From the returned JSON result:
- View the
Result.Recordsarray - Select a number pool with
NumberCount > 0(numbers available) - Extract the
NumberPoolNofield value of that number pool (for example:NP165357678402826428)
Note: Prioritize selecting the first number pool that has numbers.
Step 3: Query voice resources
Run the following command to query voice resources:
python3 scripts/voice_notify.py resource
From the returned JSON result:
- View the
Result.Recordsarray - Based on the keyword in the user's instruction, match in the resource's
Name、Remark、TtsTemplateContent、Langfield - Select the most matching voice resource
- Extract the
ResourceKeyfield value of that resource
Resource selection rules:
- If there is no matching keyword, select the first resource in the list
Step 4: Send the voice notification
Run the following command to send the voice notification:
python3 scripts/voice_notify.py send <手机号> <资源Key> <号码池编号>
Fill in the command with the mobile phone number extracted in Step 1, the resource Key extracted in Step 3, and the number pool ID extracted in Step 2.
Step 5: Return the result
Tell the user directly the return result of the send command.
Script Command Description
| Command | Parameter | Description |
|---|---|---|
resource |
None | Query the list of available voice resources |
pool |
None | Query the list of voice notification number pools |
send |
<手机号> <资源Key> <号码池编号> |
Send a voice notification |
Complete Usage Example
Example 1: Simple send
User input: Send a voice notification to 13800138000
Your execution:
-
Extract the mobile phone number:
13800138000 -
Query the number pools:
python3 scripts/voice_notify.py pool
Assume that in the returned result, the NumberPoolNo of the first number pool that has numbers is NPabc
- Query voice resources:
python3 scripts/voice_notify.py resource
Assume that in the returned result, the ResourceKey of the first resource is 312346368e676406285b8463931f090f4
- Send the voice notification:
python3 scripts/voice_notify.py send 13800138000 312346368e676406285b8463931f090f4 NPabc
- Tell the user the sending result
Example 2: Specify the language
User input: Send a voice notification to 13800138000 in Japanese
Your execution:
-
Extract phone number:
13800138000 -
Query number pools:
python3 scripts/voice_notify.py pool
Select the first number pool that has a number
- Query voice resources:
python3 scripts/voice_notify.py resource
In the returned resource list, find resources whose Lang is jap or Name/Remark contains "Japanese", and extract their ResourceKey
- Send voice notification:
python3 scripts/voice_notify.py send 13800138000 <日语资源Key> <号码池编号>
- Inform the user of the sending result
Example 3: Specify a keyword
User input: Send an OCIC voice notification to 13800138000 Your execution:
-
Extract phone number:
13800138000 -
Query number pools:
python3 scripts/voice_notify.py pool
Select the first number pool that has a number
- Query voice resources:
python3 scripts/voice_notify.py resource
In the returned resource list, find resources whose Name or Remark contains "OCIC", and extract their ResourceKey
- Send voice notification:
python3 scripts/voice_notify.py send 13800138000 <OCIC资源Key> <号码池编号>
- Inform the user of the sending result
Environment variables
Before use, configure the Volcengine access key in the system environment variables or OpenClaw's .env file:
- VOLCENGINE_ACCESS_KEY: Volcengine access key ID
- VOLCENGINE_SECRET_KEY: Volcengine secret access key
How to obtain: Log in to the Volcengine console and create and obtain it in Access Key Management.
Error handling
- If error
请设置环境变量 VOLCENGINE_ACCESS_KEY 和 VOLCENGINE_SECRET_KEY: Prompt the user to configure the Volcengine access key. - If error
没有找到可用的号码池: Prompt the user to check whether there is an available voice notification number pool under the account. - If error
没有找到可用的语音资源: Prompt the user to check whether there is an available voice resource file under the account. - When encountering other errors, directly inform the user of the specific error information.
Reference documentation
https://www.volcengine.com/docs/6358/166389?lang=zh— Signature mechanismhttps://www.volcengine.com/docs/6358/1722078?lang=zh— Query available voice resourceshttps://www.volcengine.com/docs/6358/172952?lang=zh— Send a single voice notificationhttps://www.volcengine.com/docs/6358/173339?lang=zh— Query the number pool list