Need a Https endpoint for microsoft teams and python integration - python

I have some python scripts which perform some jobs based on the user inputs I want to host this on microsoft teams. For an outgoing webhook teams asks for a https link where and how do I get it. I am pretty new to this so do not take anything for granted.

Basically, this "outgoing webhook" means that Teams has the ability to call a web service of some sort, hosted on a publicly-accessible https address. In the end, it functions very similarly to a bot, so it's possible to just create a full-blown bot. Here's guidance on creating a Microsoft bot (for Teams or otherwise) using Python.
However, there's a more simple option, of basically just hosting a web function somewhere (e.g. an Azure Function or, I guess, an Amazon Lamba). See this article. As mentioned in this link:
Outgoing webhooks post data from Teams to any chosen service capable
of accepting a JSON payload. Once an outgoing webhook is added to a
team, it acts like bot, listening in channels for messages using
#mention, sending notifications to external web services, and
responding with rich messages that can include cards and images.
An Azure Function automatically gets a full, unique, https address, so it's fine to use.
As another example, this blog post describes how to create a Flow ("Power Automate") that the webhook calls into. This example also ends up using an Azure Function to "glue together" Teams + Flow, but it explains the concepts a bit. You could ignore Flow and just use an Azure Function.
Whether to build an -actual- bot depends on -what else- you might want to be able to do. For instance, do you want to have a more complete conversation with the user? Do you want to the user to be able to interact with your code outside of a channel (e.g. a 1-1 conversation)? These are the kinds of things that will indicate if you might need a proper bot.

You need to use bot framework to create bot that will handle that:
https://github.com/microsoft/botframework-sdk
https://github.com/microsoft/BotBuilder-Samples

Related

Custom NLP-Engine in Python link to Microsoft Teams (Chat Bot)

I have built an NLP Engine in Python for domain-specific language. It takes in raw text and extracts semantics and entities. Also through socket method I have built in the state-management of the conversation. However now this needs to be pushed into Teams and I have understood that this can't be done directly (outgoing webhook Teams) due to security compliance, so I have to use Azure Cloud. I have been going through MSFT BotBuilder Framework, but this is not what I want. I need either:
Teams to be like the client.py that I currently have in the socket-method and use the state-management I currently have.
somehow for Teams to send a POST message to Python (Flask) and then manage the state, which I have no clue how to approach. How should this be done, there seem so many steps involved from Azure to MSFT botbuilder framework. However I don't need the bots from msft, already have my own bot, which I want to invoke in python.
Has anyone experience with any of the above approaches?
Thanks

Amazon MWS - how do I go about using AnyOfferChanged Notification with python

I want to develop an app that sends me an email when pricing offers for specific listings change using the AnyOfferChanged MWS notifications. However, I can't find any good documentation on how to go about receiving the notifications. Is it a must to have AWS SQS, or can I use Django? how do I go about subscribing to a notification?
I already have a developers account and I'm using the python mws library
You need to subscribe to the AnyOfferChangedNotification through the Subscriptions API and yes, it must use SQS. I found it easiest to use the scratchpad to create the subscription, since it's usually a one-time event.
Once your price change notifications start flowing into your queue, write an app that reads the queue and you can respond to your messages, including sending an email if that's what you want to do.
See if these code samples for SQS help you: https://docs.aws.amazon.com/code-samples/latest/catalog/code-catalog-python-example_code-sqs.html

How can other users obtain tokens for my in-development slack app?

