Unfortunately, Google Chat cards cannot dynamically append text input values to button URLs without server-side processing. The button URL is static when the card is rendered.
Since you're using Splunk alerts (which only send static JSON), here are your options:
Option 1: Pre-fill the URL in Splunk (Recommended)
Instead of having a text input in the card, include the comment/parameters directly in the URL when creating the alert:
| eval comment="investigation_needed"
| eval encoded_comment=replace(comment, " ", "%20")
| eval payload="{\"sections\":[{\"widgets\":[{\"textParagraph\":{\"text\":\"An alert has been triggered. Click below to investigate.\"}},{\"buttonList\":{\"buttons\":[{\"text\":\"Fill w/ IMG icon\",\"type\":\"FILLED\",\"onClick\":{\"openLink\":{\"url\":\"https://your-splunk-instance/app/search/search?q=your-search-query&comment=" . encoded_comment . "\"}}}]}}]}]}"
Option 2: Use a Static Form Link
Create a button that opens a form where users can enter their comment:
{
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": "An alert has been triggered. Click below to investigate."
}
},
{
"buttonList": {
"buttons": [
{
"text": "Fill w/ IMG icon",
"type": "FILLED",
"onClick": {
"openLink": {
"url": "https://your-form-site.com/investigate?base_url=https://your-splunk-instance/app/search/search?q=your-search-query"
}
}
}
]
}
},
{
"textParagraph": {
"text": "<i>Note: You'll be able to add comments on the next page.</i>"
}
}
]
}
]
}
Option 3: Two-Step Process
Provide instructions for users to copy the comment:
{
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": "An alert has been triggered. Copy your comment below before clicking the button."
}
},
{
"textInput": {
"name": "comment",
"label": "Komentarz (copy this text)",
"value": "Your comment here"
}
},
{
"buttonList": {
"buttons": [
{
"text": "Open Splunk (paste comment there)",
"type": "FILLED",
"onClick": {
"openLink": {
"url": "https://your-splunk-instance/app/search/search?q=your-search-query"
}
}
}
]
}
}
]
}
]
}
Why This Limitation Exists:
- Google Chat cards are rendered once and sent to the chat
- They don't have client-side JavaScript to modify URLs dynamically
onChangeAction requires a backend server to process the input and return an updated card
- Splunk alerts can only send static JSON payloads
If You Had a Backend Server:
With a server handling card interactions, you could:
- Capture the text input value when the button is clicked
- Construct the URL with the comment
- Redirect the user or return an updated card
But since you're using Splunk alerts directly, you're limited to static content.
Bottom line: Without a backend server, you cannot dynamically append text input values to button URLs in Google Chat cards. The best approach is to include any necessary parameters in the URL when generating the alert in Splunk.