i am trying to get events of google meet for one of my project. as per discussed in documentation while subscribing the channel you should receive status code 200. which means you have successfully subscribed the channel and now you can get specified events.
{
"kind": "api#channel",
"id": "2_3_1649922664979",
"resourceId": "2o-e8ddqUdzRvmQ96lTxgh3SWkM",
"resourceUri": "https://admin.googleapis.com/admin/reports/v1/activity/users/daud.rauf%40venturenox.com/applications/meet?alt=json&eventName=call_ended&orgUnitID",
"token": "{\"user_id\":3,\"tenant_id\":2}",
"expiration": "1649944266000"}
i got 200 with response above but didn't receiving any further events. Detailed code is...
const data = await google
.admin({
version: 'reports_v1',
auth: google_client,
})
.activities.watch({
userKey: 'all',
applicationName: 'meet',
eventName: 'call_ended',
// maxResults: 10,
requestBody: {
id: watchId, // it is unique
token: JSON.stringify(params),
type: 'web_hook',
address: process.env.GOOGLE_REPORTS_WATCH_URL,
kind: 'api#channel',
},
});
Related
I have the following code
let calendar = google.calendar({
version: "v3",
auth: oauth2Client,
});
let resource = {
summary: process.env.SITE_NAME + " 1-1 Session",
location: options.comments,
description: "";
start: {
dateTime: new Date(options.startDate),
timeZone: "utc",
},
end: {
dateTime: new Date(options.endDate),
timeZone: "utc",
},
attendees: [
{
email: options.user.email,
},
{
email: options.mentor.email,
},
],
reminders: {
useDefault: false,
overrides: [
{
method: "email",
minutes: 15,
},
{
method: "email",
minutes: 60,
},
{
method: "popup",
minutes: 10,
},
]
},
colorId: 4,
sendUpdates: "all",
status: "confirmed",
};
I want to send a google notification to attendees when they book an appointment. How can I do so using the code above?
I believe your goal is as follows.
When an event is created, you want to send a notification email.
You want to achieve this using googleapis for Node.js.
In this case, how about the following sample script?
In this case, I think that resource is not required to be modified. Please modify the script for requesting Calendar API as follows.
Sample script:
calendar.events.insert({
calendarId,
resource,
sendNotifications: true, // <--- Please add this.
})
.then(({ data }) => console.log(data))
.catch(({ errors }) => console.log(errors));
Reference:
Events: insert
This might sound like an odd request but we're running in to a bit of trouble getting Rocket.Chat to send a message in its entirety via a webhook to Slack.
Just a little background on the logic behind this and without going in to too much detail:
We have a script that collects the status of servers that are running in an air gapped manner (no access to the internet)
The idea is to have the big important messages in the text including server status and important issues with the smaller/more numerous issues grouped in the fields since it is more flexible with formatting
The script creates a message with the status and sends it to one of our Rocket.Chat instances via a webhook to a channel for notifications
Rocket.chat then sends the messages that arrive in that notification channel to Slack via an outgoing webhook
Script generates this json which is sent to Rocket.Chat:
{
"username": "Morning Message Update",
"attachments": [
{
"fields": [
{
"value": "Server 1, server 2",
"title": "These hosts are down"
}
],
"text": "**1** critical messages.",
"fallback": "There are 1 critical messages. You may need to have embeds turned on to view them",
"mrkdwn_in": [
"text"
],
"color": "#d03ae8",
"title": "In house applications"
}
],
"icon_emoji": ":sunrise:",
"text": "Hello!"
}
Screenshot of what appears in Rocket.Chat:
Screenshot of what appears in Slack, first from Rocket.Chat then me manually sending the above json file (as a sanity check):
Looking through the logs I can see that the message is received alright (albeit with the fields section truncated):
I20220304-15:33:55.416(0) server.js:204 Integrations ➔ Incoming WebHook.debug #bodyParams: { username: 'Morning Message Update', attachments: [ { fields: [Array], text: '**1** critical messages.', fallback: 'There are 1 critical messages. You may need to have embeds turned on to view them', mrkdwn_in: [Array], color: '#d03ae8', title: 'In house applications' } ], icon_emoji: ':sunrise:', text: 'Hello!' }
Then when the outgoing webhook process is started (some identifying information removed):
I20220304-15:33:55.438(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Got the event arguments for the event: sendMessage { event: 'sendMessage', message: { alias: 'Morning Message Update', msg: 'Hello!', attachments: [ [Object] ], parseUrls: false, bot: { i: '!removed!' }, groupable: false, tmid: undefined, emoji: ':sunrise:', ts: 2022-03-04T15:33:55.421Z, u: { _id: 'rocket.cat', username: 'rocket.cat', name: 'Rocket.Cat' }, rid: '!removed!', mentions: [], channels: [], md: [ [Object] ], _updatedAt: 2022-03-04T15:33:55.430Z, _id: '!removed!' }, room: { _id: '!removed!', fname: '!removed!', customFields: {}, description: '', broadcast: false, encrypted: false, name: '!removed!', t: 'p', msgs: -192, usersCount: 4, u: { _id: '!removed!', username: '!removed!' }, ts: 2022-03-04T11:02:14.417Z, ro: false, _updatedAt: 2022-03-04T15:04:09.451Z, lm: 2022-03-04T15:04:09.437Z, lastMessage: { alias: 'Morning Message Update', msg: 'Hello!', attachments: [Array], parseUrls: false, bot: [Object], groupable: false, emoji: ':sunrise:', ts: 2022-03-04T15:04:09.437Z, u: [Object], rid: '!removed!', mentions: [], channels: [], md: [Array], _updatedAt: 2022-03-04T15:04:09.447Z, _id: '!removed!' } } }
The only thing I can see that's different is has been changed to truncated down to simply attachments: [Array] but I'm assuming it's still containing the full message text for now. But then it seems to strip the message of all its attachments except text:
I20220304-15:33:55.439(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Starting search for triggers for the room: !removed!
I20220304-15:33:55.439(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Found 1 to iterate over and see if the match the event.
I20220304-15:33:55.440(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Is "!removed!" enabled, true, and what is the event? sendMessage
I20220304-15:33:55.440(0) server.js:204 Integrations ➔ Outgoing WebHook.debug Starting to execute trigger: !removed! (!removed!)
I20220304-15:33:55.443(0) server.js:204 Callbacks ➔ debug Executing callback with id emojione-shortnameToUnicode for hook beforeSendMessageNotifications
I20220304-15:33:55.448(0) server.js:204 Integrations ➔ Outgoing WebHook.info Will be executing the Integration "!removed!" to the url: https://hooks.slack.com/services/!removed!
I20220304-15:33:55.449(0) server.js:204 Integrations ➔ Outgoing WebHook.debug { token: '!removed!', bot: { i: '!removed!' }, channel_id: '!removed!', channel_name: '!removed!', message_id: '!removed!', timestamp: 2022-03-04T15:33:55.421Z, user_id: 'rocket.cat', user_name: 'rocket.cat', text: 'Hello!', siteUrl: '!removed!', alias: 'Morning Message Update' }
I20220304-15:33:55.452(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.454(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.455(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.455(0) server.js:204 Callbacks ➔ debug Executing callback with id filter-markdown for hook renderNotification
I20220304-15:33:55.599(0) server.js:204 Integrations ➔ Outgoing WebHook.info Status code for the Integration platform-testing-2 to https://hooks.slack.com/services/!removed! is 200
So my understanding is that Rocket.Chat is sending just the body of the message rather than the body and the attachment. My question is what is the best way to prevent this from happening and to allow the full message with attachments through the Rocket.Chat webhook to Slack
Thank you and all the best!
Server Setup Information
Version of Rocket.Chat Server: 3.18.2
Operating System: Redhat Linux
Deployment Method: docker
Number of Running Instances:
DB Replicaset Oplog:
NodeJS Version: v12.22.1
MongoDB Version: 4.0.2
Proxy:
Firewalls involved: Yes
This is the error I get
name: 'VALIDATION_ERROR',
details: [
{
field: 'purchase_units[0]',
issue: 'Item amount must add up to specified amount subtotal (or total if amount details not specified)'
}
],
message: 'Invalid request - see details',
information_link: 'https://developer.paypal.com/docs/api/payments/#errors',
debug_id: '74ac8660674d8',
httpStatusCode: 400
This is my /pay post route
app.post('/pay' , (req , res) => {
let cart = new Cart(req.session.cart)
const create_payment_json = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://localhost:3000/success",
"cancel_url": "http://localhost:3000/failed"
},
"transactions": [{
"item_list": {
"items": getItems(cart.items)
},
"amount": {
"currency": "USD",
"total": cart.totalPrice
},
"description": "This is the payment description."
}]
};
This is the getItems function
function getItems(cart) {
let itemsArray = [];
for (const [idx, item] of Object.entries(cart)) {
itemsArray.push({
"name": item.item.product_name,
"price": item.price,
"currency": "USD",
"quantity": item.qty
});
}
return itemsArray;
}
When I console.log the cart.totalPrice it is correct as it should be (Which is the total of all the items in the cart) Any idea what is going wrong here. I am a bit new to all this stuff so a bit confused
For the current (non-deprecated) APIs, see examples in Set up standard payments
Make 2 routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. Both routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.
Pair those 2 routes with the current JS SDK frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
I am using the bot framework rest API and channelData to send the game to telegram. But the framework returns 200 and still it doesn't show any message on the telegram side, I don't know what I am doing wrong here, Pasting the code below for setting up the channelData:
const channel_data = { method: 'sendGame', parameters: { game_short_name: 'gamename' } };
let payload = {
type: type,
from: {
id: telegramResponse.recipient.id,
name: telegramResponse.recipient.name
},
recipient: {
id: telegramResponse.from.id,
name: telegramResponse.from.name
},
conversation: {
id: telegramResponse.conversation.id
},
text: text, channelData: channel_data
};
return payload;
}
}
I tried to run a script which creates a specific intent by using the Dialogflow API. The API is enabled already a couple of weeks.
After I called my script i received the following error:
Error: Dialogflow API has not been used in project usable-auth-library before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=usable-auth-library then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
at /Users/$USER"/Desktop/node_modules/grpc/src/client.js:554:15
code: 7,
metadata:
Metadata {
_internal_repr:
{ 'google.rpc.help-bin': [Array],
'grpc-status-details-bin': [Array],
'grpc-server-stats-bin': [Array] } } }
Here is my script.
// Imports the Dialogflow library
const dialogflow = require('dialogflow');
// Instantiates clients
const contextsClient = new dialogflow.ContextsClient();
const intentsClient = new dialogflow.IntentsClient();
projectId="1000-1505-ecom-conx-dev"
projectId="conrad-test"
// The path to identify the agent that owns the created intent.
const agentPath = intentsClient.projectAgentPath(projectId);
// Setup intents for ordering a pizza.
// First of all, let's create an intent that triggers pizza order flow.
// Output contexts for ordering pizza. They are used for matching follow-up
// intents. For pizza ordering intents, a "pizza" output context is used for
// hinting the conversation is about pizza ordering, not beer or something
// else. For the first intent, it returns responses asking users to provide
// size information, with a "size" output context for matching the intent
// asking for the size of the pizza.
// Note that session ID is unknown here, using asterisk.
const accountOutputContexts = [
{
name: contextsClient.contextPath(
projectId,
'*' /* sessionId */,
'EComerceAgent'
),
lifespanCount: 5,
},
];
// The result of the matched intent.
const accountResult = {
action: '',
parameters: [
{
displayName: 'Account for',
value: '$application',
entityTypeDisplayName: '#application',
mandatory: true,
prompts: [
'You need appliation access, please describe for which and which permissions do you need?',
'Would you like access to jirra?',
'Would you like access to confluence?',
'Would you like access to AEM?',
],
},
{
displayName: 'user',
value: '$user',
entityTypeDisplayName: '#user',
mandatory: true,
prompts: ['For wich user'],
isList: true,
},
{
displayName: 'permission',
value: '$permission',
// The API provides a built-in entity type #sys.address for addresses.
entityTypeDisplayName: 'permission',
mandatory: true,
prompts: ['Which permission do you need?'],
},
],
messages: [
{
text: {
text: [
'No problem. We will create an account on $application for $user with the following permission: $permission'
],
},
},
{
text: {
text: [
'Reply "check" to place your order. Reply "cancel" to cancel ' +
'your order. You can change your delivery address as well.',
],
},
},
{
quickReplies: {
title:
'No problem. We will create an account on $application for $user with the following permissions: $permission',
quickReplies: ['Create account', 'Cancel']
},
platform: 'PLATFORM_UNSPECIFIED',
},
],
outputContexts: accountOutputContexts,
};
// The phrases for training the linguistic model.
const accountPhrases = [
{type: 'TYPE_EXAMPLE', parts: [{text: 'Get account'}]},
{type: 'TYPE_EXAMPLE', parts: [{text: 'acction'}]},
{
type: 'TYPE_EXAMPLE',
parts: [
{text: 'Create an account '},
{text: 'for', entityType: '#application', alias: 'application'},
{text: ' '},
{text: 'for ', entityType: '#user', alias: 'user'},
{text: 'with the followin permissions ', entityType: '#permission', alias: 'permission'},
],
},
{
type: 'TYPE_EXAMPLE',
parts: [
{text: "I'd like to have access "},
{text: 'to', entityType: '#application', alias: 'application'},
],
}
];
// The intent to be created.
const accountIntent = {
displayName: 'Account',
events: ['create_account'],
// Webhook is disabled because we are not ready to call the webhook yet.
webhookState: 'WEBHOOK_STATE_DISABLED',
trainingPhrases: accountPhrases,
mlEnabled: true,
priority: 500000,
result: accountResult,
};
const accountRequest = {
parent: agentPath,
intent: accountIntent,
};
// Create the pizza intent
intentsClient
.createIntent(accountRequest)
.then(responses => {
console.log('Created account intent:');
logIntent(responses[0]);
})
.catch(err => {
console.error('ERROR:', err);
});
The error is not clear at all, it means that your are not authorized to access the remote ressource without credentials. Here is the quick solution that worked for me :
Go to https://console.cloud.google.com/apis/credentials/serviceaccountkey
Download json auth file (eg. foobar-123.json)
Add environement variable :
export GOOGLE_APPLICATION_CREDENTIALS="/home/me/secure/foobar-123.json"
And the full tutorial & documentation here : https://cloud.google.com/docs/authentication/getting-started
I reported this issue : https://github.com/dialogflow/dialogflow-nodejs-client-v2/issues/28