I've built a small basic web bot app using bot framework and want to deploy it on Azure. I've followed all the steps and it's working fine under "Test in Web Chat" of Azure Portal too, but however as I open my bot's endpoint
https://optlbot.azurewebsites.net/api/messages
I get an error saying
The requested resource does not support http method 'GET'
Can somebody please help me, I can't debug my application at all. I've also tested on emulator and there too it's working fine.
Yes, the URL https://optlbot.azurewebsites.net/api/messages works only for POST request and not a GET request, because you post a message from user to bot and not a get, you can see that in the MessagesController code.
Being said that, if you want to test your bot locally, you have to use the emulator. You can have a look at Bot emulator for the same.
Now if you want to publish the bot to the world so that others can see it and use it, so that's where the channel comes in. Consider channel as a medium by which you enable your bot for others to use with a much better user experience.
There are multiple channels available for the bot to be published in, and yes you can publish the same bot in all the channels.webchat is just one channel and the one which is enabled by default and the way to see it is :
Open your bot in the Azure Portal and click Channels blade.
Click Edit for the Web Chat channel
Under Secret keys, click Show for the first key
Copy the Secret key and the Embed code.
Click Done
So the embed code is actually an iframe which you can place in your website or share with others who want to use your bot. Or you can use the src of the iFrame too to reach the bot directly.
Again this is just one channel. You can take a look at the Configure channels documentation for steps to enable the bot in more channels like Skype, Microsoft Teams, Email, Facebook, Slack, Telegram, etc.
If you check the code of your MessagesController, you would find the following action defined in your controller, it only accept POST request and read the value of activity from the request body, it does not support http method 'GET'.
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
Related
This question already has an answer here:
Legacy People API has not been used in project
(1 answer)
Closed 1 year ago.
Google API is active but give error ;
Legacy People API has not been used in project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project= then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
You don't need to install any other APIs like Google Drive API, Google Sheets API or other except Google+ API,
The error is coming because of "passport-google-oauth": "^1.0.0"
Just change the version "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0" and remove node_modules and package.lock.json file and run "npm i"
That's it
Before the Google+ API Shutdown on March 7, 2019, the people.get and people.getOpenIdConnect methods were available for requesting a person’s profile.
To avoid breaking existing integrations with these methods supporting sign-in, a new minimal implementation only returns basic fields necessary for that functionality, such as name and email address, if authorized by the user. The Legacy People API is where these methods will remain available for existing callers at the existing HTTP endpoints.
The Legacy People API serves a limited new implementation of the legacy Google+ API people.get and people.getOpenIdConnect methods necessary for maintaining sign-in functionality. It is available to existing callers of the original methods that haven't migrated to recommended replacements such as Google Sign-in or Google People API at the time of the Google+ API shutdown.
enter link description here
Thanks
In this case, I'm facing the same issue. This is what I've done to fix it.
Situation:
NodeJS ver 8
"passport-google-oauth": "^1.0.0"
Using Google+ API as Google Sign-in
When I run the apps and click Sign in with Google, what happened then?
Server error
Error log: Legacy People API has not been used in project "xxxx" before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=xxxx then retry.
How I solve it?
Go to Google Console
Click on Google+ API under Social APIs, then click Enable API
Click on Google Drive API under G Suite, then click Enable API
Click on Google Sheets API under G Suite, then click Enable API
Update "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0"
in package.json
remove package-lock.json and node_modules folder (to ensure everything is clear)
run this command : npm install
It works now!
Note: my previous code still using profile._json.image.url to get profile image. Actually, this response was not there anymore. So I delete this code.
Goodbye Google+
Thank you Google People API.
Enabling the Google Contacts API and the Google+ API fixed this issue for me.
Hi I recently stumbeled on the same issue. As explained by Ilan Laloum, Google+ API as been decommissionned completely for new projects.
I found that Google People API works in a similar way. The following example is based on the Bookshelf tutorial in GCP. Source code can be seen here: https://github.com/GoogleCloudPlatform/golang-samples/tree/appengine/go111/cloudsql/getting-started/bookshelf (branch appengine/go111/cloudsql)
import people "google.golang.org/api/people/v1"
...
// retrieves the profile of the user associated with the provided OAuth token
func fetchProfile(ctx context.Context, tok *oauth2.Token) (*people.Person, error) {
peopleService, err := people.NewService(ctx, option.WithTokenSource(bookshelf.OAuthConfig.TokenSource(ctx, tok)))
if err != nil {
return nil, err
}
return peopleService.People.Get("people/me").
PersonFields("names,coverPhotos,emailAddresses").
Do()
}
This method needs a context and a OAuth token, just like Google+ API used to. The peopleService is initialized in a similar fashion.
The peopleService.People.Get("people/me") prepares a query that fetches the profile of the connected user. Then PersonFields("names,coverPhotos,emailAddresses") is a filter on profile fields. This part of the request is mandatory. Eventually Do() will execute the request.
This issue can be fixed using the passport-google-token
npm install passport-google-token
const GoogleStrategy = require('passport-google-token').Strategy;
// Google OAuth Strategy
passport.use('googleToken', new GoogleStrategy({
clientID: CLIENT_ID,
clientSecret: CLIENT_SECRET
}, async (accessToken, refreshToken, profile, done) => {
try {
console.log('creating a new user')
const newUser = new User({
google: {
id: profile.id,
email: profile.emails[0].value
}
});
await newUser.save();
done(null, newUser);
} catch (error) {
done(error, false, error.message);
}
}));
I was also having the same issue but with my Rails app. So I resolved it by upgrading the omniauth gems by running bundle update devise omniauth omniauth-google-oauth2 in terminal.
I also faced the same issue. This issue may occur for using the old library, enable the google people Api for your project, and download the library as per your php version from this link and integrate it.
With https://portal.azure.com I managed to create a QnA Bot.
I also managed to send a message from the Bot Framework Emulator to MS Teams and the Test Web Chat of the bot. (Though it is very static and manually done as of now)
I get my Token from https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token. With that Token I can send a message to https://smba.trafficmanager.net/emea/v3/conversations/ConversationID/activities (which is Teams) and I can send a message to https://webchat.botframework.com/v3/conversations/ConversationID/activities (which is the Test Web Chat).
Little bit offtopic: Since I'm new to Azure I wonder if everything done so far is fine or completly false?
Anyway...
My goal so far is that when writing a message in the Test Web Chat the message should also end up in MS Teams. Then from Teams I want to answer to the message like #Bot This is my Answer. This Answer in Teams should then also end up in the Test Web Chat. (So basically communication between Teams and Web Chat)
What would be the best approach to do this?
I was thinking of a backend in Azure but I don't know what would be possible to use and if it's even possible.
My idea was:
A message is sent Web Chat. In Code I would upload the Web Chat Conversation Information to Azure. Also in Teams there is now the same message that was written in Web Chat. The Conversation ID in Teams also needs to be uploaded now and the Conversation ID the Web Chat is sending to needs to be updated (this would be needed so there is no spamming of new threads/messages in Teams from one Conversation and all the messages from this Web Chat Conversation are now in one thread.) Now to answer in the Conversation of the Web Chat via Teams I would write and send the answer. Before the sending of the answer happens I would need the Conversation ID from the Web Chat. So the Bot would download the information from Azure so it knows where it has to sent the answer to.
Is this a good apporach or do you know better ones? Also what ressources in Azure could I use to achieve this?
It sounds like you are thinking about this the right way. Basically you want to pair two conversation references - one in Teams and the other in Web Chat - together and then forward the messages between the two.
BotFramework SDK v4 (C#)
I would recommend creating two functions - AddConversationReferenceAsync and GetConversationReferenceAsync. In those functions, you should manage how you store, connect, and retrieve conversation references. You can check the channel Id - activity.ChannelId - to determine how you want to handle the reference. Then in OnMessageActivityAsync you can add and retrieve the corresponding conversation references to send a proactive message to the other channel.
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
AddConversationReferenceAsync(turnContext.Activity as Activity);
var conversationReference = GetConversationReferenceAsync(turnContext.Activity as Activity);
if (conversationReference != null) {
await turnContext.Adapter.ContinueConversationAsync(_appId, conversationReference, (ITurnContext context, CancellationToken cancellationToken) => {
await context.SendActivityAsync(turnContext.Activity);
}, cancellationToken);
} else {
await turnContext.SendActivityAsync("You are not connected to anyone at the moment");
}
}
Screen Capture
I would recommend looking at the BotBuilder Proactive Messaging sample, and #tompaana built a Hunan Handoff Bot sample that connects conversations in Teams and Slack that might be helpful.
Hope this helps!
I'm trying to test my outbound calling via Twilio, using my Twilio "test" credentials. It's an ASP.NET MVC 4 Web app that is hosting the endpoints for Twilio to hit. Since I'm running on localhost, they will be hit via ngrok (public endpoint that routes to your localhost).
I have configured a [toll-free] phone number in twilio where voice requests route to my ngrok url.
When I try to execute my test outbound call in my web app, I navigate to a test controller. It fires off some code that ends up executing this:
var call = _client.InitiateOutboundCall(
new CallOptions
{
From = "+1" + _fromPhone, // twilio toll-free phone number with base site/ngrok url configured, ie http://{ngrokcode}.ngrok.io
To = "+1" + phoneNumber, // phone that I want to "answer" and listen to the message
Url = url, // ngrok url that points to my localhost endpoint to play message, ie http://{ngrokcode}.ngrok.io/message/{forCustomerId}
IfMachine = "Continue"
});
In this call, the "_fromPhone" is the phone number that I have purchased/configured in twilio, the toll-free number, which is what routes to my ngrok url.
The "phoneNumber" is the phone that I want to call
The "url" is the endpoint that I want twilio to hit so it can "Say" the message to the recipient.
But, using these test credentials, the phone call never goes out. I accidentally ran this same thing, but using the production credentials, and the phone call DID go out (and started ringing on my cell phone), but when I answered, it was silent for about 15 seconds, then it finally said twilio encountered an error.
Looking at the logs for the accidental production call, it said it couldn't connect to my [ngrok] url.
So, two questions, why isn't the phone call getting executed when using my test credentials? And, if/when the phone call goes out, why isn't it executing/hitting my endpoint that contains my "Say" verbs?
Twilio developer evangelist here.
Test credentials are not used to make test calls, they are used to ensure that calls to the API are working as expected and will not generate calls themselves. The docs say:
When you authenticate with your test credentials, we will not charge your account, update the state of your account, or connect to real phone numbers.
As for when you made the call with your real credentials, there's more to look into here.
15 seconds is the timeout that Twilio will wait for when trying to connect to an endpoint. This suggests to me that ngrok was working and proxying the request but that your web application was hanging or taking too long to respond.
Can you hit your ngrok endpoints from a browser (or Postman or curl)? Is your web application logging anything that might help when you do access it? Does the ngrok dashboard (available at http://127.0.0.1:4040 when ngrok is running) give you any more insight.
Let me know and I'll update my answer with more suggestions.
I have successfully connected to Microsoft Graph using OAuth. I can receive and send emails from my Office365 account.
But I am completely stuck on how to receive emails automatically, similar to the IMAP IDLE routine.
I am referencing
using Microsoft.Graph;
using Microsoft.Toolkit.Services.MicrosoftGraph;
I have tried Subscription but have no clue what to do next, or even if this is correct.
Subscription sub = new Subscription {
ChangeType = "created",
NotificationUrl = "urn:ietf:wg:oauth:2.0:oob",
Resource = "/users/me/messages",
ExpirationDateTime = DateTimeOffset.Now.AddMinutes(20),
ClientState = "????" // if applicable, what is this
};
To make a subscription you need to expose a notification URL with https (see graph documentation).
POST https://graph.microsoft.com/v1.0/subscriptions
Content-Type: application/json
{
"changeType": "created,updated",
"notificationUrl": > "https://webhook.azurewebsites.net/notificationClient",
"resource": "/me/mailfolders('inbox')/messages",
"expirationDateTime": "2016-03-20T11:00:00.0000000Z",
"clientState": "SecretClientState"
}
If you want examples the graph documentation references a Node.js and asp.net example. Both use ngrok to expose an https URL (just for testing purposes though). The program tunnels HTTP requests through to your localhost (like a reverse proxy). If you have that setup, you have to validate your request. When you send your subscription request the first post message your notification URL will receive is a message with a validation token (see doc). You have to send this validation token back. Now you should receive notifications on your specified notification URL.
You can read about the Subscription resource type and its properties in the graph documentation.
For example, the client state is described as:
Specifies the value of the clientState property sent by the service in each notification. The maximum length is 255 characters. The client can check that the notification came from the service by comparing the value of the clientState property sent with the subscription with the value of the clientState property received with each notification.
Subscriptions are not in possible at this moment using Microsoft Graph for UWP, for notifications the Outlook 365 API should be used. The Microsoft graph api can be used for Auth and other tasks though.
Can Microsoft consider including streaming notifications in Microsoft Graph?
I have got a requirement,
When a work item is created (and status -say In progress) in TFS 2015(not vsts), I want my web hook to fire a post method which ll create a Channel in Slack, and invite few folks.
2) Once the Bug is closed - read all the history of channel and push the history back to Bug.
I was able to achieve the same with TFS server side plugin and it's working, but requirement got changed to Web hooks.
Could someone help me on how to achieve custom web hook.which ll enable events from TFS WI to Slack please?
Thanks,
You can not create new incoming webhooks in slack programmatically, but you can use any existing incoming webhook for a new channel.
Just add the channel property in your message to the webhook.
Example from the Slack documentation:
curl -X POST \
--data-urlencode 'payload={"text": "This is posted to #general and comes from *monkey-bot*.", "channel": "#general", "link_names": 1, "username": "monkey-bot", "icon_emoji": ":monkey_face:"}' \
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
So to implement your requirement I suggest you create a new channel and invite users as needed through the Slack web API. And then use an existing incoming webhook to send messages to that channel.
TFS has default slack service hook which can post a message to a channel. The API looks like below:
POST http://tfsserver:8080/tfs/DefaultCollection/_apis/hooks/subscriptions?api-version=3.2
Content-Type: application/json
{
"consumerActionId":"postMessageToChannel",
"consumerId":"slack",
"consumerInputs":{
"url":"https://hooks.slack.com/services/xxxxxx"},
"eventType":"workitem.created",
"publisherId":"tfs",
"publisherInputs":{
"areaPath":"",
"workItemType":"",
"projectId":"77e3c775-dc30-4354-xxxx-xxxxxxxxxxxx"}
}
For your second requirement, you need to check Slack Api to see how to read all the history of channel, and use Update work items to update Bug work items.