How to programmatically send a message to a Teams BOT - microsoft-graph-api

I have a BOT running which reponds to api/messages URL from the BOT Framework Emulator, and I can send text to it.
However what I need to do is write an application which sends text to the BOT over this URL. That is basically does what the BOT Framework Emulator does when I enter text and send it, probably over the graph API.
I am aware of information which demonstrates sending to a chat in a channel, but I just need to send to the BOT itself.
Can anyone advise how I can do this, or is there a suitable sample which demonstrates it.
Thanks

At the end of the day, your bot is really just a web api endpoint. If you set up a tunneling service like ngrok, you can use it's built-in web viewer to see the traffic that is sent to you bot, e.g. via the emulator or even via the azure bot registration page (there is a similar emulator built into the page in Azure). Once you've seen that traffic, you can essentially just mirror it from whatever you want to call from - it's essentially a json payload.
However, considering your bot is just a web api, I'm not sure why you want to "call" your bot from another app. Why not just make another endpoint that you can use for app-to-app communication (like a normal api endpoint). You can then refactor your code so that whatever you need to do can be done either via a bot message OR via the API call.

Related

Teams bot, which approach to go for?

My use case requires me to integrate teams with an app. Whenever a message is sent from that app, a private channel will be created and the message will be sent to teams. I've been reading the documentation and it has only confused me further. Do I need to use graph or bot? Can I do this using only graphs or only bot?
It's possible to send a message using Graph API - see here for more: https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http
HOWEVER, there are two ways to authenticate with Graph, either via an "application" permission (kind of like background service), or via "delegation", which means your app would work on behalf of a user. For this specific Graph endpoint, Microsoft mentions in the page that Application permissions are only allowed for "migration" (e.g. if you were building a tool to migrate from, say, slack to Teams). That means that you would have to use "delegation" which means the message would appear to come from a specific user.
As an example, instead of the message coming from "ABC Application", it would appear to come from "Syed Muhammad Ibrahim". If that's ok, then you can use Graph. If not, you would need to go the Bot route.

Slack Oauth - how do I force my slack app to receive messages in a certain channel?

I'm building a Slack app and when I install the app in my workspace, during the Oauth flow it asks me what channel I want messages sent to. I then have to choose among all my channels in a select menu (one of which is my slack app) where to receive messages.
When I install something like the Jira Cloud Slack app, it does not ask me what channel I want to use to receive messages, it just installs the app and I receive messages in the Jira Cloud channel. I'd like to try to set up my slack app so the user does not have to select a channel, but instead the messages go automatically to the app channel (like Jira).
Does anyone know what settings (Oauth scopes maybe?) I need to make this happen?
Are you using Slack's incoming webhooks? Webhooks will require you to specify a channel, but using Sign in with Slack for auth (or just authenticating with their OAuth v2) does not. Also make sure that you're using Slack's most recent version of apps that include granular scopes -- not sure if the legacy apps work like this.

Browser to Phone Calls Microsoft Teams (Communication API) C#

I am attempting to make a browser to phone call using microsoft teams communication api. I have gone through the documentation here and it suggests to create a calling bot.
I'm not sure if registering the bot on teams is necessary as I don't want the bot to participate in calls I need it purely for initiating 1:1 calls (myself to another user)
Is it possible to make browser to phone calls using communications-api
Any sample guiding implementation of this functionality

generate SLACK_APP_TOKEN for slack application

let's say I've created slack app and I have client id and secret.
What is the easiest way to get SLACK_APP_TOKEN in my hands that will be able to create channel?
If you want a proper access token that is related to your Slack App the only way to get it is to install your Slack app with the OAuth process as described here in the Slack documentation. You will need a mini website with a script (e.g. PHP) to perform the installation.
The so called test token will also allow you use the Slack API (e.g. to create a channel), provided that the user that created the test token has that right on your Slack. It is the easiest to obtain, but it will always be linked to a user account, not a Slack app. And you can not request specific scopes for it. So for most applications its better to use a Slack App and get a proper access token by installing it.
If you are looking for an example for an installer script, here is a complete script in PHP. It will run on any webserver that supports PHP. Its very basic, but it will work just fine.

Way to up incoming and outgoing mail for a custom mobile app

I am used to building apps in larger infrastructures. In a startup, how do I setup SMTP for a mobile app? Is there a place I can use for hosting this?
There are a couple of possible approaches:
One option is to not attempt to interface with SMTP/IMAP/POP servers directly in your app. You can, alternatively, send emails from your app via MFMessageComposeViewController, which gives you a standard compose email user interface. This is very easy to do.
To handle inbound emails you can let the user receive their emails via the standard Mail app (that way users don't have to go to different places to receive their emails). You integrate inbound emails with your app using a custom URL scheme. You can then send the user an email using this custom URL scheme, and if they get the mail on their iOS device and have that app installed, when they click on the link they will be taken to your app, passing it information from the URL in the email.
For example, if you defined a custom URL scheme of yourapp://, you can just include a hyperlink to that URL in your email (or text message or your web site), and if the user is on their iOS device, when they click on that link, they'll be taken to your app. If you google "iOS custom URL scheme tutorial", you'll see examples of the plist entries you need to make in your app for it to respond to a custom URL scheme. The Implementing Custom URL Schemes reference shows you what sort of changes you need to make to your app delegate to actually pass data in your custom URL to your app.
Alternatively, you can (a) sign up with any Internet Service Provider (ISP) that offers mail hosting; (b) write an app that sends email by connecting to that ISP's SMTP server; and (c) retrieve email by connecting to that ISP's IMAP or POP servers. Clearly you'll have to pay fees to the ISP, the quality of your app is linked to the quality of the ISP you partner with (so pick a good one), and you'll have to do your own SMTP/IMAP/POP integration in your app (and you'll have to write your own code to do that or use a third-party library for that, as this is not standard Cocoa Touch functionality). In my opinion, you'd need a pretty compelling business case to go down this road, though it can be done.
You could avoid email altogether, and develop a web service for letting the users send and receive messages. (This might make sense if the app is just sending messages between users of your app, for example.) Again, you'll have to contract with an ISP for web hosting, and you'll of course have to undertake the non-trivial exercise of writing your web service code. But this is architecturally cleaner than integrating with SMTP/IMAP/POP servers if the purpose of your app to facilitate communication between users of your app.
You haven't provided enough information for us to assess which approach best suits your situation.

Resources