TLDR: I have a slack app for managing private channels in its development workspace and tokens for it that inherit my user privileges. How can someone else in the same workspace obtain tokens for this app that inherit their user privileges instead?
Ok, so the background of this is: i need to manage the membership of a bunch of private channels based on some more or less complicated ldap-related conditions. For this, i wanted to write a simple Python program that got the membership of the channels in question, did its ldap magic to figure out who should be where, and then make it so.
I have implemented this and all works fine so far. The issue now is that i (that is my slack user) cannot be in all of these channels for privacy reasons. The API and Bot tokens i have obtained inherit all of my own user privileges. That means i can neither see nor administrate the channels that i'm not a part of.
Based on what i've read in the documentation of the Slack API, there's a way to have another user go through the OAuth process for the app that i created to get the tokens, get their own tokens, and use them with the Python program that i wrote. That would be fine, but i can't figure out how to do this.
Noone else has access to the app directly. The documentation makes it seem like i need to give people a specially formatted link (the "Add to Slack Button") that they can click on to get taken through the process. But that seems to require a "redirect URL". I'm not sure what this is and the documentation isn't very clear on it, but it seems they are assuming that the app is running on a server somewhere and will need to answer requests from Slack or something. That's not the case. It's a fairly simple Python script, not some always-up cloud app that will be responding to Slack Events.
So it feels like i'm missing something. Either i have some fundamental misconception about how this is supposed to work, or there is a simple way for someone else to get a token like that and i'm not seeing it.
Yes. If you want other users to authenticate your app (e.g. generate tokens so your app can perform tasks on the users behalf) you need to create an installation routine using Ouath 2.0. That installation routine is a small web app that has the "Add to Slack" button, a HTML interface and is able to run through the Oauth 2.0 process. That web app needs to run on a public web server.
For development purpose that web server can also run on your local dev machine with a VPN tunnel to the public Internet. Slack recommends using the VPN service ngrok for that purpose.

Slack RTM API uses POST or GET method?

This might seem a lame question, but would be great if someone can help. I wrote a small python script which returns some output based on a command sent to it via slack's custom bot. Python script uses RTM API. Whenever someone in slack mentions the bot and passes a command (ex: #slackcustombot foobar), it returns a custom message(ex: Hi foobar) from the script. Now the issue is at the security side. My script resides at a server which is not open to internet. And as Slack uses dynamic IP, there's no possibility of white-listing the slack ip's.
So basically, all I wanted to know is, when someone in slack channel mentions the bots, and when the bot at slack server sends the command to my python script residing at my server, does it send as GET method or as POST method? cuz if it's a GET method, I might not have to worry about the security issue. but if it sends as POST method, what alternative I could use in this scenario? Any help is appreciated. Please correct me if I am wrong somewhere, still learning. :)
Regards,
Junaid.
Neither. It uses the WebSocket protocoll. If you rather want to use a HTTP-based protocol I would recommend looking into the Slack's Event API. It uses HTTPS POST to transfer messages to your bot.
The Events API is not providing all event types that are available with the RTM API, but its much easier to handle and should be sufficient for a chat bot. Check here for a documentation of which event types are available to the both RTM API and Events API.
You will however need to find a way to expose the url of your bot to the Internet, so that Slack can use it. If you need to access internal company applications through your Slack bot, the best approach in my opinion is to have the Slack bot on a webserver in the DMZ of your company.
A more small scale approach is to use a forwarding provider that is connecting to your local webserver through a VPN tunnel and exposing your internal webserver through a special public URL. That would work if you want Slack to talk to your webserver on a local network behind a router / firewall. One example is ngrok, but they are other providers too.

send google hangout notification using python

Is there an API which allows me to send a notification to Google Hangout? Or is there even a python module which encapsulates the Hangout API?
I would like to send system notification (e.g. hard disk failure reports) to a certain hangout account. Any ideas, suggestions?
Hangouts does not currently have a public API.
That said, messages delivered to the Google Talk XMPP server (talk.google.com:5222) are still being delivered to users via Hangouts. This support is only extended to one-on-one conversations, so the notification can't be delivered to a group of users. The messages will need to be supplied through an authenticated Google account in order to be delivered.
There is pre-alpha library for sending hangouts messages on python:
https://pypi.python.org/pypi/hangups/0.1
The API have been reverse engineered and is not published (as someone posted in comments). Thus it might change a Google's will.
Also, messages sent using XMPP ceased to be delivered to Hangouts users. I guess this is another cut (of the thousand scheduled).
I send alarms and other notifications with a python script (failures on database server, partitions without free space, etc), using hangouts. It's easy. Look at http://www.administracion-linux.com/2014/07/enviar-mensajes-por-hangout-desde.html to send hangouts.

Categories

Resources