What is the Get URL to fetch TEAM roster or user profile information? - azure

Can someone please share the postman to fetch TEAM roster or user profile information. I am referring to https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json

The Url you need is this: [serviceUrl] + "/v3/conversations/{teamId}/members/"
and it is based on two variables: the "teamId" is obviously different per team. However, the first part of the address (called the ServiceUrl) can also vary between teams, based on where they might be hosted, and you need both.
It sounds like, from the link you sent, that you already have a bot? If so, your bot can retrieve both of these required parameters. One way is that, whenever a user sends a message to the bot, to get the ServiceUrl and TeamId that are sent in the incoming "activity" object that. However, if you want it even earlier than this (i.e. before a user even sends a message to the bot), have a look at the conversationUpdate event here which will fire right when the bot is first added to the conversation.
Does that help?

Related

Discord.js how can bot ping when someone with a specific role leave

I made a bot and I want to add a feature to my bot. ping a specific room when people with a custom role leave the server. So, for example, we'll know when people with the "partner" role come out.
I wanna write code in index.js.
Lemme tell you this isn't much related to discordjs itself, but the way discord client works. You should not probably ping a user who has left the server, as uncached users on mobile or any user may show as invalid user. Therefore you should log username#discriminator, or actually tag and then user id incase you want to keep the record of their IDs for future ping, etc.
Edit after you commented:
There's guildMemberRemove event for your client bot.
Info: https://discord.js.org/#/docs/discord.js/stable/class/Client?scrollTo=e-guildMemberRemove
It emits member object, and you can get that user's name, etc from that. You can make the bot dm you, or send a message in a specific channel, and ping you.
Important Notice: keep your bot private, in your server only, or else, add a if condition to check whether the member who left was from your specific server or not, or else the bot may log that user even if he didn't leave your own server.
In guildMemberRemove event you can specify the alert message.
Check member has a role or not then send your message in right situation.

Adaptive Card Expire After Specific Time

We have integrated the NodeJs bot application with the bot framework for interacting with bot in the Microsoft teams.
Based on the user input we are sending the adaptive cards respectively. Currently user can get the adaptive card today and can update the card later that day or after few days.
Is there any way to make the card expire after specific amount of time which make the card disabled.
Thank You
I have an idea how you could do this, but just an fyi that I've not done exactly this before, so there's no guarantee it will work. Basically, you'd be combining the ability to Update a message like discussed here with sending (or in this case 'updating') a pro-active message - see more here on that.
Because this is an existing conversation with the user, you'll have access from any existing message the user sends to get the parameters you need to start your proactive conversation (you need serviceurl, conversationid, tenantid, etc.). Do note that you can send a proactive message from OUTSIDE your bot (the code can be hosted somewhere else, and doesn't need to actually live IN your bot, even though to the user it will appear as if a proactive message was sent from your bot). I mention this because you could have this "expire card" message live in a separate process to your bot.
In case if you are still looking for an answer, I recently tried this approach:
In the card's response data, I set the expiry date and so now when the user submits the card, you can validate the data in the response and then update the card accordingly.
I had to use this approach because we have a very high user base and updating the card for all users proactively took much longer.
Cons: The card will remain will remain active, unless and until the user takes some action on it.
First of all, no this is nothing that is already implemented anywhere and you completely have to build that yourself.
One way to do this is this:
You need to store the activity / message ID for all cards you send. If you have the ID, you can always at any time go back and update the message (ie update your card)
Now that said, what i would suggest is this:
Sent a card to the user and store the id
Store the ID together
with creation date and expiration date somewhere on your end
Have some scheduled process that scans for expired cards
If a card is expired, update the message with a new card saying "sorry this card is expired"
We did that for our MS Teams Bot and its working quite well this way.

Actions on Google - Push notification to a user (userId strategy)

