User Avatar in Ms Bot virtual Assistant bot framework V4 - c#

I am developing a chat bot using MS bot framework V4 and virtual assistant.I am looking for ways to add avatar.
1) Bot avatar
in Azure Web Chat I updated the bot icon, but the avatar is showing up only when I test in azure web chat.How to setup my bot avatar so that it will show up consistently in every bot channel
2) User avatar.
I am authenticating my user making use of MS graph API and I can find the profile image in token, but not sure where to configure it so that it will show user's avatar along with each response/message
I have gone through the Demo for setting the bot framework server and the webchat for the bot by following the samples provided
bot server == https://github.com/Microsoft/BotBuilder-Samples
webchat == https://github.com/Microsoft/BotFramework-WebChat
but there is no proper example or documentation on how to set the user image after the user has signed in. using the signed user object.
I looked into the discussions mentioned here, here and here. Any suggestions ?

Bot avatar: avatar management is different given channels. There is no way to globally modify your bot avatar for every channel:
For Teams, it is a property of your app package
For the webchat, you can setup the image on your webchat code
Etc
User avatar: same here, there is no quick way of changing the image of the user in the webchat after its start. You pointed the right topic, you will have to dig in the webchat code

Nicolas is correct regarding avatar management across different channels. This answer specifically addresses the "User avatar" question.
Updating the user avatar in Web Chat is possible, however it will require you to use React (or similar) for re-rendering, as well as for state management. This Stack Overflow solution (located here) details how to achieve this.
It does use AAD for obtaining the user photo (for use as the avatar). If you are not using AAD, then change the code to make the appropriate service and API call(s).
Hope of help!

If you are following the webchat samples available at: https://github.com/Microsoft/BotFramework-WebChat. User avatar can be changed by creating a style set using createStyleSet method where you can put many style properties to customize your webchat UI. Among those properties is userAvatarImage which will take the image url for user avatar.
hope this helps.

Related

How to really send a message to a user in Teams through a bot

