How to Integrate Radio App with Gleo AI
1. Example of App Schema
- An example of the App Schema for the radio app is as follows:
{
"packageName": "ai.umos.mediaapp",
"appDescription": "An app for streaming live radio stations.",
"actionCalls": [
{
"type": "function",
"function": {
"name": "SWITCH_BAND",
"description": "Changes between FM and AM radio bands.",
"parameters": {
"type": "object",
"properties": {
"band": {
"type": "string",
"enum": [
"FM",
"AM"
],
"description": "The radio band to switch to."
}
},
"required": [
"band"
]
},
"component": "service"
}
},
{
"type": "function",
"function": {
"name": "SEARCH_STATION",
"description": "Searches radio stations based on a keyword or frequency.",
"parameters": {
"type": "object",
"properties": {
"searchTerm": {
"type": "string",
"description": "The keyword to search for in station names or frequencies."
}
},
"required": [
"searchTerm"
]
},
"component": "activity"
}
},
{
"type": "function",
"function": {
"name": "PLAY_FREQUENCY",
"description": "Plays the specified radio frequency.",
"parameters": {
"type": "object",
"properties": {
"frequency": {
"type": "number",
"description": "The radio frequency to play. For FM band it can be both in MHz and kHz. AM frequency should be given in kHz."
}
},
"required": [
"frequency"
]
},
"component": "service"
}
}
]
}
Receiving Side (Radio App)
private fun handleIntent(intent: Intent?) {
if (intent == null) return
val action = intent.action
val rawJson = intent.getStringExtra("actionParameters") ?: "{}"
try {
val json = JSONObject(rawJson) // Convert JSON string to JSONObject
when (action) {
"SEARCH_STATION" -> {
val searchTerm = json.optString("searchTerm", "Unknown")
Log.d("RadioReceiver", "Searching radio station with search term: $searchTerm")
// TODO: Implement logic to play the radio based on searchTerm
}
"SWITCH_BAND" -> {
val band = json.optString("band", "Unknown")
Log.d("RadioReceiver", "Switching band to: $band")
// TODO: Implement logic to switch band
}
"PLAY_FREQUENCY" -> {
// TODO: Implement for PLAY_FREQUENCY
}
else -> {
Log.w("RadioReceiver", "Unknown action received: $action")
}
}
} catch (e: Exception) {
e.printStackTrace()
Log.e("RadioReceiver", "Failed to parse actionParameters")
}
}
...
private fun sendCallback(functionName: String, status: String, message: String) {
val response = JSONObject()
try {
response.put("functionName", functionName)
response.put("status", status)
response.put("message", message)
response.put("data", data) // optional
} catch (e: JSONException) {
e.printStackTrace()
}
// Send response back to Gleo AI (e.g., via an API or broadcast)
}
- The radio app creates an app intent for each of the functions mentioned above and executes the corresponding processing logic within the app.
- The radio app receives intents such as SEARCH_STATION(searchTerm="SBS Power FM") from Gleo AI. Then, using the LLM/Search SDK or SQLite database, the app searches for the appropriate channel based on the given search term and plays the corresponding frequency.
2. Example of Callback
- Examples of the Callback Schema for the radio app are as follows:
SEARCH_STATION - Success
{
"functionName": "SEARCH_STATION",
"status": "success",
"message": "The radio has started playing successfully.",
"data": "[\n {\n \"frequency\": \"91.9MHz\",\n \"frequencyBand\": \"FM\",\n \"stationName\": \"MBC\",\n \"channelName\": \"MBC FM4U\"\n }\n]"
}
SEARCH_STATION - Fail
{
"functionName": "SEARCH_STATION",
"status": "fail",
"message": "Failed to play the requested radio. Please check the station name or frequency."
}
SEARCH_STATION - Asking (multiple matches)
{
"functionName": "SEARCH_STATION",
"status": "asking",
"message": "Multiple stations match your request. Please specify the frequency or channel name.",
"data": "[\n {\n \"frequency\": \"91.9MHz\",\n \"frequencyBand\": \"FM\",\n \"stationName\": \"MBC\",\n \"channelName\": \"MBC FM4U\"\n },\n {\n \"frequency\": \"95.9MHz\",\n \"frequencyBand\": \"FM\",\n \"stationName\": \"MBC\",\n \"channelName\": \"MBC Standard FM\"\n }\n]"
}