Troubles forwarding message attachments from Rocket.Chat to Slack - webhooks

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

Related

Google Reports Push notification not working

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',
},
});

DocuSign creates the envelope via API but no e-mail are sent

And thanks in advance for any help !
When I create en envelope with the status "sent", the signers does not get e-mail any more.
Friday morning, everything was working I was receiving e-mail.
But since friday noon, i can not receive a single e-mail (for recipients).
When I use: envelopeApi.createEnvelope(this.config.accountId, { envelopeDefinition })
My code receive:
{
"envelopeId": "xxx",
"status": "sent",
"statusDateTime": "2021-07-26T09:29:11.1800000Z",
"uri": "/envelopes/xxx"
}
And When I check in the envelope administration panel, I see
If I try to create the envelope from the administration panel, emails are sent but not from API calls...
Is it my account which limited or did I missed something?
Complete code example:
async testSendEnvelope2() {
const signers: TemplateRole[] = [
{
email: 'sirko.alexandre#gmail.com',
name: 'alexander',
clientUserId: 'toto',
tabs: {
textTabs: [
{
tabLabel: 'toto',
locked: 'true',
required: 'true',
value: 'blabla',
},
],
},
roleName: 'Freeluper',
},
{
email: 'alexandre#jump-biz.com',
name: 'jalexandre',
clientUserId: 'titi',
tabs: {
textTabs: [
{
tabLabel: 'titi',
locked: 'true',
required: 'true',
value: 'blibli',
},
],
},
roleName: 'Company',
},
];
const env: EnvelopeDefinition = {
emailSubject: 'le sujet du mail',
status: 'sent',
templateId: 'xxx',
templateRoles: signers,
};
const results = await this.docusignService.sendEnvelope(env);
console.log(results);
}
And this.docusignService.sendEnvelope simply calls the envelopeApi.createEnvelope (with credentials)
Re: Why aren't my recipients receiving email invitations to the signing ceremony?
The reason is that you are setting the clientUserId attribute for the recipient objects.
When you do that, the recipients become captive (embedded) recipients. In this case, email is not sent since the assumption is that you want your application to offer the signing ceremony to them.
If you want to record recipient metadata without causing the recipients to become embedded signers, use the customFields attribute
Re: Limitations for developer accounts?
The main limitations for the developer (demo) accounts are:
the envelopes cannot be used for legally binding agreements
the envelopes are cleared out periodically.
Re slow email
On rare occasions the developer system gets a bit backed up and email delivery is slow.
A way to check is to use the DocuSign web app to send a test envelope from your developer account. If it works then you should suspect your API app.

Custom payload for platforms like Telegram, Facebook, Slack for DialogFlow in Nodejs

I would like to ask how to custom payload for carousel, image in other platforms like Facebook, Telegram and etc.
Information
DialogFlow API version: V2 API
Node version: v8.10.0
body-parser version: ^1.18.3
express: ^4.16.4
return res.json({
payload: {
google: {
expectUserResponse: true,
systemIntent: {
intent: "actions.intent.OPTION",
data: {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
carouselSelect: {
items: [{
optionInfo: {
key: "car",
synonyms: ["automobile", "vehicle"]
},
description: "A four wheel vehicle",
title: "Car"
},
{
optionInfo: {
key: "plane",
synonyms: ["aeroplane", "jet"]
},
description: "A flying machine",
title: "Plane"
}
]
}
}
},
richResponse: {
items: [{
simpleResponse: {
textToSpeech: "Category List"
}
}]
}
},
telegram: {
text: "Category list",
expectUserResponse: true,
systemIntent: {
intent: "actions.intent.OPTION",
data: {
"#type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
carouselSelect: {
items: [{
optionInfo: {
key: "car",
synonyms: ["automobile", "vehicle"]
},
description: "A four wheel vehicle",
title: "Car"
},
{
optionInfo: {
key: "plane",
synonyms: ["aeroplane", "jet"]
},
description: "A flying machine",
title: "Plane"
}
]
}
}
}
}
},
outputContexts: []
});
This is code snippet to return carousel response to Telegram and Google. It worked in google assistant but failed to display carousel list in Telegram. Only text "Category list" was displayed in Telegram.
Is there any mistake in the payload for Telegram? Could anyone provide guidance on this?
Option responses(such as Carousel and List) are response type of actions-on-google modules and it is created for Google Assistant. Every platform has different screen abilities so you can not use every response type for every platform. As far as I know, there is no carousel or list type supported by Telegram. You may consider to use different options. For more information you may check out :
Rich messages

Failure calling dialogflow api by using npm programm

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

adding custom metrics to countly

I have a local countly installation, I have been able to make it multi tenet, now any dev from my organization can make an account on it, make applications under his account, and send data on it.
We would like to add some more data to our dashboard, like "Gender","age" e.t.c, and that I suppose will be in form of another metric like "device details" and "carriers", I would like know how do we add a custom metric to it.
I am new to nodejs and express, but I am getting hang of it, so just elementary know how will do, anyways I am reading code at the moment, so If I realize how to do it, i'll post it here as well.
There is a generic piece of code which gets the params from incoming http request, and throws them to the db, like all other params, the new collection is also made by this process automatically.
in file api/parts/data/usage.js
var predefinedMetrics = [
{ db: "devices", metrics: [{ name: "_device", set: "devices", short_code: common.dbUserMap['device'] }] },
{ db: "carriers", metrics: [{ name: "_carrier", set: "carriers", short_code: common.dbUserMap['carrier'] }] },
{ db: "device_details", metrics: [{ name: "_os", set: "os", short_code: common.dbUserMap['platform'] }, { name: "_os_version", set: "os_versions", short_code: common.dbUserMap['platform_version'] }, { name: "_resolution", set: "resolutions" }] },
{ db: "app_versions", metrics: [{ name: "_app_version", set: "app_versions", short_code: common.dbUserMap['app_version'] }] },
{ db: "gender", metrics: [{ name: "_gender", set: "gender", short_code: common.dbUserMap['gender'] }] }]
I just added gender to this list of predefined metrices, and now when i send the gender along with my http request, it gets saved easily.
Now I am working on rendering it on dashboard.

Resources