The last few days, I checked dozens of samples, docs, blog posts, youtube videos (courses, that I couldn't fine) and I can say I'm still confused and I still without a Teams bot.
Every example I've checked is different in approach, and now I'm pretty sure there are many others like me.
Frequently problems: required input/parameters like service Url, conversation Id, etc. 1. You can't find a explanation for them. 2. You can't find a place where it's explained how to get them.
What I want to achieve
I want a bot on Teams, with a API, with 2 parameters: user email, message. The bot has to send the message to the specified user. That's it.
I'm looking how to:
Create/Setup the Application
Create the actual Bot
Install the application to Teams
I used to create a Teams conversation bot. Hope my experience will help you.
First, download sample provided by microsoft. I uses c# to create this bot, so I copy the '57.teams-conversation-bot' folder and opened it with vs studio. In this sample, I need to modify the configuration in appsettings.json. I need to enter the appid and apppassword.
So the next step is creating an Azure ad application in Azure portal. But if you never create Bot Framework registration resource before, you can create the azure ad application when you create a Bot Framework.By the way, You can leave 'Messaging endpoint' empty now. Please note, when you creating Azure ad application, you can choose to set this application as a multitenant app if your account creating the app is in a different tenant with your teams account.
Now I have a bot framework and an Azure ad app, I can modify appsettings.json, enter the appId and app password. I can get appId in app overview page and get app password when creating client secrets in Certificates & secrets tag.
Now, I need to debug my sample with web chat in the azure portal(Enter the bot framework created just now, you can see Tag 'Test in web chat' in the left panel). So I need to use ngrok to make the bot visit my code in local environment. Running the sample by pressing F5 in vs studio. Opening ngrok.exe and running the command ngrok http -host-header=rewrite 3978. Then I can get a https url, copy that and paste in the 'Messaging endpoint'. Don't forget to add '/api/messages'.
Now sending 'hello' to the bot and you will get default result. When you get the picture below, it means you have made a correct configuration.
Next step is to add this bot to Teams client. First, I add the Teams Channel in the bot I created in the azure portal.
Then I need to modify the manifest file. Replacing the "YOUR-MICROSOFT-APP-ID" with appId creating just now. And creating manifest.zip file which contains the three file in folder TeamsAppManifest.
Next step is uploading the zip file to Teams client. Click the 'Apps' in the lower-left corner and click the 'Upload the custom app' in the bottom of the left panel, then click add. Ok, now I get a team conversation bot.
There -are- a ton of approaches, partly because Teams development is still relatively new, partly because the Bot Framework (the set of tools for buildings Bots in the Microsoft world, both for Teams and otherwise) has also undergone some major changes. That's aside from the various language options (dotnet, node, python, etc.).
What's looking to be a good place to get started though, is the new Teams Toolkit, a plugin for Visual Studio and Visual Studio Code, for building a new Teams project (Tab, Bot, etc.). Have a look here for a link. It's very new though, so some rough edges, but it's aiming to be very comprehensive to get up and running quickly (does a lot of Azure registrations behind the scenes, for example). Check out the latest monthly Teams Developer call, from earlier this week, for a visual run-through: https://www.youtube.com/playlist?list=PLWZJrkeLOrbbTKzV1sQOFAXd_s0BHJDiL (this week's call isn't up yet, but it should be very soon).

How to get access token and use it

I am working on creating bot for Microsoft teams in C#. I have a sample code (basic echo bot) that works fine in emulator. I created an app in teams app studio and entered my API end points in Bot section. I download the package and upload it as custom package in teams.
Now, when I add this app and try communicate with Bot, I get unauthorize error in API (using ngrok). I guess what’s going on here is that I don’t have the access token i.e. when someone install it, teams should give you access token, right?
What I don’t know is how teams will give me the access token and where in the process that access token will be used?
So basically, when someone clicks on “Add” button in teams app store, how the access token are passed.
#update
Note:-I have done the app registration as well.
So i did bot channel registration in Azure and added my ngrok end points. I copied the "MicrosoftAppId" and "MicrosoftAppPassword" in appsettings file. It is working fine in emulator as well as "test on web chat" in Azure bot management portal. I also connected it to Teams channel from portal itself. when i navigate to teams from the channel link, my bot is working as expected.
After that i opened app studio and entered all the details. In Bot section, i selected existing bot id and entered my MicrosoftAppId from azure and it worked.
what I still don't understand is, when someone install the app, teams should be sending some information to my end point, right?
Without access to your code it is hard/impossible to determine the cause of your issue.
I suggest instead you take a fresh start by using one of the Teams bot examples that are shared :
57.teams-conversation-bot
if you do require authentication in your bot:
Authentication flow for bots - Teams | Microsoft Docs
46.teams-auth
52.teams-messaging-extensions-search-auth-config
pleanty other teams examples as well in that repo:
50.teams-messaging-extensions-search
51.teams-messaging-extensions-action
53.teams-messaging-extensions-action-preview
54.teams-task-module
55.teams-link-unfurling
56.teams-file-upload
57.teams-conversation-bot
58.teams-start-new-thread-in-channel

Where to find the Telegram Api Key

I am trying to find the Api Key for Telegram but I cannot find it. Where do I find it on the website? If I use the Api Id, I get the error Incorrect Token Format in the C# Console Application.
Like ihoru mentioned in his answer, you can find all of your bots relevant information in BotFather.
So navigate to #BotFather in Telegram. If you have not yet created a bot do so by entering /newbotand follow the instructions on screen. You should get your key at the end of the process.
But now let's assume you already have a bot and can't find the key anymore. Again, go to #BotFather but this time enter /mybots. You should see something like this:
Click/Touch whatever bot you would like your API key for, then you should see this:
Click the API Key button and tadaa there is your key:
You mean Telegram API for create a telegram application using C#, not Telegram Bot API, right? to get API key. Please see the step by step below or for detail information you can see this link
Sign up for Telegram using any application.
Log in to your Telegram core: https://my.telegram.org.
Go to ‘API development tools’ and fill out the form.
You will get basic addresses as well as the api_id and api_hash parameters required
for user authorization.
For the moment each number can only have one api_id connected to it.
But if you need API for Telegram Bot, You can check the API your bot using BotFather.
for detail, you can check on this link
I hope this is useful for you.
In special official bot: https://telegram.me/BotFather
Additional information on official Telegram FAQ page:
https://core.telegram.org/bots/faq#how-do-i-create-a-bot
Are you asking for finding bot's token ?
or are looking for telegram client api code ?
#BotFather , gives you the token of each bot you made.
for getting api token for making client , you must make developer account for telegram. it can be you personal account for telegram .

How to get user's location while chatting with bots?

I am developing a Bot Framework application that integrates with Slack using Microsoft Bot technology. In the bot project, I was trying to get the user location when the user sends a message.
What I am trying to achieve is that, when a user types the message "Show me nearby hospitals", I want to get the users Geo coordinates and pass them to an API that will return a list of hospitals near that location. So any idea on how to get the user's current location in the Microsoft Bot project?
I tried using the Geo location class, however I am not able to add the class reference directly and when I add the external DLL for the Geo location class, Visual Studio throws some errors.
Is there any way to get the users current location in Bots?
The Bot Framework is getting updated every minute!!!
The Bing location control for Microsoft Bot Framework makes the process of collecting and validating the user’s desired location in a conversation easy and reliable.
The control is available for C# and Node.js and works consistently across all channels supported by Bot Framework.
Check the documentation here.
Click to view the code sample
This question is old but this is now a thing that exists to help with location hope it will help someone looking for this answer. https://github.com/Microsoft/BotBuilder-Location
Channels vary on whether they support location information. There is currently no way to get location information for users on Slack. Telegram, for instance, does. When location data is available it will returned in the Attachment data structure and in the channel's native format in the ChannelData field. Note that the user needs to opt into sending this data (to protect their privacy). The bot developer can send a message to the user requesting that they share their location data, but they cannot get it from the channel it w/o user action to share it.
This is currently not handled by the BotBuilder well. I've opened an issue to get this standardize across platforms. Regarding Slack, they don't have an option to send a location as an attachment as Telegram, Messenger and Kik do, so you might want to use Google Geocode API to derive coordinates from a string.

Is it possible to post a picture to facebook,twitter using Microsoft.Phone.Task library in wp 7.5

I am using ShareLinkTask to post URL to social websites like twitter and facebook. Along with the URL ,i want to add a picture URI and the picture should display in sites.Is it possible ? Also is it possible to share when a different user is using the app ?since only one account is in sync and always the posting to sites happens with the account in sync with the phone.Can we have the login again while sharing so that the person using the app can post to his wall?
No. Tasks are somewhat more limited compared to a direct API layer implementation that you would get through a service-based SDK. They are always bound to the accounts that are associated with the device and you cannot log the user in/out with those from the app, unless the user himself decides to switch the accounts.
Also, at this point you cannot attach media content to a ShareLinkTask unless you already uploaded it through a service (such as IMGUR) and just posting a link to it.

Categories