I am working on my push notifications to users and working through the documentation.
Following this walk through, I have set up a webhook to send a notification to a user, this notes a target.userId for the recipient. Question, what exact value is the referring to? Is this the userId I invent for a user, or is it something else?
Looking at userId documentation, it appears this has to be generated/maintained, and can go stale every 30 days of inactivity. Noted here
My concern is - users sending other users notifications. If the recipients userId has gone stale from what I've stored in my database, I assume the push notification will fail when trying to find that user by userId that expired? Is this the only way to target a user for a push notification? My assumption is yes based on this documentation - but it seems brittle - or unstable, since it rely's on an ID that can expire (unless i'm misunderstanding userId's).
Is what I've outlined above the correct way to think about push notifications from one user to another? I store the users ID in my database, and when a message is triggered ie: "tell JimBob that I'll be there at 11." i look through my DB to find JimBob and his saved userId, and then send JimBob the push Notification from MarySue.
I assume this also denotes that JimBob has to allow push notifications from the intent "receive_message".
In this case, you're misunderstanding the ID that is sent to you.
First - the UserID you reference is deprecated and scheduled to be removed later this year. And even when it wasn't deprecated, it would be unique and non-duplicated, so there was little chance of missends.
The ID that you need to use will be handed to you when the user approves the subscription. This will be in the arguments that are sent as part of the Intent where they approve it, and not with the request in general. When sent to you, you need to save this.

Dialogflow v2 user input and fulfillment

I am writing a Dialogflow v2 chatbot with Actions on Google.
I am asking for users to create a list and then have the option for ordering them.
I need to get a few pieces of information from the user. Her name, phone number and address.
Then I need the name of the vendor and their mobile number where the order will be forwarded.
If they have already given their name, I want to show it to them and have them confirm it.
The problem is that everything is an intent.
As an example they say Order from my list. I have to ask them for a store name e.g. Walmart. Now the problem is that I may not have all the vendors in an entity list. And if they just say Walmart, how do I know if it's a vendor name. I know I could have a follow up intent but not sure what happens when they don't say the right thing.
Basically, this is how I want the conversation to go.
They create a list which I have working.
Then they say order from list
Chatbot ask for the name of the store and mobile number to order from
Chatbot checks the name in the database and if doesn't exist adds it.
Asks for name, number address of the user
Shows the order, the vendor and the user's name and address
Passes this information to the server fulfillment hook.
Next time it needs to sense that it knows the user name, address and number and ask the user to confirm.
In simple terms, you would need to rely on contexts and webhook for validating the store name.
If the store is not valid, reset the context (same as input) and politely ask the user to provide the right store name.
Maintain a counter in parameters to keep track of the number of wrong attempts.
Increment that counter when wrong, reset when correct.
If the counter reaches 3 or 4, politely reply back that you could not serve them this that vendor and ask them to try the app later.
If this assistant app is US based you may need to add Transaction API as well to show the final order and confirm back to the user. Transaction API is available in the US as of now so keep that in mind.

Telegram Bot Event When Users Join To Channel

After create telegram bot, access and admin this bot to channel. how to get channel members list or event when users join to this channel?
Pretty disappointed with the current answers, so I'll leave an updated (as of February 2018) answer that explains how to do this with the Telegram API itself, as well as with the framework I am using, Telegraf for Node.
The Telegram API is both very powerful, and pretty simple as far as API's go. If you are using the polling method of getting updates, and not websockets which are a whole other issue, checking if someone new has been added to a group or channel is very easy.
The API method getUpdates returns an array of Update objects, which contain all of the possible information you could want including any messages sent, inline queries, and new chat members. To get any new chat members you simply need to access update.message.new_chat_members which will contain an array of new users. For reference you can look in the API documentation here.
To fetch the update objects in browser, or with curl, all you have to do is send a GET or POST request to https://api.telegram.org/botYOUR-BOT-TOKEN/getUpdates. Then just look for messages->new_chat_members.
If you are using the Telegraf bot framework with NodeJs you can use the bot.on method with the event new_chat_members.
Example:
bot.on('new_chat_members', (ctx) => console.log(ctx.message.new_chat_members))
I know this was asked a while ago, but I hope this helps other people searching.
From docs:
new_chat_members New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
So i think you can't.
To get updates on users join group or channel you must correctly setup webhook for your bot. This update type is disabled by default. See https://core.telegram.org/bots/api#setwebhook
allowed_updates
A JSON-serialized list of the update types you want your bot to
receive. For example, specify [“message”, “edited_channel_post”,
“callback_query”] to only receive updates of these types. See Update
for a complete list of available update types. Specify an empty list
to receive all update types except chat_member (default). If not
specified, the previous setting will be used.
Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received
for a short period of time.
So, the request should look like this:
https://api.telegram.org/<BOT_TOKEN>/setWebhook?url=<WEBHOOK_URL>&allowed_updates=["chat_member"]
Yes! You can use this:
https://api.telegram.org/bot[TOKEN]/promoteChatMember?chat_id=#[channelname]&user_id=[user_id]
if user is joined response is ok, else response is not ok.

Resources