Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate Dialogflow with Microsoft Teams. #43

Open
revs1 opened this issue Aug 3, 2020 · 40 comments
Open

How to integrate Dialogflow with Microsoft Teams. #43

revs1 opened this issue Aug 3, 2020 · 40 comments

Comments

@revs1
Copy link

revs1 commented Aug 3, 2020

As I have noticed in official document, Teams integration is not part of built in integrations supported by Google. It being an independent integration, can someone help me with trusted third party organization to do the same?

@mekpavit
Copy link

mekpavit commented Aug 3, 2020

@revs1 I did integrate the Dialogflow with Microsoft Teams about 4 months ago using the same approach as Skype., I think it is still working now. Have you tried integrating using the Skype approach mentioned here. The key is that Dialogflow does not directly connect to Microsoft Teams, instead, it connects to Azure Bot Service and you integrate Azure Bot Service with Microsoft Teams channel just like this.

@cah-prashanth-soma
Copy link

@mekpavit
What will be the messaging endpoint configuration for the server.js. I am unable to access the bot from the Microsoft bot framework channel TEST.

I have tried appending both "/webhook" and "/api/messages" to the cloud function URL https://xxxxxxxx.cloudfunctions.net/TeamsChannel

I am trying to integrate teams. I have followed the documentation for skype open source. But, instead of docker containers i am using cloud functions to deploy the server.js. (org level restrictions on docker).

@mekpavit
Copy link

mekpavit commented Aug 12, 2020

@cah-prashanth-soma Have you tried using the Cloud Function url with adding any suffix? If you have, did you get any incoming request to your Cloud Function? I've never used Cloud Function for hosting the webhook before, but I think it should work.

@cah-prashanth-soma
Copy link

thanks. if you meant without suffix? yes I did. And nothing is logged. Nothing is getting hit.

@mekpavit
Copy link

mekpavit commented Aug 13, 2020

@cah-prashanth-soma I've already tested dialogflow-integration with Azure Bot Service. It did work but it requires some changes on server.js since the Cloud Function works with only some project structure. Here is what I did:

  1. Move botlib folder to be in skype.
  2. Update importing statement in skype/server.js to refer to the new location of botlib. For example, you have to change const protoToJson = require('../botlib/proto_to_json.js'); to const protoToJson = require('./botlib/proto_to_json.js'); (remove one dot).
  3. Remove this code block because it will cause an error when the function is running
const listener = app.listen(port, () => {
  console.log('Your Skype integration server is listening on port '
      + listener.address().port);
});
  1. change this code block:
module.exports = {
  convertToSkypeMessage
};

to this (Cloud Function can only access to the exported class/function from a .js file declared in main field of package.json):

module.exports = {
  convertToSkypeMessage,
  app
};
  1. Deploy to the Cloud Function with nodejs12 runtime, app entry point and service account that you created according to the instruction. For example,
gcloud functions deploy you-function-name --runtime nodejs12 --service-account=some-service-acount-email@some-project-id.iam.gserviceaccount.com --entry-point app --trigger-http

@cah-prashanth-soma
Copy link

@mekpavit, it works. I thank you profusely for your quick and detailed response. Point 4 did the magic for me. (I have already implemented point 1 and 2 and redirected 3 to other port, but I was using convertToSkypeMessage as entry point ).

@mekpavit
Copy link

@cah-prashanth-soma You're welcome!!

@preethamjv
Copy link

@mekpavit what is the messaging endpoint for cloud run? I have set mine to https://skype-xxxxxxxxxx-uc.a.run.app, But my dialogflow intents still do not show up on Azure bot. can you pls help?

@mekpavit
Copy link

mekpavit commented Mar 8, 2021

@mekpavit what is the messaging endpoint for cloud run? I have set mine to https://skype-xxxxxxxxxx-uc.a.run.app, But my dialogflow intents still do not show up on Azure bot. can you pls help?

@preethamjv Can you show your Cloud Run log? I want to ensure that the Microsoft Bot Service can't access your Cloud Run.

@preethamjv
Copy link

@mekpavit I get a series of error messages in my logs
image
image
image

@mekpavit
Copy link

mekpavit commented Mar 8, 2021

@mekpavit I get a series of error messages in my logs
image
image
image

According to the logs, it looks like you misconfigure the microsoft secret. Can you show me your server.js file? Maybe take a screenshot around here:
Screen Shot 2564-03-08 at 19 20 23

@preethamjv
Copy link

