This topic describes how to set custom prompt variables using the RTOS SDK (License mode).
1. Preparations
1.1. Prerequisites
-
This topic builds on Implement chat capabilities using RTOS SDK (License mode). Before you proceed, complete the environment setup described in that document.
-
Make sure that you have integrated the SDK and that the interactive voice response (IVR) flow runs as expected.
1.2. Configure prompts
-
Create an application in the Alibaba Cloud Model Studio console.
-
Modify the
Promptto add aCustom Variable.

2. Develop client-side features
2.1. Sample code
int main(void)
{
c_mmi_prompt_pram_t prompt[] = {
{"name", "Ayun"},
{"skill", "singing"},
};
// Initialize the SDK.
c_mmi_sdk_init();
// Configure prompt variables.
c_mmi_data_set_prompt_param(prompt, ARRAY_SIZE(prompt));
return 0;
}
2.2. Key logs
[UT][I][_gen_cmd_start]out [870][{"header":{"action":"run-task","streaming":"duplex","task_id":"Task Id"},"payload":{"task_group":"aigc","task":"multimodal-generation","function":"generation","model":"multimodal-dialog","input":{"workspace_id":"Workspace Id","app_id":"App Id","directive":"Start"},"parameters":{"upstream":{"sample_rate":16000,"type":"AudioAndVideo","mode":"tap2talk","audio_format":"pcm","enable_server_vad_start":false},"downstream":{"voice":"longanhuan","sample_rate":16000,"audio_format":"mp3","volume":50,"speech_rate":100,"pitch_rate":100,"intermediate_text":"transcript,dialog","transmit_rate_limit":16000},"client_info":{"user_id":"test_1","device":{"uuid":"test_1"}},"biz_params":{"user_prompt_params":{"name":"Ayun","skill":"singing"},"user_defined_params":{"children_story":{"speaker_1_voice":"longxiaochun_v2"}}}}}}]
The preceding log shows that the cmd_start command contains the custom prompt variables. This command is sent when a connection is established.
3. Common scenarios
-
You can use custom prompt variables to switch roles without switching the App ID. For example, you can define role properties such as name, age, gender, and hobbies.
-
Alternatively, you can treat the entire prompt as a variable and pass parameters from the device to rewrite the prompt.