Я пытаюсь создать приложение Google Chat, которое называет функцию Cloud Run в качестве логики. Я предполагаю, что интерфейсы GCP, должно быть, недавно изменились /обновлялись, потому что многие руководства и устранение неполадок не соответствуют элементам пользовательского интерфейса, которые я вижу в GCP. DataCations или Card.
не удалось проанализировать JSON в качестве рендеринга. Не удастся с ошибкой: не удается найти поле: cardsv2 в сообщении Google.apps.card.v1.renderactions
не удалось проанализировать JSON в качестве данных. Не удастся с ошибкой: не удается найти поле: cardsv2 в сообщении Google.apps.card.v1.datactions
Не удалось проанализировать JSON как карту. Не удастся с ошибкой: невозможно найти поле: cardsv2 в сообщении Google.apps.card.v1.card < /p>
< /blockquote>
и < /p>
Не удается опубликовать ответ. Приложение чата не ответило, или его ответ был недействительным. Если ваше приложение в чате настроено как дополнение, см. «Создайте интерфейсы Google Chat» (https://developers.google.com/workspace ... chat/build) в документации Google Workspace. В противном случае см. «Получить и ответьте на события чата Google» (https://developers.google.com/chat/api/ ... ge-formats) в документации API чата./**
* Google Chat Bot Echo function.
*
* This function is triggered by an HTTP request from Google Chat.
* It processes the event payload and responds with a structured card message.
*
* @param {object} req The HTTP request object.
* @param {object} res The HTTP response object.
*/
exports.chatBot = (req, res) => {
// Check if the request method is POST. Google Chat sends POST requests.
if (req.method !== 'POST') {
return res.status(403).send('Forbidden');
}
const event = req.body;
console.log('Received event:', JSON.stringify(event, null, 2));
let responseMessage;
// Handle different event types from Google Chat.
switch (event.type) {
case 'ADDED_TO_SPACE':
// This event is triggered when the bot is added to a space or a DM.
const spaceType = event.space.type;
if (spaceType === 'DM') {
responseMessage = `Hi ${event.user.displayName}! Thanks for starting a chat. I'll echo back anything you say.`;
} else {
responseMessage = `Thanks for adding me to ${event.space.displayName}! I'm ready to echo messages.`;
}
break;
case 'MESSAGE':
// This event is triggered when a user sends a message to the bot.
// event.message.argumentText contains the text sent after the bot's @-mention.
const userMessage = (event.message.argumentText || '').trim();
if (userMessage) {
responseMessage = `You said: "${userMessage}"`;
} else {
responseMessage = 'Hello! Please mention me and type a message.';
}
break;
case 'REMOVED_FROM_SPACE':
// This event is triggered when the bot is removed. No response is needed.
console.log(`Bot removed from ${event.space.displayName}.`);
return res.status(200).send();
default:
// For any other event type, send a default response.
responseMessage = 'I received an event I don\'t know how to handle.';
break;
}
// For a Google Workspace Add-on responding to a MESSAGE event,
// the response must be a `renderActions` object.
const reply = {
"renderActions": {
"action": {
"navigations": [
{
"pushCard": {
"header": {
"title": "Echo Bot"
},
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": responseMessage
}
}
]
}
]
}
}
]
}
}
};
// Send the JSON response back to Google Chat.
res.status(200).json(reply);
};
< /code>
Я вполне новичок в GCP Google Chat API и функциях Cloud Run, поэтому мои извинения, если этот вопрос кажется немного очевидным. Но я застрял некоторое время и нигде не могу найти резолюцию. Любая помощь была бы очень ценить!
Подробнее здесь: https://stackoverflow.com/questions/797 ... dsv2-error
Приложение Google Chat с функцией Cloud Run - renderactions и ошибки картВ2 ⇐ Javascript
Форум по Javascript
1759187262
Anonymous
Я пытаюсь создать приложение Google Chat, которое называет функцию Cloud Run в качестве логики. Я предполагаю, что интерфейсы GCP, должно быть, недавно изменились /обновлялись, потому что многие руководства и устранение неполадок не соответствуют элементам пользовательского интерфейса, которые я вижу в GCP. DataCations или Card.
не удалось проанализировать JSON в качестве рендеринга. Не удастся с ошибкой: не удается найти поле: cardsv2 в сообщении Google.apps.card.v1.renderactions
не удалось проанализировать JSON в качестве данных. Не удастся с ошибкой: не удается найти поле: cardsv2 в сообщении Google.apps.card.v1.datactions
Не удалось проанализировать JSON как карту. Не удастся с ошибкой: невозможно найти поле: cardsv2 в сообщении Google.apps.card.v1.card < /p>
< /blockquote>
и < /p>
Не удается опубликовать ответ. Приложение чата не ответило, или его ответ был недействительным. Если ваше приложение в чате настроено как дополнение, см. «Создайте интерфейсы Google Chat» (https://developers.google.com/workspace/add-ons/chat/build) в документации Google Workspace. В противном случае см. «Получить и ответьте на события чата Google» (https://developers.google.com/chat/api/guides/message-formats) в документации API чата./**
* Google Chat Bot Echo function.
*
* This function is triggered by an HTTP request from Google Chat.
* It processes the event payload and responds with a structured card message.
*
* @param {object} req The HTTP request object.
* @param {object} res The HTTP response object.
*/
exports.chatBot = (req, res) => {
// Check if the request method is POST. Google Chat sends POST requests.
if (req.method !== 'POST') {
return res.status(403).send('Forbidden');
}
const event = req.body;
console.log('Received event:', JSON.stringify(event, null, 2));
let responseMessage;
// Handle different event types from Google Chat.
switch (event.type) {
case 'ADDED_TO_SPACE':
// This event is triggered when the bot is added to a space or a DM.
const spaceType = event.space.type;
if (spaceType === 'DM') {
responseMessage = `Hi ${event.user.displayName}! Thanks for starting a chat. I'll echo back anything you say.`;
} else {
responseMessage = `Thanks for adding me to ${event.space.displayName}! I'm ready to echo messages.`;
}
break;
case 'MESSAGE':
// This event is triggered when a user sends a message to the bot.
// event.message.argumentText contains the text sent after the bot's @-mention.
const userMessage = (event.message.argumentText || '').trim();
if (userMessage) {
responseMessage = `You said: "${userMessage}"`;
} else {
responseMessage = 'Hello! Please mention me and type a message.';
}
break;
case 'REMOVED_FROM_SPACE':
// This event is triggered when the bot is removed. No response is needed.
console.log(`Bot removed from ${event.space.displayName}.`);
return res.status(200).send();
default:
// For any other event type, send a default response.
responseMessage = 'I received an event I don\'t know how to handle.';
break;
}
// For a Google Workspace Add-on responding to a MESSAGE event,
// the response must be a `renderActions` object.
const reply = {
"renderActions": {
"action": {
"navigations": [
{
"pushCard": {
"header": {
"title": "Echo Bot"
},
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": responseMessage
}
}
]
}
]
}
}
]
}
}
};
// Send the JSON response back to Google Chat.
res.status(200).json(reply);
};
< /code>
Я вполне новичок в GCP Google Chat API и функциях Cloud Run, поэтому мои извинения, если этот вопрос кажется немного очевидным. Но я застрял некоторое время и нигде не могу найти резолюцию. Любая помощь была бы очень ценить!
Подробнее здесь: [url]https://stackoverflow.com/questions/79778526/google-chat-app-with-a-cloud-run-function-renderactions-and-cardsv2-error[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия