How to send email by the chatbot through Builder May 26, 2023 20:26 Updated Index: What is my chatbot’s mail How to send an email using Builder How do I send an email using one of the SDKs? Sending an email is a common task for anyone developing a bot. Control emails, alerts or confirmation of information are some common scenarios for this demand. Blip abstracts the entire process of sending and receiving emails to your bot. What is my chatbot’s mail At Blip, every chatbot already has an email automatically. This email is always formed by the bot identifier + @blip.bot. For example, a bot created with the identifier mailgun, will have an email mailgun@blip.bot. To find out exactly what your bot's email is, access the Channels > Email module on the Portal. How to send an email using Builder Sending an email using Builder is very simple, just make an HTTP request to the internal API of Blip. Before sending the email, think about the best moment of the conversation flow to do this operation. For example, let's imagine that your chatbot collects information from potential leads in a company. At some point in the flow you will need to send content in exchange for information from users. This is an interesting time to send an email. After defining at which point of the flow the email will be triggered, access the corresponding block and create an HTTP Request action (input or output, according to its context) for the Blip API with the following information: To find out where to find your bot's API key click here. Name of the action: Sending email confirmation Request method: POST URL: https://{{contractid}}.http.msging.net/messages Note: Use the url with the contract id to consume the endpoints reported below, its performance and operation may be impacted if it does not have the contract id, so it is essential to use the url with the contract id to use http requests! Header: Key: Authorization Value: Key API-KEY-BOT Text: JSON with a message, according to the LIME protocol, with the desired content type. { "to":"xpto%40xpto.com@mailgun.gw.msging.net", "type":"text/plain", "content":"Hello {{contact.name}}, you can access the ebook through the link {{link}}"} Note that the addressee of the email must be informed in the JSON to field that will be sent to the Blip API (highlighted in blue). In this example, the addressee's email is: xpto@xpto.com. As every LIME Node has the @ character, it is necessary to replace the @ in the email with its corresponding ASCII code (% 40). In addition to the addressee's email, you need to identify the email channel (@mailgun.gw.msging.net), so that Blip knows how to send your message correctly. To send an email to abcdef@foo.bar the JSON to field will be: abcdef%40foo.bar@mailgun.gw.msging.net In addition to assembling the message that will be sent by email and its respective recipient, you will also need the API-KEY-BOT. Note: The e-mail channel currently supports only the text content type. How do I send an email using one of the SDKs? To send an email through one of the Blip SDKs is very easy, just send a message, as the example below. Remember to replace the field with the addressee's email. Example: Sending an email to xpto@xpto.com with the content "Hello World": SDK JS client.sendMessage({ id: Lime.Guid(), type: "text/plain", to: "xpto%40xpto.com@mailgun.gw.msging.net", content: "Hello World"}); SDK C# using System;using System.Collections.Generic;using System.Threading;using System.Threading.Tasks;using Lime.Messaging.Contents;using Lime.Protocol;using Take.Blip.Client;//Replying a received message with a simple text message.public class PlainTextMessageReceiver : IMessageReceiver{ private readonly ISender _sender; private readonly Settings _settings; public PlainTextMessageReceiver(ISender sender, Settings settings) { _sender = sender; _settings = settings; } public async Task ReceiveAsync(Message message, CancellationToken cancellationToken) { var document = new PlainText {Text = "Welcome to our service! How can I help you?"}; await _sender.SendMessageAsync(document, Node.Parse("xpto%40xpto.com@mailgun.gw.msging.net"), cancellationToken); }} For more information, visit the discussion on the subject in our community or the videos on our channel. 😊 Related articles Finding my bot's API-KEY How to interact with users through email Builder variables What is WhatsApp Flows? Active Messages - Error Codes