microsoft / BotFramework-Services

Microsoft Bot Framework Services
Creative Commons Attribution 4.0 International
38 stars 11 forks source link

ConversationParameters object needed to create conversation in Bot Service email channel #317

Closed bolleman closed 3 years ago

bolleman commented 3 years ago

I can't find any documentation on what the ConversationParameters object needs to look like in order to use the Bot Service Create Conversation with an email channel. Documentation says that the ChannelData object needs to be a "Channel-specific payload for creating the conversation.", but I'm guessing this is something other than the typical email channelData which is part of the activity object (which I've tried). As an example, I figured out through trial and error that in the case of a Teams channel, the ConversationParameters object needs to be: { "activity": { "text": "some message", "type": "message" }, "channelData": { "channel": { "id": "<teamsChannelId>" } }, "isGroup": true } If someone has a similar example of one that works for creating an email conversation that would be awesome, thanks!

Jeffders commented 3 years ago

To proactively create conversations in the bot to send email to a user, you'll want to use these fields on the ConversationParameter object:

For the email channel, the fields that are used by this API call are:

{
    "activity": { "text": "some message", "type": "message" },
    "members": [
        { "id": "...email address...", "name": "... friendly name..." }
    ]
} 
bolleman commented 3 years ago

Thanks for the quick response @Jeffders!

Your exact payload (except with a real email address) generated the following error:
"code": "MissingProperty", "message": "'bot' is required"

However, the error message was nice and specific, so I just added the bot property according to the docs and it worked great. The entire working payload ended up being as follows, for anyone else trying to do the same thing:

{
    "bot": {
      "aadObjectId": "e283adf........",
      "id": "bot@wni.app",
      "name": "WNI Bot",
      "role": "bot"
    },
    "activity": {
      "text": "some message",
      "type": "message"
    },
    "members": [
      {
        "id": "brent@wni.app",
        "name": "Brent Email"
      }
    ]
  }

That just saved me a huge amount of time, I really appreciate the help.

MichaelHaydenAtMicrosoft commented 3 years ago

Great work, @Jeffders!! @Bolleman - is there anything further you may need here or can we close this issue?

bolleman commented 3 years ago

@MichaelHaydenAtMicrosoft Oh yes, my bad, I should have closed. Thanks again.