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

Service error 'Unknown' when attempting to send a (non-reply) message #260

Closed
penguinsource opened this issue Oct 15, 2020 · 11 comments
Closed
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Required for internal Azure reporting. Do not delete. Do not change color. customer-reported As opposed to development work item.

Comments

@penguinsource
Copy link

Hi!

I am using the Bot Framework Rest API with Node. I am successfully sending reply messages upon a user sending a message (in MS Teams).

I am now trying to start a conversation, to which the response comes back successful, with a conversation id.
( POST /v3/conversations returns me an id - great!)

Then, I try to send a message to that conversation id and I keep getting Service error 'Unknown'. I have tried everything..

Get token function (works fine)
image

Create a conversation (works fine)
image

Using the conversationId above, send a message (Not working):
image
image

I am following the documentation provided:

https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#create-conversation

Step 1, create a conversation:
image
image

Step 2, send message using conversation id from above:
image

@stevkan stevkan added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-reported As opposed to development work item. labels Oct 15, 2020
@penguinsource
Copy link
Author

penguinsource commented Oct 15, 2020

Pretty please halp? Sending an activity is failing.. seems like an integral part of the service as a whole which isn't replaced in any way by the Graph API :(. Is this not a critical failure? Am i doing something very wrong? Because I've gone over this documentation over and over and not only is it impossible to know which APIs to use anymore, but it's not working 👎

Thanks @stevkan for the labels.

@dmvtech
Copy link

dmvtech commented Oct 15, 2020

Hi @penguinsource

That's all the error/information you get? (ServiceError). In the bot registration in Azure portal; do you see any further information/error message/help in the Channels blade for Teams? For example, something like:
image

@penguinsource
Copy link
Author

penguinsource commented Oct 15, 2020

Hi @dmvtech! Sorry to be a noob about Azure but I'm not sure how to get to that page. Is it around here somewhere:
image

I don't see Teams in the blade options:

image

@dmvtech
Copy link

dmvtech commented Oct 15, 2020

So, when you create a bot resource (either a Bot Channels Registration or a Web App Bot), it will create a App Registration (an AAD app), but it is itself also another resource type (Microsoft.BotService/botServices) of it's own. You should be able to see any/all by going here.

These types of resource have a blade called Channels where you can configure the channels that are allowed/setup for this bot to use.

image

More info:
https://docs.microsoft.com/en-us/azure/bot-service/abs-quickstart?view=azure-bot-service-4.0

@MichaelHaydenAtMicrosoft MichaelHaydenAtMicrosoft added the customer-replied-to Required for internal Azure reporting. Do not delete. Do not change color. label Oct 15, 2020
@penguinsource
Copy link
Author

penguinsource commented Oct 16, 2020

I don't have any errors logging in the My Bots webpage:

image

And I retried a few more calls and it's the same issue - I get the conversation id successfully but I get the service error upon sending an activity.

I am going to go through a full flow of the following tasks:

  1. Send a message in teams, receive the interactive request on the server
  2. Get the variables from the interactive request + save them
  3. Create a conversation and then send an activity/message

Here we go:

  1. My server side code receiving interactive request:
    image

Here is a sample incoming request:

image

Now that you know these values are valid, I am going to use the bot id, bot name, user id and user name to create a conversation and then send a non-reply message/activity:

image

Now the code for sending a message/activity:

image

And now the actual code output when I run it - conversation gets created successfully, but sending an activity fails 👍

image

Further information that may be useful.. here is the function that successfully creates a token (default scopes set in the app):

image

API Permission set for this bot application (yes, I set a whole lot of them as I was playing with the graph api):

image

After doing a bunch more of these requests, i still see no warnings on the MS Teams bot channel page.

Any ideas on what I could try next?

Thanks!
Mihai

@EricDahlvang
Copy link
Member

Hi @penguinsource

Can you share a repro project, without the keys and secrets? We cannot copy/paste the screenshots.

By looking at your screenshots, I'm surprised the calls are able to generate a conversation.id. I thought the Teams channel requires TenantId for this call, as is done here: https://github.com/microsoft/botbuilder-js/blob/main/libraries/botbuilder/src/botFrameworkAdapter.ts#L484

A few things to check:

Hope this helps! What you are doing is definitely possible. I think we just have not documented exactly how to accomplish this from the Teams channel specifically.

@dmvtech
Copy link