@mekpavit Thanks for your quick follow-up, here is the screenshot
image
image

@mekpavit
Copy link

mekpavit commented Mar 8, 2021

@preethamjv Okay, you already set the appId and appPassword. Could you check whether the appId and appPassword in server.js are correct? (1. Is it really the appId of your chatbot? 2. Is the appId match the appPassword)

@preethamjv
Copy link

preethamjv commented Mar 8, 2021

@mekpavit I have checked the app id and password, it was correct. I redeployed the code into a new cloud run service, it worked!
Adding the missing steps in documentation:
On dialogflow webhook fulfillment section, we need to give the MS Azure endpoint URL:
image

In the Azure bot configuration section, replace the existing MS Azure endpoint URL with the URL of the Cloud Run service that we have created.
image

Hope this helps someone!

@mekpavit thanks for your quick response!

@preethamjv
Copy link

@mekpavit just wanted to check, can we add google calendar schedule(book a slot) feature into this integration? Pls give your inputs, thanks in advance!

@mekpavit
Copy link

mekpavit commented Mar 10, 2021

@mekpavit just wanted to check, can we add google calendar schedule(book a slot) feature into this integration? Pls give your inputs, thanks in advance!

I'm not sure if I really understand your feature. if I guess, it might be one of this:

  1. When someone ask your chatbot to setup a meeting, you chatbot schedule a meeting on Google Calendar:
  • IMO, this integration app should only concern about how to integrate between various messaging platform and Google's Dialogflow. If you want to add a feature like this, it might be better to add it in your bot handler app.
  1. When someone schedule a meeting on the bot's Google Calendar, it triggers the Google's Dialogflow intent based on some properties on the meeting.
  • This is possible since the Google Calendar API has a feature that let's an application watch for a change in a calendar. If this is what you want, you can take a look about the Google Calendar API here and develop the feature on this repository.

@ExceptionXD
Copy link

@revs1 I did integrate the Dialogflow with Microsoft Teams about 4 months ago using the same approach as Skype., I think it is still working now. Have you tried integrating using the Skype approach mentioned here. The key is that Dialogflow does not directly connect to Microsoft Teams, instead, it connects to Azure Bot Service and you integrate Azure Bot Service with Microsoft Teams channel just like this.

Hi, is there any video tutorial for the same, I am facing issues.

@mekpavit
Copy link

mekpavit commented Apr 7, 2021

@ExceptionXD What's the issues you're facing?

@ExceptionXD
Copy link

@mekpavit So I followed all the steps and also got the URL but when i am keeping that as my messaging endpoint and testing web chat I am getting the following error :
There was an error sending this message to your bot: HTTP status code Unauthorized

@mekpavit
Copy link

mekpavit commented Apr 8, 2021

@mekpavit So I followed all the steps and also got the URL but when i am keeping that as my messaging endpoint and testing web chat I am getting the following error :
There was an error sending this message to your bot: HTTP status code Unauthorized

Where did you get this error message? From Microsoft Teams web chat or from the logging page on GCP?

@ExceptionXD
Copy link

@mekpavit on Microsoft Team web chat

@mekpavit
Copy link

mekpavit commented Apr 8, 2021

@mekpavit on Microsoft Team web chat

So, the situation is that, when Microsoft Teams sends a HTTP request to your Cloud Run application, it responses back with 401 status code. One possibility that can be the root clause is that "allow unauthenticated invocations" setting on your Cloud Run application is set to "no".

Could you confirm that, when you deploying using gcloud beta run deploy command, you answer "y" when it is prompted to allow unauthenticated invocations?

@ExceptionXD
Copy link

Yes I had given 'y' as my response

@ExceptionXD
Copy link

@mekpavit the msg endpoint which i got, I am placing that in my web chat bot -> configurations -> messaging endpoint and then testing. This is what is mentioned right ?

@ExceptionXD
Copy link

Hey @mekpavit , @preethamjv has mentioned that " I have checked the app id and password, it was correct. I redeployed the code into a new cloud run service, it worked!
Adding the missing steps in documentation:
On dialogflow webhook fulfillment section, we need to give the MS Azure endpoint URL:"

so do i need to do this ?

@cah-prashanth-soma
Copy link

Well..

  1. Cloud run service end point URL has to be plugged in Bot framework messaging end point (configuration section)
  2. if you have a cloud function that has the webhook handling functionality .. you can mention its trigger URL On you dialogflow webhook fulfillment section.

