Is it possible to call external web APIs from Slack? - slack

I want to pull some metrics daily posted in my slack channel. these metrics are located in my personal server, and to pull them via rest API a basic authentication is also required.
Does slack support this?in other words can slack do external api call in such way?
and if yes how?

To achieve this, you need to create a custom application(bot).
You can implement your custom business logic and then use slack APIs to post generated data to Slack Client.
https://slack.com/intl/en-in/help/articles/115005265703-Create-a-bot-for-your-workspace

Related

Slack - Interactive button with authentication

What I'm trying to accomplish?
Send an API (chat.postMessage) from a 3rd party app to a Slack user - Done
The message will have two buttons (approve and decline) which the user can click on - Done
Upon clicking on one of the buttons, Slack should send an API back to the 3rd party app - TBD
Before sending an API, Slack should retrieve an authentication token via API - TBD
Note: I've seen in Slack docs mentioning of /incoming endpoint (also /interactive-message). My 3rd party app has a strict set of available APIs. I'm not able to create new API endpoints. Also, I need the payload to be sent in a specific JSON structure.
I've reviewed Slack documentation but I can't figure it out.
Making notifications actionable
I'm technical but not a developer so there might be nuances which I'm missing.
Is there any section in Slack where I can add custom code to accomplish such integration?
If not, how I can accomplish it?
Edit:
I've configured a Request URL (in slack), when I click on one of the buttons in the message, I can see an API request is being sent to the URL.
I'm able to see the payload as well.
My problem is that I need the information to be sent in a different format and to a different endpoint.
What is the best approach to take for this? Do I need to develop a new service to capture and parse the payload and then generate the API request to my 3rd party app?
Ok, so here is how I've accomplished it.
Upon clicking a button in slack, Slack sends an API with a certain payload to the predefined endpoint which you configure (Request URL).
I've used free tier AWS serverless components:
API Gateway and Lambda
API gateway receives the payload and invokes the Lambda function (I used Python as it seems the easier for a non developer)
My Lambda function is processing the payload and has the logic to interact with my 3rd party app in the required way.

Authentication to use Teams incoming webhook

I'm implementing a microsoft teams incoming webhook and I got worried about some bad guy getting the webhook link and sending spams, getting messages from the team and so on. So I'd like to know how secure this feature is? Is there anything that I can do to improve the webhook security?
You can bring Microsoft Teams Incoming Webhook security to the next level using Azure Logic Apps:
It provides following security levels:
Better control over who can create and use a webhook:
You can rely on Azure RBAC built-in roles for Azure Logic App to define your access policy. The configuration of the webhook is done in Azure and no configuration information is available from Microsoft Teams.
More options to authenticate the event emitter: There are different ways to authenticate an emitter and Azure Logic App provides a wide range of options to do that - These methods come in addition to the SAS signature or can replace it.
To name the most requested one in the context of incoming webhooks, we have:
Source IP white listing
Basic authentication / Http headers acces keys
Azure AD OAuth2.0 token
Protect users from the content published into Teams:
With Azure Logic App, you will capture all requests to the webhook because you have control over the endpoint (versus incoming webhooks hosted and exposed via the O365 platform) - When the workflow is triggered, you can add actions steps to your workflow to:
Validate the schema of the payload (in case an inappropriate JSON
content is pushed)
Log this request into an external system - e.g.
you can push this payload or log this event into Azure Monitor and
process the content in Azure Sentinel using Logic App built-in
connectors.
Map / aggregate / curate / enrich / .... the incoming
content and format the message to be pushed in Teams using Adaptive Cards.
Reference doc: https://www.linkedin.com/pulse/bring-microsoft-teams-incoming-webhook-security-next-level-kinzelin/?msclkid=58f6ddafd0eb11eca9ccc0356553ed5c

Is it possible to trigger TravisCI build by Slack message w/o spinning up my own server?

When I did research online, most of the solutions are about triggering Slack notification from TravisCI. Now I want to do the reverse direction - type some message in slack, and trigger a build task in TravisCI.
I'm looking at Slack's Outgoing WebHooks - under their "Custom Integrations" in Slack app directory. However, their webhook POST data spec is fixed, not seem to be programmable through just their webpage UI. They have a column in the UI that lets you fill in URL(s) to POST to. But I don't see any ways that I can customize the data field of the POST request.
Same as TravisCI's Triggering Builds API v3, the data fields they expect in the POST are fixed and unchangeable.
I know I can sign up a cloud service, write some code and spin up a server to re-package the parameters to do the work, like a middleware between these 2 APIs. But just want to see if anyone manages to achieve triggering TravisCI by Slack in such way that doesn't involve spinning up a server myself?
I ended up hosting a server and writing the porting logic myself. I guess there's no simple way to do this, after all they are different APIs. Here is the code where I request against travisCI API, and here is the code where I unpack the slack webhook POST request.

How to user Direct Line to create a real-time messaging in MVC

Is there a way to use direct line from a bot framework to create a real-time messaging application? I need call my Bot directly from a custom MVC application.
The Microsoft Bot Connector Direct Line REST API allows me to do this, but not in real time. Currently I have to make a post action to refresh the screen and get these messages, and it requires a client post action. Do you know a way to achieve this real-time?
You might want to take look at the version 3.0 of the Direct Line API, which allows you to use a WebSocket to receive messages.

MailChimp send email v3.0

The version 2.0 of MailChimp APIs has a campaign send API. However I don't find any similar API on v3.0. I do find an automation API where in I can start a workflow, however it appears from the documentation that workflows can't be created using APIs and can be created only using the GUI.
The requirement is to be able to send emails using MailChimp API. Please advise.
It's now possible to both create and send a campaign through the V3.0 API.
See the 'Action' tab here
You can send to a saved segment, but as far as I can tell, there's no way to create a saved segment via the API.
You actually cannot send one on one email with APIv3.0. Mandrill now takes over for the transactional emails.
It's not yet possible to edit or create campaigns in API v3.0. See the API v3 roadmap.

Resources