Skip to content

Latest commit

 

History

History
80 lines (57 loc) · 4.49 KB

File metadata and controls

80 lines (57 loc) · 4.49 KB
title description keywords author ms.author manager ms.topic ms.service ms.date
Connect a bot to Office 365 email - Bot Service
Learn how to configure bots to send and receive email messages by connecting them to Microsoft 365 email. See how to customize messages.
Office 365, bot channels, email, email credentials, azure portal, custom email
kamrani
kamrani
kamrani
article
bot-service
12/09/2019

Connect a bot to Office 365 email

[!INCLUDE applies-to-v4]

Bots can communicate with users via Office 365 email in addition to other channels. When a bot is configured to access an email account, it receives a message when a new email arrives. The bot can then respond as indicated by its business logic. For example, the bot could send an email reply acknowledging an email was received with the message, "Hi! Thanks for your order! We will begin processing it immediately."

Warning

It is a violation of the Bot Framework Code of Conduct to create "spambots", including bots that send unwanted or unsolicited bulk email.

Note

If you are using Microsoft Exchange Server, make sure you have enabled Autodiscover first before configuring email channel.

Configure email credentials

You can connect a bot to the Email channel by entering Office 365 credentials in the Email channel configuration. Federated authentication using any vendor that replaces AAD is not supported.

Note

You should not use your own personal email accounts for bots, as every message sent to that email account will be forwarded to the bot. This can result in the bot inappropriately sending a response to a sender. For this reason, bots should only use dedicated O365 email accounts.

To add the Email channel, open the bot in the Azure Portal, click the Channels blade, and then click Email. Enter your valid email credentials and click Save.

Enter email credentials

The Email channel currently works with Office 365 only. Other email services are not currently supported.

Customize emails

The Email channel supports sending custom properties to create more advanced, customized emails using the channelData property.

[!INCLUDE Email channelData table]

The following example message shows a JSON file that includes these channelData properties.

{
    "type": "ActivityTypes.Message",
    "locale": "en-Us",
    "channelID": "email",
    "fromName": { "id": "mybot@mydomain.com", "name": "My bot"},
    "recipientName": { "id": "joe@otherdomain.com", "name": "Joe Doe"},
    "conversation": { "id": "123123123123", "topic": "awesome chat" },
    "channelData":
    {
        "htmlBody": "<html><body style = /"font-family: Calibri; font-size: 11pt;/" >This is more than awesome.</body></html>",
        "subject": "Super awesome message subject",
        "importance": "high",
        "ccRecipients": "Yasemin@adatum.com;Temel@adventure-works.com"

    }
}

For more information about using channelData, see how to implement channel-specific functionality.

Other considerations

If your bot does not return a 200 OK HTTP status code within 15 seconds in response to an incoming email message, the email channel will try to resend the message, and your bot may receive the same email message activity a few times. For more information, see the HTTP details section in How bots work and the how to troubleshooting timeout errors article.

Note

If you are using an Office 365 account with MFA enabled on it, make sure you disable MFA for the specified account first, then you can configure the account for the email channel. Otherwise, the connection will fail.

Additional resources