dmvtech commented Oct 20, 2020

hi @penguinsource Thanks for the info.

Lots of good info/suggestions from @EricDahlvang, as usual. I can try and see if I can set up something similar, but as Eric suggested if you can share a sanitized repro, then that might expedite things a bit.

@penguinsource
Copy link
Author

penguinsource commented Oct 20, 2020

@dmvtech @EricDahlvang thank you very much for your input - I really appreciate it! A few pressing issues have come up on my side but I'm going to go through your suggestions asap by the end of the week and post updates here!

@MichaelHaydenAtMicrosoft MichaelHaydenAtMicrosoft removed their assignment Oct 20, 2020
@penguinsource
Copy link
Author

penguinsource commented Oct 22, 2020

Hi @EricDahlvang , I updated the service url to https://smba.trafficmanager.net/amer when creating a conversation and it responds with bad format of conversation id - i added the tenant id and now creating a conversation and sending a message works (aweeeeeeeeeeeesomeeeeeeeee)!!!

You can create a conversation id using https://smba.trafficmanager.net/api without a tenant id which you should not do (or should not do for the purpose of sending a message, anyhow).

I really thought I switched them out before but I guess I never got both calls to use the /amer endpoint. Thank you!!

The REST documentation should be updated to reference https://smba.trafficmanager.net/amer instead of https://smba.trafficmanager.net/api. It uses the /api endpoint everywhere in the 'Connector' section:

image

Documentation: https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-authentication?view=azure-bot-service-4.0

Here is a link to a very basic sample repo with some hard-coded values for my bot and user name for reference in case others want to use it - https://github.com/penguinsource/ms-teams-bot/blob/master/index.js

I will update it/clean it up a bit

@penguinsource
Copy link
Author

penguinsource commented Oct 22, 2020

Since I have a knowledgeable audience about this product in this topic, I might as well ask - I could not find a way to do this with the Graph API, at least not with any documentation pointing to initiating a conversation with a user.

Is it possible?

Is this Bot Framework API going to be deprecated in favor of the Graph API?

If yes, do you know if there are any plans of updating the Graph API to support this workflow?

And last but not least, where do I set up the API permissions for the bot framework? I've been digging through documentation and I'm still quite lost :(

My application is going to consist of a business signing up for my platform.

  • The business authorizes the use of Microsoft Teams (company authorization)
  • Then, every user belonging to that business can then allow my bot to message them privately (individual authorization)

Do you have any tips on how to go about setting up permissions and authorizations that you could point me towards?

Thank you very much again!
Mihai

@dmvtech
Copy link

dmvtech commented Oct 22, 2020

Hi @penguinsource Thanks for the follow up!

The REST documentation should be updated to reference https://smba.trafficmanager.net/amer instead of https://smba.trafficmanager.net/api. It uses the /api endpoint everywhere in the 'Connector' section

I think the documentation is aimed to be more generic and mostly focused on Direct Line and not for the intricacies of using Teams. Additionally, i'm not sure if /amer is going to be a global fix, as I'm guessing it probably depends on the regional location of the resources (my assumption is /amer is Americas). @EricDahlvang any input here?

Also; you can always suggest a change to the documentation from the GitHub link on the bottom of the page.

I could not find a way to do this with the Graph API, at least not with any documentation pointing to initiating a conversation with a user. Is it possible?

No, unfortunately not.

Is this Bot Framework API going to be deprecated in favor of the Graph API?

Not that we are aware of at this point.

And last but not least, where do I set up the API permissions for the bot framework? I've been digging through documentation and I'm still quite lost :(

I guess this depends on what permissions you are talking about exactly (there is a lot of them and a lot going on). When you create a bot there is the app registration that gets created that sets up the basics for authentication through the bot framework service and the multiple channels. Secondarily, you have to configure the channels and there are permissions for that as well.

The business authorizes the use of Microsoft Teams (company authorization) Then, every user belonging to that business can then allow my bot to message them privately (individual authorization) Do you have any tips on how to go about setting up permissions and authorizations that you could point me towards?

Ah, I believe you will want to look into some of the OAuth samples we have. I think this will get you started in the right direction.
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/18.bot-authentication
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/24.bot-authentication-msgraph
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/46.teams-auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-replied-to Required for internal Azure reporting. Do not delete. Do not change color. customer-reported As opposed to development work item.
Projects
None yet
Development

No branches or pull requests

6 participants