Sending Emails From Your Bot


Use Dexter’s HTTP Post Request combined with SendGrid’s API to easily send email to your bot users.


+ (yes|confirm)
- Okay, sending your email! {@ sendemail}
+ no
- Okay, say yes if you want to send.
+ sendemail
$ POST {"headers":{"Authorization":"Bearer <<YOUR_API_KEY>>","Content-Type":"application/json"},"body":{"personalizations":[{"to":[{"email":"EMAIL@EMAIL.COM"}],"subject":"Subject Line"}],"from":{"email":"Email Content"},"content":[{"type":"text/plain","value":"<get body>"}]}}
- Email sent!


You’ll need a Web API v3 key from SendGrid. You can generate an API key in your SendGrid account. Replace <<YOUR_API_KEY>> with your generated key.

You can use any email address to replace EMAIL@EMAIL.COM, capture a bot user’s email address in the conversation flow, or use the email address in the _userEmail namespace variable pulled for you from the bot user’s profile.

Replace Subject Line and Email Body with whatever content you like--just be careful of certain characters. You can also check out our snippets for Capturing Message Content and User Emails from a bot user to send user-generated emails.