Connect Rasa Bot to Microsoft Teams

I have a Rasa bot in local environment and exposed it with ngrok and it fails to connect to Microsoft Teams channel.

I am using the endpoint “https://xxxxxx.ngrok.io/webhooks/botframework/webhook

I have also created a Azure Active Directory app and provided the credentials in credentials.yml

Bot failed to get the token so I had to change the MICROSOFT_OAUTH2_PATH in botframework.py from

MICROSOFT_OAUTH2_PATH = “botframework.com/oauth2/v2.0/token

to following

MICROSOFT_OAUTH2_PATH = “my-default-directory-id/oauth2/v2.0/token”

No I can get the token but I am getting the following error

2019-11-16 12:28:50 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_0_MemoizationPolicy
2019-11-16 12:28:50 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2019-11-16 12:28:50 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'
2019-11-16 12:28:50 DEBUG    rasa.core.lock_store  - Deleted lock for conversation '29:1bdrGBPoUuSsfwaDEdPG8zaXweU5Iux9diwozFzVDIutP0Q73JpSUcq8FnjdHWCy45kkzzTlfUJ1YY2Yl2rKYjw'.
2019-11-16 12:31:05 DEBUG    rasa.core.tracker_store  - Recreating tracker for id '29:1bdrGBPoUuSsfwaDEdPG8zaXweU5Iux9diwozFzVDIutP0Q73JpSUcq8FnjdHWCy45kkzzTlfUJ1YY2Yl2rKYjw'
2019-11-16 12:31:05 DEBUG    rasa.core.processor  - Received user message 'hi' with intent '{'name': 'greet', 'confidence': 0.9369716644287109}' and entities '[]'
2019-11-16 12:31:05 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 6 events
2019-11-16 12:31:05 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'prev_action_listen': 1.0, 'intent_greet': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_greet': 1.0}]
2019-11-16 12:31:05 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2019-11-16 12:31:05 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_1_KerasPolicy
2019-11-16 12:31:05 DEBUG    rasa.core.processor  - Predicted next action 'utter_happy' with confidence 0.33.
2019-11-16 12:31:05 DEBUG    rasa.core.processor  - Action 'utter_happy' ended with events '['BotUttered(text: Great, carry on!, data: {"elements": null, "quick_replies": null, "buttons": null, "attachment": null, "image": null, "custom": null}, metadata: {})']'
2019-11-16 12:31:05 ERROR    rasa.core.channels.botframework  - Error trying to send botframework messge. Response: {"message":"Authorization has been denied for this request."}
2019-11-16 12:31:05 DEBUG    rasa.core.policies.memoization  - Current tracker state [{}, {'prev_action_listen': 1.0, 'intent_greet': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_greet': 1.0}, {'intent_greet': 1.0, 'prev_utter_happy': 1.0}]
2019-11-16 12:31:05 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2019-11-16 12:31:05 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'greet'.

I can see that the message is receiving and intent detection is done but it fails to send the reply. I have logged the post_message_uri, headers and message_data

2019-11-16 12:31:05 INFO     rasa.core.channels.botframework  - https://smba.trafficmanager.net/apac/v3/conversations/a:1znrD__jLTjxqUtCjNOnh14ogzQHXRnP-BuDrJ4Lk_FwUY7r-JiFBlPU6gnbw61cEK7GP-hwO3xewIbHMQZf1CHSkCXqcWhZkXnSKaKdTwPg3pMQuuTEO0B7Kjyuv-1Tj/activities
2019-11-16 12:31:05 INFO     rasa.core.channels.botframework  - {'content-type': 'application/json', 'Authorization': 'Bearer eyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2019-11-16 12:31:05 INFO     rasa.core.channels.botframework  - {'type': 'message', 'recipient': {'id': '29:1bdrGxxxxxxxxxxxxxxxxxxxxxx'}, 'from': {'id': '28:2087cxxxxxxxxxxxx', 'name': 'RasaTest'}, 'channelData': {'notification': {'alert': 'true'}}, 'text': 'Great, carry on!'}

I have added following permissions to my Azure Active Directory app

Delegated Permissions

  • User.Read
  • User.ReadAll
  • User.ReadBasic.All
  • User.ReadWrite.All
  • openid
  • profile

Application Permissions

  • User.ReadAll
  • User.ReadWrite.All

All the permissions have been granted admin consent but still it says Error trying to send botframework messge. Response: {“message”:“Authorization has been denied for this request.”}

How can I solve this?

1 Like

@ishan-anuranga am as well facing exact same issue. Did you resolve it?

@erohmensing any idea about this error?

@ishan-anuranga no luck for past 30 days. Just curious, did you resolve this issue?

@tmbo @erohmensing you guys have any one in mind who can help me here?

For those who comes here in future

Issue has been resolved.

Reason: I was using Rest APi with single tenant AAD application configuration.

Solution: Now converted that into multi-tenant AAD app based on this answer

Also change (or keep as it is ) the MICROSOFT_OAUTH2_PATH = “botframework.com/oauth2/v2.0/token” ;

can you explain this in a little more details please. I am having a similar Problem while trying to access Rasa moodbot on localhost. from Teams

Sorry, missed your question.

For debugging, we have modified few parameters such as MICROSOFT_OAUTH2_PATH in botframework.py.(rasa/botframework.py at master · RasaHQ/rasa · GitHub)

Please check the actual question for more details.

But finally i reverted back to whatever existed in botframework.py in the master branch.

Hey Vignesh,

Can you provide link which have details to integrate rasa in teams? I am new to rasa and dont know and struggling for last 2 days.

Sorry for the late reply @AshwaniT

I dont have any specific document for this setup. Let me narrate what i did as much as possible.

  1. Register the endpoint (http://domainname:5005/webhooks/botframework/webhook/) in Azure --> Bot Channels Registration.
  2. Link TEAMS in Channels option inside the Bot Channels Registration
  3. Note down the Microsoft App ID & pwd and use it in credentials.yml.
  4. Create an app in TEAMS using Manifest Editor