Send console output from jenkins job to teams channel - jenkins-pipeline

I have a jenkins job that when run I want to be able to send the output from the console to a teams channel.
I currently send a notification to the channel with a link to the build but want the actual output without having to follow the link.
Is this something that is possible to do?
currently have this in jenkisfile:
post {
always {
script {
office365ConnectorSend webhookUrl: '<webhook url>',
status: "Environment Owners",
message: "Environment owners can be seen here (<${env.BUILD_URL}>)"

Related

Unable to successfully upload a file via Slack API

I'm unable to successfully upload a file even using Slacks file.upload tester mechanism here: https://api.slack.com/methods/files.upload
I've applied a Slack app token, channel name, and chosen a file, but get the following result:
{
"ok": false,
"error": "missing_scope",
"needed": "files:write:user",
"provided": "identify,incoming-webhook"
}
I then created a new app, and ensured that files: write was in scope (it wasn't in the previous app). Now, I get a different error:
{
"ok": false,
"error": "not_in_channel"
}
As a test to confirm that the channel name was ok, I subsequently tried a nonexistent channel name, and the error indicated 'channel_not_found', so the channel name I used should be valid.
I had the same issue and fixed it by adding the Slack app to the channel
I guess there are many ways to add it;
I just opened the corresponding channel I was trying to "files.upload" to, and clicked the "Add an app" link at the really top of the channel history:
Before posting a message, reacting to any message or uploading files you need to open a conversation with the channel. You can also do it programmatically and achieve this with the help of API (https://api.slack.com/methods/conversations.open)
You just need to invite the app that you created into the slack channel. Example:
#AppBot

Rasa Slack Integration Issue

I am using rasa to connect to slack using Ngrok.
My bot is properly responding with RASA X. These are steps i have done to connect with slack.
Create new Channel.
Added new user in App home(new in slack, worked with dialogflow for me).
Added the URL in event subscription like this:
Event Subscription containing ngrok/webhook url
subscribed to following bot events.
Added localhost to redirect URL
Installed the app to a channel
Copied the Bot User OAuth Access Token to my credentials file:
then started the bot using rasa run on port 5005 where ngrok is running
I get the response from slack into rasa (rasa run actions terminal, trying to run some google drive api).
Even simple bot is not responding to a hi msg tried that also.
Only in cmd i get the response, which means that msg is coming from slack to the rasa
And no message is fetched back in rasa window.
Note : i have also used
rasa run -m models --enable-api --cors “*” --debug
to debug the output and it shows clearly message coming to rasa from slack, bot predicting correct intent and uttering correct response. but this msg is not getting fetched back to slack

Delete interactive message (command response) just with Slack Commands API

So I'm building a slack app in Node that responds to some user commands. It usually responds with an interactive message that has some attachments and buttons.
For certain buttons, I return different types of texts or other attachments, but I also want to have a "Cancel" button that would basically cancel the current command - delete it from the user's chat.
The thing is that I want to do it without having to request the chat:write:user scope or without having to create a bot.
By asking for the chat:write:user scope I can basically remove any message the user created, but it asks for that scope when installing the app and gives my app permission to post on behalf of the user, which most find uncomfortable.
By creating a bot I could achieve this, but again it asks for permission to add a bot to the channel and I don't want this.
What I've tried
Use chat.delete method, but I get { ok: false, error: 'missing_scope', needed: 'chat:write:user', provided: 'identify,commands' } from Slack, even when I try with as_user set to false.
Respond with an empty message to the command, like res.send(), or res.send({ text: null }), or res.send({ attachments: null }), etc.
When you reply to a user command on Slack it overrides by default the previous content. I just want to override with nothing, basically removing the original response. When I try this however, it doesn't do anything, unless I provide some content.
I'm pretty sure #2 is the way to go and I feel I'm close and it's something pretty simple but out of my sight.
Working example of what I want
I know it can be done because the GIF Keyboard app for slack does this. When searching for Gifs, they have a "cancel" button at the bottom that just removes the current command/message. Furthermore, they only ask for the Commands scope.
You are on the right track. Option #2 works, so no need to request scopes to delete a message.
Just send the following response back to Slack and the last (ephemeral) message from your app will be deleted:
{
"response_type": "ephemeral",
"replace_original": true,
"delete_original": true,
"text": ""
}

Can't see Grafana images in Slack

I set up a Slack notification channel in Grafana using a webhook as URL.
When I click "Send Test" I see this notification in my Slack channel:
However ordinary notifications are shown without images. I read Grafana's docs, but apparently I haven't understood it.
If you want to include screenshots of the firing alerts in the slack messages you have to configure either the external image destination in Grafana, or a bot integration via Slack Apps. Follow Slack’s guide to set up a bot integration and use the token provided https://api.slack.com/bot-users, which starts with “xoxb”.
Can someone guide me through it? I created a new bot and generated a token for it (starts with xoxb as requested) but how do I keep going from there?
Please assign this permission in your Slack app then try:
Go to <grafana_host>/alerting/notification/new (or click the top-left Menu icon, select "Alerting", select "Notification Channels", click the green "New Channel" button). You should get the page in the screenshot below.
Do the following steps:
Set "Name" for the channel.
Set the channel "Type" to Slack.
Check "Include image" option.
In "Slack settings", set "URL" to incoming
webhook you created in Slack.
Set "Token" to bot token generated for
bot.
And voila!
Update
Ability to configure a Slack token was added in Grafana version 4.6.0
It wasn't mentioned by OP but if your target Slack channel is a private channel, you'll also need to ensure that you've added the bot to the private channel so that it is able upload an image to it.
You can do this by viewing the channel's details, clicking "More" and then "Add apps". On the screen that shows up, you should be able to search for the bot that you created and click the "Add" button aside it.
Good luck!

How to check credentials against botframework api

I'd like to check that my bot credentials (appId + appSecret) are ok to connect to https://api.botframework.com/bot/v1.0/messages.
I can't send a real message because i have no conversation running so I tried to post the following json message :
{ "type": "Ping"} but the response i got was
{
"error": {
"message": "Expression evaluation failed. Object reference not set to an instance of an object.",
"code": "ServiceError"
}
}
Is there any way to check if my access to the api is ok?
If you've registered your bot, you can visit the Bot Framework page, click on the My Bots menu, and select your registered bot. On your bot page, scroll down to the bottom left and there's a test box.
Also, you can use the emulator. It has a place in the upper right corner to replace the default credentials with your bot credentials. Then change the URL to where you have your bot deployed. Tip: remember to append 'api/messages' to the URL.
Download the BotFrameworkEmulator to test connectivity to your bot. It works on windows and OSX if you have mono installed. You can change the default settings that the emulator uses by typing '/settings' after running it. You will be prompted to enter your appId, appSecret and url endpoint for sending and receiving messages to/from your bot.
You can also use the directline rest api to initiate conversations and send messages to your bot

Resources