@ExceptionXD
Copy link

From where to get MS Azure end point URL ?

@mekpavit
Copy link

mekpavit commented Apr 9, 2021

@ExceptionXD Okay, so, 401 response does not come from Cloud Run authentication. Cloud you show your application logs on Cloud Run? I want to confirm that whether the 401 response was from BotFrameworkAdapter or not.

@ExceptionXD
Copy link

Screenshot (50)
Screenshot (51)

@mekpavit
Copy link

mekpavit commented Apr 9, 2021

@ExceptionXD Ok. According to the logs, it seems like the service account of your application does not have a permission to use Dialogflow. Could you confirm that you've done "Service Account Setup (GCP)" section here. If you've already done this, please show the screenshot of IAM page on your GCP console, so I can ensure that you give the right permission to the service account.

@ExceptionXD
Copy link

Screenshot (52)
Screenshot (53)
@mekpavit the second image has the permissions which are granted to me

@ExceptionXD
Copy link

@mekpavit I am using DialogFlowCX, so is the integration process different ?

@mekpavit
Copy link

mekpavit commented Apr 9, 2021

@ExceptionXD After reading the API document of both Dialogflow ES and CSV, the API specification seems different (at least, the end point is different). Since this integration application only supports Dialogflow ES, I think you cannot use Dialogflow CX here.

BTW, there is one thing you can try. You can try changing the library used in botlib/dialogflow_session_client.js from dialogflow to dialogflow-cx instead. Since the API exposed by these two library is almost identical, I think just changing the package name would be fine.

@kyooi2
Copy link

kyooi2 commented Sep 23, 2021

image

Hi @mekpavit, I follow the msteams integrations using cloud run, but facing the issue above. Can you assist to help?

@mekpavit
Copy link

mekpavit commented Sep 23, 2021

@kyooi2 Hi. According to your logs, the response object doesn't have response.payload.fields.skype field. So, when convertToSkypeMessage tried to get that field's value to convert to a valid MSTeam response, it encountered Cannot read property 'structValue' of undefined error.

https://github.com/GoogleCloudPlatform/dialogflow-integrations/blob/master/skype/server.js#L148-L152

I would suggest you to find out why Dialogflow responded you back with that response object. Do you use a webhook or just Dialogflow to process a message?

  • If you use your own webhook, you can easily fix the HTTP response to Diagflow to include payload.fields.skype field
  • If you use only Dialogflow, you might need to find a way to transform the HTTP response body to include payload.fields.skype field
  • If none of these works, it's possible that Dialogflow already changed the structure of HTTP response body payload. You might need to change line#150 on server.js.

https://github.com/GoogleCloudPlatform/dialogflow-integrations/blob/master/skype/server.js#L150

@kyooi2
Copy link

kyooi2 commented Sep 24, 2021

@mekpavit Hi. I think i found out the things that i have missed out. I forgot to add in the response for skype, so when it route back to default response, it will take the default payload. This is what I encounter for the error. Thanks alot for helping.

image

@olivomarco
Copy link

Hi. Using knowledge from this issue I have recently created this repo where I have put all code and instructions needed to integrate bots in DialogFlow with Microsoft Teams.
HTH

@AdityaSinghania93
Copy link

Hello @mekpavit
Hope you doing great.
I am trying to integrate Google Dialog Flow with MS Teams but could not complete it.
I have created Google dialog Flow intents ( request & response ).
Created Azure Service Bot also & also followed the below link in order to compete the integration but it does not work.
I don't receive any response on MS teams platform the response that i have written in my Google Dialog flow.

https://github.com/olivomarco/dialogflow-teams-integration
If you can help me set up the integration of Google Dialog Flow with MS teams.
Almost 90 % work is completed not sure what is causing the error.
If you have any step by step to follow, if you can share it it will be big help also

@ghchinoy
Copy link

ghchinoy commented Mar 1, 2023

@shahilnissam
Copy link

shahilnissam commented Sep 23, 2023

Has anyone got this gateway timeout issue for dialogflow cx integration with Azure bot service?
https://github.com/GoogleCloudPlatform/dialogflow-integrations/tree/master/cx/azure-bot-service
All env keys are correct as per the instructions.. but I still get this error.

**September 23, 2023 at 9:53 PM GMT+5:30
There was an error sending this message to your bot: HTTP status code GatewayTimeout
ca12f4b87b1ba4ae040098b5904c62e6
**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants