mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-07-10 01:38:44 +00:00
fix(brain): correct Google Chat Add-on response format — chatDataAction
The correct Add-ons envelope uses `chatDataAction` (NOT `chatDataActionMarkup`):
{ "hostAppDataAction": { "chatDataAction": { "createMessageAction": { "message": {...} } } } }
Previous attempts:
1. Plain Message → 200 OK but "not responding" (wrong format for Add-ons)
2. chatDataActionMarkup → 200 OK but "not responding" (wrong field name)
3. chatDataAction → this should work per quickstart-http docs
Ref: https://developers.google.com/workspace/add-ons/chat/quickstart-http
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
2ac9096ed3
commit
6ca508a20f
1 changed files with 34 additions and 18 deletions
|
|
@ -6069,28 +6069,36 @@ struct GoogleChatUser {
|
|||
email: Option<String>,
|
||||
}
|
||||
|
||||
/// Google Chat response — return raw Message object.
|
||||
/// Google Chat Add-on response in the correct DataActions envelope.
|
||||
///
|
||||
/// For HTTP endpoint Chat apps, the response is a plain Message object:
|
||||
/// { "text": "...", "cardsV2": [...] }
|
||||
/// Google Workspace Add-ons (HTTP endpoint) expect:
|
||||
/// { "hostAppDataAction": { "chatDataAction": { "createMessageAction": { "message": {...} } } } }
|
||||
///
|
||||
/// The text field is required as a notification fallback.
|
||||
/// cardsV2 provides the rich card UI.
|
||||
/// Note: the key is `chatDataAction` (NOT `chatDataActionMarkup`).
|
||||
/// Ref: https://developers.google.com/workspace/add-ons/chat/quickstart-http
|
||||
fn chat_card(title: &str, subtitle: &str, sections: Vec<serde_json::Value>) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"text": format!("{} — {}", title, subtitle),
|
||||
"cardsV2": [{
|
||||
"cardId": "brain-response",
|
||||
"card": {
|
||||
"header": {
|
||||
"title": title,
|
||||
"subtitle": subtitle,
|
||||
"imageUrl": "https://pi.ruv.io/og-image.svg",
|
||||
"imageType": "CIRCLE"
|
||||
},
|
||||
"sections": sections
|
||||
"hostAppDataAction": {
|
||||
"chatDataAction": {
|
||||
"createMessageAction": {
|
||||
"message": {
|
||||
"text": format!("{} — {}", title, subtitle),
|
||||
"cardsV2": [{
|
||||
"cardId": "brain-response",
|
||||
"card": {
|
||||
"header": {
|
||||
"title": title,
|
||||
"subtitle": subtitle,
|
||||
"imageUrl": "https://pi.ruv.io/og-image.svg",
|
||||
"imageType": "CIRCLE"
|
||||
},
|
||||
"sections": sections
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -6129,7 +6137,15 @@ async fn google_chat_handler(
|
|||
let raw = String::from_utf8_lossy(&body);
|
||||
tracing::warn!("Failed to parse Chat event: {}. Raw: {}", err, &raw[..raw.len().min(500)]);
|
||||
return Json(serde_json::json!({
|
||||
"text": "Pi Brain received your message but couldn't parse it. Try: help"
|
||||
"hostAppDataAction": {
|
||||
"chatDataAction": {
|
||||
"createMessageAction": {
|
||||
"message": {
|
||||
"text": "Pi Brain received your message but couldn't parse it. Try: help"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue