NAV Navbar
C# JavaScript HTTP
  • Introduction
  • Concepts
  • Authentication
  • Getting Started
  • Content Types
  • Extensions
  • Integrations
  • Introduction

    Welcome to BLiP Docs😊!

    In this documentation, you will be introduced to the most important platform's concepts so you can explore all the power of BLiP!

    The main goal of BLiP Docs is to provide technical development knowledge on the BLiP platform and present various code samples.

    Here, you will find code samples on the right side for each subject. The samples are presented in C#, JavaScript and as a generic HTTP request that you can use in your favorite programming language. In the left side menu, you will find a step-by-step guide for each big subject on BLiP.

    Essential information:

    Concepts

    BLiP allows conversational applications (here also called chatbots, intelligent contacts, smart contacts, or just bots) to be built only once and be made available through different messaging channels, such as Messenger, WhatsApp, SMS, Email, Skype, Workplace, BLiP Chat (BLiP's channel for web, Android and iOS), and others (click here to see all available channels).

    There are basically 3 differents ways to create a chatbot using BLiP.

    Integrations are external APIs connected to BLiP in order to reduce your work to use these applications. Some of BLiP's integrations include: Chatbase, RD Station and PagSeguro(click here to see all available integrations).

    Extensions are internal APIs that encapsulate common functionalities used in message applications. Some of BLiP's extensions include: broadcasting, scheduling, simple databases, chat history and many others (click here to see all available extensions).

    Every content sent or received by BLiP's APIs and any communication between chatbots and their clients use LIME protocol definitions. LIME Protocol (acronym for Lightweight Messaging Protocol) is an open source JSON based protocol for messaging, maintained by BLiP's team and inspired by the XMPP protocol. It aims to be simple but extensible, with little verbosity yet providing good readability. The envelopes are information containers defined by the protocol and can be messages, notifications or commands, sent in JSON format.

    Addressing

    All the envelopes (messages, notifications and commands) exchanged between bots and their customers in BLiP have from and to addresses.

    The address (also called as Node) is presented in the format name@domain/instance, where:

    See below samples of different addresses (or Node):

      //WhatsApp Node - where '551199991111' is the user identifier
      "551199991111@wa.gw.msging.net"
    
      //BLiP Chat Node - where '0mn.io' is the BLiP Chat domain identifier
      "df83582a-87b9-45b4-9e76-d4a4a743e2a6@0mn.io"
    
      //Messenger Node
      "213681763812763812@messenger.gw.msging.net"
    

    Usually, the interaction between a chatbot and a customer starts after the message, which has a from address, is received. In this case, it is only necessary to answer to this address - in an unchanged way, in order to guarantee the message's delivery.

    The addresses may have different life cycles depending on the channels, they can be scoped – valid in some conditions (as in Messenger, where the address is only valid for a specific originator) or persistent, always valid (in SMS and WhatsApp). The chatbots must take these characteristics in consideration to build the interactions. For more details, check the LIME protocol specification.

    Channels

    Channels are message nets connected to BLiP in which the chatbots are able to send and receive messages to these nets' customers. Each channel has an identifier used for addressing which is normally a FQDN. This identifier appears after the @ in the nodes address.

    Each channel (or messaging application) has a unique set of features. Besides unify all of these channels into a single API, BLiP also adapt automatically any content to these unique feature sets.

    This means that you can respond to a user with message like a menu without consideration for the features of that channel. If the user is on Facebook or any other channel that supports this content type, the message will appear to the user as a menu, but on a channel like Whatsapp the menu will fall back to a text messages. It's also possible to customize this behaviour as you desire.

    In order to send or receive messages to a channel, the chatbot must be published on it. The publishing is done through the portal, which may request specific information that helps to identify the chatbot in this channel, such as API tokens for example. Usually, previous registration is necessary in each channel, through a specific tool, before publishing.

    The following channels are available in BLiP platform:

    Name FQDN
    BLiP Chat 0mn.io
    Tangram (SMS) tangram.com.br (deprecated)
    Take.IO (SMS) take.io
    Facebook Messenger messenger.gw.msging.net
    WhatsApp wa.gw.msging.net
    Skype skype.gw.msging.net
    Telegram telegram.gw.msging.net
    Workplace workplace.gw.msging.net
    Email mailgun.gw.msging.net
    PagSeguro pagseguro.gw.msging.net

    For more information about any channel, check the Integrations section.

    Messages

    See below the representation of a message:

      var message = new Message
      {
          Id = "65603604-fe19-479c-c885-3195b196fe8e",
          From = "551199991111@0mn.io/182310923192",
          To = "mycontact@msging.net",
          Content = new PlainText
          {
              Text = "Hello World"
          }
      };
    
    var message = {
      id: "65603604-fe19-479c-c885-3195b196fe8e",
      from: "551199991111@0mn.io/182310923192",
      to: "mycontact@msging.net",
      type: "text/plain",
      content: "Hello World"
    }
    
    {
      "id": "65603604-fe19-479c-c885-3195b196fe8e",
      "from": "551199991111@0mn.io/182310923192",
      "to": "mycontact@msging.net",
      "type": "text/plain",
      "content": "Hello World"
    }
    

    A message allows content exchange between clients and chatbots.

    Each message has:

    For more information, check the LIME protocol specification.

    Sending messages

    In order to send messages and notifications use an instance of `ISender` (on C#), which is automatically injected on constructors of registered `receivers` defined on project and on the `Startup` class.

    //reply a received message sample
    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)
        {
            // Write the received message to the console
            Console.WriteLine(message.Content.ToString());
            // Responds to the received message
            _sender.SendMessageAsync("Hi. I just received your message!", message.From, cancellationToken);
        }
    
    }
    

    It's possible send notifications and messages only after sessions has been stablished.

    //send a message after connection has been stablished sample
    client.connect()
        .then(function(session) {
            // After connection is possible send messages
            var msg = { type: 'text/plain', content: 'Hello, world', to: '553199990000@0mn.io' };
            client.sendMessage(msg);
        });
    

    For this sample bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ is a valid Key. You must to change this key

    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Length: 131
    
    {
        "id": "123e4567-e89b-12d3-a456-426655440000",
        "to": "551100001111@0mn.io",
        "type": "text/plain",
        "content": "Hello, how can I help you?"
    }
    

    The process of sending message is asynchronous and the status of sent messages is delivered to application by notifications.

    For more information about messages, check the messages section or the supported content types specification.

    Name Description
    id Unique identifier of the message
    from Originator’s address
    to Recipient’s address
    type Statement with content type, in the MIME format
    content Message content

    Receiving messages

    The receipt of messages is done using the interface IMessageReceiver.

    //A `IMessageReceiver` can be defined as follows
    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)
        {
            // Write the received message to the console
            Console.WriteLine(message.Content.ToString());
        }
    
    }
    

    All messages sent to the chatbot are redirected to registered receivers of messages. You also can define filters to each receiver.

    //add simple message receiver example
    client.addMessageReceiver(true, (message) => {
      // Process received message
    
    });
    
    //Example of message receiver with filter of originator
    client.addMessageReceiver((message) => { message.from === "553199990000@0mn.io" },
    (message) => {
      // Process received message
    });
    
    //Each registration of receivers return a `handler` that can be used to cancell the registration:
    var removeJsonReceiver = client.addMessageReceiver("application/json", handleJson);
    // ...
    removeJsonReceiver();
    

    All messages will be delivered as a HTTP POST request on configured chatbot messages URL. A sample of received message is presented below.

    POST https://your.endpoint/messages HTTP/1.1
    Content-Type: application/json
    
    {
      "id": "99cf454e-f25d-4ebd-831f-e48a1c612cd4",
      "from": "551100001111@0mn.io/4ac58r6e3",
      "to": "blipmessaginghubapp@msging.net",
      "type": "text/plain",
      "content": "Help"
    }
    

    The process of receiving messages is asynchronous. The received messages will be on the format defined on LIME Protocol.

    Notifications

    See below the representation of a received notification from the destination:

    var notification = new Notification
    {
        Id = "65603604-fe19-479c-c885-3195b196fe8e",
        From = "551199991111@0mn.io/182310923192",
        To = "mycontact@msging.net",
        Event = Event.Received
    };
    
    var notification = {
      id: "65603604-fe19-479c-c885-3195b196fe8e",
      from: "551199991111@0mn.io/182310923192",
      to: "mycontact@msging.net",
      event: "received"
    }
    
    POST https://your.endpoint/notifications HTTP/1.1
    Content-Type: application/json
    
    {
      "id": "65603604-fe19-479c-c885-3195b196fe8e",
      "from": "551199991111@0mn.io/182310923192",
      "to": "mycontact@msging.net",
      "event": "received"
    }
    

    And a notification of a server failure:

    var notification = new Notification
    {
        Id = "65603604-fe19-479c-c885-3195b196fe8e",
        From = "551199991111@0mn.io/182310923192",
        To = "mycontact@msging.net",
        Event = Event.Failed,
        Reason = new Reason
        {
            Code = 42,
            Description = "Destination not found"
        }
    };
    
    var notification = {
      id: "65603604-fe19-479c-c885-3195b196fe8e",
      from: "postmaster@msging.net/server1",
      to: "mycontact@msging.net",
      event: "failed",
      reason: {
        code: 42,
        description: "Destination not found"
      }
    }
    
    POST https://your.endpoint/notifications HTTP/1.1
    Content-Type: application/json
    
    {
      "id": "65603604-fe19-479c-c885-3195b196fe8e",
      "from": "postmaster@msging.net/server1",
      "to": "mycontact@msging.net",
      "event": "failed",
      "reason": {
        "code": 42,
        "description": "Destination not found"
      }
    }
    
    
    

    A notification provides information about a sent message.

    Each notification has:

    For more details, check the LIME protocol specification.

    Sending notifications

    We send a notification using a client object with method sendNotification

    client.connect()
        .then((session) => {
            // Sending "received" notification
            var notification = {
                id: 'ef16284d-09b2-4d91-8220-74008f3a5788',
                to: '553199990000@0mn.io',
                event: Lime.NotificationEvent.RECEIVED
            };
            client.sendNotification(notification);
        });
    
    // Using await keyword
    let session = await client.connect();
    let notification = {
        id: 'ef16284d-09b2-4d91-8220-74008f3a5788',
        to: '553199990000@0mn.io',
        event: Lime.NotificationEvent.RECEIVED
    };
    
    client.sendNotification(notification);
    
    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 notification = new Notification
                {
                    Id = message.Id,
                    To = message.From,
                    Event = Event.Consumed
                };
    
            await _sender.SendNotificationAsync(notification, cancellationToken);
        }
    }
    

    For instance, imagine that the received a message from example above (whit id 99cf454e-f25d-4ebd-831f-e48a1c612cd4

    POST https://msging.net/notifications HTTP/1.1
    Content-Type: application/json
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Length: 131
    
    {
        "id": "99cf454e-f25d-4ebd-831f-e48a1c612cd4",
        "from": "551100001111@0mn.io/4ac58r6e3",
        "event": "consumed"
    }
    

    In order to correctly show the message history, it is important that the chatbots send notifications of messages processed to originator clients.

    For each message processed, a notification must be sent with the consumed event. In case of problems, the chatbot must send a notification with the failed event.

    REQUEST

    Name Description
    id Identifier of the related message
    from Notification originator’s address
    to Notification recipient’s address
    event Event related to the message
    reason In case of failed events, represents the reason of the message failure

    Receiving notifications

    The next sample shows how to add a notification receiver with filter to the `received` event type:

    client.addNotificationReceiver("received", function(notification) {
      // Process received notifications
    });
    
    // Using expression lambda
    client.addNotificationReceiver(() => true, function(message) {
      // Process received notifications
    });
    

    The receipt of notifications is done using the interface INotificationReceiver.

    public class ConsumedNotificationReceiver : INotificationReceiver
    {
        public async Task ReceiveAsync(Notification notification, CancellationToken cancellationToken)
        {
            // Write the received notification to the console
            Console.WriteLine(notification.ToString());
        }
    }
    

    All notifications will be delivered as a HTTP POST request on the configured URL for chatbot notifications.

    POST https://your.endpoint/notifications HTTP/1.1
    Content-Type: application/json
    
    {
      "id": "123e4567-e89b-12d3-a456-426655440000",
      "from": "551100001111@0mn.io/4ac58r6e3",
      "to": "blipmessaginghubapp@msging.net/7a8fr233x",
      "event": "received"
    }
    

    Each notification contains the status of messages. Observe that the notifications are sent by the clients, informing if they received some message or not.

    Commands

    See below the representation of a command for the distribution list creation.

    var command = new Command()
    {
        Id = EnvelopeId.NewId(),
        To = "postmaster@broadcast.msging.net",
        Method = CommandMethod.Set,
        Uri = new LimeUri("/lists"),
        Resource = new JsonDocument(DistributionList.MediaType)
        {
            {"identity", "list@broadcast.msging.net"}
        }
    };
    
    var command = {
      id:  "1",
      to: "postmaster@broadcast.msging.net",
      method: "set",
      uri: "/lists",
      type: "application/vnd.iris.distribution-list+json",
      resource: {
        identity:  "list@broadcast.msging.net"
      }
    } 
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Length: 131
    
    {
      "id":  "1",
      "to": "postmaster@broadcast.msging.net",
      "method": "set",
      "uri": "/lists",
      "type": "application/vnd.iris.distribution-list+json",
      "resource": {
        "identity":  "list@broadcast.msging.net"
      }
    } 
    

    Reponse in the case of a successful answer:

    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "1",
      "from": "postmaster@broadcast.msging.net/#hmgirismsging2",
      "to": "my-contact@msging.net/default",
      "method": "set",
      "status": "success"
    } 
    

    In the case of a failure:

    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "1",
      "from": "postmaster@broadcast.msging.net/#hmgirismsging2",
      "to": "my-contact@msging.net/default",
      "method": "set",
      "status": "failure",
      "reason": {
       "code": 60,
       "description": "Invalid list identifier"
      }
    } 
    

    A command allows querying and manipulation of server resources and the consumption of BLiP extensions. It provides a request-response interface similar to HTTP, with verbs and URIs.

    Each command has:

    Note: Some extensions cannot accept all of the available methods.

    Besides the properties previously mentioned, a response command may have:

    For more details, check the LIME protocol specification.

    Sending commands

    ISender interface also enables send commands to the server, as the following sample:

    // For this case, the command response is received on a synchronous way.
    
    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 command = new Command {
                Id = 1,
                Method = CommandMethod.Get,
                Uri = new LimeUri("/account")
            };
    
            var response = await _sender.ProcessCommandAsync(command, cancellationToken);
        }
    }
    
    var pingCommand = {
        id: Lime.Guid(),
        uri: '/ping',
        method: 'get'
    };
    
    messagingHubClient
        .sendCommand(pingCommand)
        .then(function (commandResponse) {
            utils.logLimeCommand(pingCommand, 'Ping sent');
            utils.logLimeCommand(commandResponse, 'Ping response');
        })
        .catch(function (err) {
            utils.logMessage('An error occurred: ' + err);
        });
    
    
    
    POST https://msging.net/commands HTTP/1.1
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Type: application/json
    Content-Length: 393
    
    {  
        "id":"2",
        "to":"postmaster@scheduler.msging.net",
        "method":"set",
        "uri":"/schedules",
        "type":"application/vnd.iris.schedule+json",
        "resource":{  
        "message":{  
            "id":"ad19adf8-f5ec-4fff-8aeb-2e7ebe9f7a67",
            "to":"553100001111@0mn.io",
            "type":"text/plain",
            "content":"Scheduled Message"
        },
        "when":"2016-07-25T17:50:00.000Z"
        }
    }
    

    In order to use the BLiP's extensions (like schedule and directory), it is necessary to send commands.

    REQUEST

    Name Description
    id Unique command identifier
    from Command originator address
    to Command recipient address
    uri The path at the recipient the command refers to
    method Method for resource manipulation defined at the uri. This value is mandatory
    type Declaration of the resource value type, in the MIME format
    resource JSON resource representation
    status Indicates the command processing result, it is mandatory in the answers
    reason Indicates the command processing failure reason

    Obs: The uri value is mandatory in the requests and can be omitted in the responses. A response command may have status and reason properties.

    Result codes for requests

    Code Description
    202 (Accepted) Envelope was accepted by the server
    400 (Bad Request) Alert to some problem with the format or fields of sent envelope.
    401 (Unauthorized) Alert to some problem or Authorization header missing

    Throughputs

    There are a maximum number of messages, notifications and commands you can send asynchronously, according to your plan.

    Description Free Business Enterprise
    Message throughput (per second) 3 250 500
    Notification throughput (per second) 6 500 1000
    Command throughput (per second) 48 1000 2000

    Authentication

    If you need to build your chatbot using one of the SDKs or using HTTP or if you need to access any BLiP internal API (for extensions and integrations) you must to be authenticated. This section explain how to authenticate your chatbot in order to use BLiP.

    SDKs

    On both C# and Javascript, you will need an identifier and an access key to be able to connect to the BLiP. To get them:

    imagem

    HTTP

    On HTTP, whatever request made (messages/notifications/commands) must contain an authorization header (Authorization) with a Key type, as showed on BLiP Portal chatbot configurations.

    imagem

    Auth Samples

    Imagine a chatbot with an Authorization 'Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ='. To send a message from this bot to a BLiP user, use:

    Note: For this sample, bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ is a valid Key.
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Length: 131
    
    {
        "id": "123e4567-e89b-12d3-a456-426655440000",
        "to": "551100001111@0mn.io",
        "type": "text/plain",
        "content": "Hello, how can I help you?"
    }
    

    With C#, the authentication of your chatbot is made on application.json file. Basically, this file defines all receivers and other control properties.

    //Check an example of how to set your application.json file:
    {
      "identifier": "xpto",
      "accessKey": "cXkzT1Rp",
      "messageReceivers": [
        {
          "type": "PlainTextMessageReceiver",
          "mediaType": "text/plain"
        }
      ]
    }
    

    In order to instantiate the client, use ClientBuilder class informing the identifier and access key:

    
    // Create a client instance passing the identifier and accessKey of your chatbot 
    var client = new ClientBuilder()
        .withIdentifier(identifier)
        .withAccessKey(accessKey)
        .withTransportFactory(() => new WebSocketTransport())
        .build();
    
    // Register a receiver for messages of 'text/plain' type
    client.addMessageReceiver('text/plain', function(message) {
      // TODO: Proccess the received message
    });
    
    // Register a receiver to any notification
    client.addNotificationReceiver(true, function(notification) {
      // TODO: Proccess the received notification
    });
    
    // Connect with server asynchronously
    // Connection will occurr via websocket on 8081 port.
    client.connect() // This method return a 'promise'.
        .then(function(session) { 
            // Connection success. Now is possible send and receive envelopes from server. */ 
            })  
        .catch(function(err) { /* Connection failed. */ }); 
    
    

    Getting Started

    Even if you are completely new to BLiP Platform, getting started section is quick and easy! Start building your first bot just following these steps. If you have any problem or don't understand any step please use Forum to report.

    Before start your bot you must choice wich chatbot type do you need. There are 4 different type:

    Using Builder

    Builder is one of the BLiP portal components. It was designed to make the create chatbot process more quick, simple, visual and without code. Through Builder is possible define all conversational flow and contents integrated with any other platform resource.

    Even though be a visual component you can use Builder to create any type of bots, from really simple until very complex cases.

    imagem

    For more informations about how to create a bot using Builder component click here.

    Using SDK CSharp

    Besides Builder is possible to create a bot using only code. BLiP C# SDK is a set of Nuget packages based on .NET Core, which allows the creation of multiplatform chatbots. You can check the SDK source code in Github and the documentation on our Wiki

    Requirements

    Before start

    The easiest way to get started is using one of our dotnet templates.

    To install the templates, run the execute command in the shell:

    dotnet new -i "Take.Blip.Client.Templates::*"
    

    After installing the templates, just create a directory for your chatbot and create a new project using a template:

    mkdir MyBot
    cd MyBot
    dotnet new blip-console
    

    There are available the following templates:

    1. Starting your bot

    After installed and created the project template, open the MyBot.csproj file and build the project. Note that all the necessary files for your bot are already created.

    You will need an identifier and an access key to be able to connect to the BLiP. To get them:

    imagem

    Your application.json file must looks like:

    {
      "identifier": "your-identifier",
      "accessKey": "your-access-key",
    
      // other stuffs
    }
    

    Starting application...
    Application started. Press any key to stop.

    2. Receiving a message

    The configuration of your chatbot is made on application.json file. Basically this file define all receivers and others control properties.

    Check an example of how to minimally set your application.json file:

    {
      "identifier": "xpto",
      "accessKey": "cXkzT1Rp",
      "messageReceivers": [
        {
          "type": "PlainTextMessageReceiver",
          "mediaType": "text/plain"
        }
      ]
    }
    

    Through of application.json file the developer can realize a tranparent run of the application. All the other tasks are managed by the .NET Core template package installed before.

    Looking for the right side sample the client was configured to use a chatbot with xpto identifier with cXkzT1Rp accessKey. Besides that was registered a MessageReceiver with name PlainTextMessageReceiver and a filter for messages with text/plain media type. It means that the PlainTextMessageReceiver class you be called when a text/plain message is received by your bot. If you want to be able to receive other messages content types you must add more receivers in application.json file. To see any other advanced settings about application.json click here.

    The receipt of messages is done using the interaces IMessageReceiver.

    A IMessageReceiver can be defined as follow:

    public class PlainTextMessageReceiver : IMessageReceiver
    {
        public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
        {
            // Write the received message to the console
            Console.WriteLine(message.Content.ToString());
        }
    }
    

    Optional

    Optionally is also possible handle Notifications. The proccess is very similar to receiving message. The notifcations are fire-and-forget and if occur some exception on ReceiveAsync, this fail will be ignored.

    Create a class that implements INotificationReceiver and remember to add its name into application.json file. For more informations click here.

    An INotificationReceiver can be defined as follow:

    public class ConsumedNotificationReceiver : INotificationReceiver
    {
        public async Task ReceiveAsync(Notification notification, CancellationToken cancellationToken)
        {
            // Write the received notification to the console
            Console.WriteLine(notification.ToString());
        }
    }
    

    An application.json file sample using a NotificationReceiver

    {
      "identifier": "xpto",
      "accessKey": "cXkzT1Rp",
      "messageReceivers": [
        {
          "type": "PlainTextMessageReceiver",
          "mediaType": "text/plain"
        }
      ],
      "notificationReceivers": [
        {
          "type": "ConsumedNotificationReceiver",
        }
      ]
    }
    

    3. Sending a message

    In order to send messages and notifications use an instance of ISender, wich is automaticaly injected on constructors of registered receivers defined on project and on Startup class.

    The sample below show how to reply a received message with a text:

    public class PlainTextMessageReceiver : IMessageReceiver
    {
        private readonly ISender _sender;
    
        public PlainTextMessageReceiver(IMessagingHubSender sender)
        {
            _sender = sender;
        }
    
        public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
        {
            // Write the received message to the console
            Console.WriteLine(message.Content.ToString());
            // Responds to the received message
            _sender.SendMessageAsync("Hi. I just received your message!", message.From, cancellationToken);
        }
    }
    

    The process of send message is asynchronous and the status of sent messages is delivered to application by notifications. If you need to send any other message content type click here

    4. Sending a command

    A command allows querying and manipulation of server resources and the consumption of BLiP extensions and integrations. To see more details about what are the commands click here.

    There are two possibilities to send commands. Using the method SendCommand of ISender interface or using one of the available IExtension extensions.

    One of the most common extension is Event Analysis that allows to register chatbot's events to create analytics reports in portal.

    Let see some samples of how to send commands:

    Using IExtension interface

    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.EventTracker;
    
    namespace Extensions
    {
        public class PlainTextMessageReceiver : IMessageReceiver
        {
            private readonly IEventTrackExtension _eventTrackExtension;
    
            public PlainTextMessageReceiver(IEventTrackExtension eventTrackExtension)
            {
                _eventTrackExtension = eventTrackExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                await _eventTrackExtension.AddAsync("payments", "success-order");
            }
        }
    }
    

    Using ISender interface

    // For this case, the command response is received on a synchronous way.
    
    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 command = new Command {
                Id = 1,
                Method = CommandMethod.Set,
                Uri = new LimeUri("/event-track"),
                Resource = new EventTrack
                {
                    Category = "payments",
                    Action = "success-order",
                }
            };
    
            var response = await _sender.ProcessCommandAsync(command, cancellationToken);
        }
    }
    

    Go to Extensions or Integrations sections to see all commands available to be used.

    5. Samples using CSharp

    Click here to see same bots sample created using SDK C#.

    Using SDK Javascript

    If you are a Javascript developer and want to create a chatbot with BLiP, you must use the BLiP Javascript SDK. It was developed to help sending and receiving of BLiP messages using Javascript for browsers or node.js through persistent WebSocket connections.

    Go to Github to see the source code and the full documentation.

    Requirements

    Before start

    Create a empty Node.js project

    mkdir MyBot
    cd MyBot
    npm init
    

    Install blip-sdk package (via npm) as a dependecy of your project in order to access the BLiP server.

    npm install --save blip-sdk lime-transport-websocket
    

    1. Starting the bot (js)

    You will need an identifier and an access key to be able to connect to the BLiP. To get them:

    imagem

    Create a index.js file add the code below and replace the variables IDENTIFIER and ACCESS_KEY with informations of your bot.

    import * as BlipSdk from 'blip-sdk';
    import * as WebSocketTransport from 'lime-transport-websocket'
    
    // Put your identifier and access key here
    let IDENTIFIER = '';
    let ACCESS_KEY = '';
    
    // Create a client instance passing the identifier and accessKey of your chatbot
    let client = new BlipSdk.ClientBuilder()
        .withIdentifier(IDENTIFIER)
        .withAccessKey(ACCESS_KEY)
        .withTransportFactory(() => new WebSocketTransport())
        .build();
    
    // Connect with server asynchronously
    // Connection will occurr via websocket on 8081 port.
    client.connect() // This method return a 'promise'.
        .then(function(session) {
            // Connection success. Now is possible send and receive envelopes from server. */
            console.log('Application started. Press Ctrl + c to stop.')
        })
        .catch(function(err) { /* Connection failed. */ });
    

    Application started. Press Ctrl + c to stop.

    2. Receiving a message (js)

    In order to receive and handle messages you need to use addMessageReceiver method in client object. All messages sent to the chatbot are redirected to defined messages (or notifications) receivers. You also can define filters to each receiver.

    The following example show how to add a simple message receiver:

    client.addMessageReceiver(true, function(message) {
      // Process received message
    });
    

    It's also possible use a custom function as receiver filter. The sample above shows a message receiver with filter of originator:

    client.addMessageReceiver(function(message) { message.from === "553199990000@0mn.io" }, function(message) {
      // Process received message
    });
    

    Each registration of receivers return a handler that can be used to cancel the registration:

    var removeJsonReceiver = client.addMessageReceiver("application/json", handleJson);
    // ...
    removeJsonReceiver();
    

    Optional

    Optionally is also possible handle notifications adding a notification receiver. The proccess is very similar to receiving message. The notifcations are fire-and-forget and if occur some exception on receiver, this fail will be ignored.

    The next sample show how to add notification receiver with filter to received event type:

    client.addNotificationReceiver("received", function(notification) {
      // Process received notifications
    });
    

    Adding notification receiver with a filter using lambda expression

    // Using lambda expression
    client.addNotificationReceiver(() => true, function(notification) {
      // Process received notifications
    });
    

    3. Sending a message (js)

    In order to send messages and notifications use the sendMessage (or sendNotification) method in client object.

    The following sample show how to send a message after connection has been stablished:

    client.connect()
        .then(function(session) {
            // After connection is possible send messages
            var msg = {
                type: "text/plain",
                content: "Hello, world",
                to: "553199990000@0mn.io"
            };
            client.sendMessage(msg);
        });
    

    The following sample show how to send a notification after connection has been stablished:

    client.connect()
        .then(function(session) {
            // Sending "received" notification
            var notification = {
                id: "ef16284d-09b2-4d91-8220-74008f3a5788",
                to: "553199990000@0mn.io",
                event: Lime.NotificationEvent.RECEIVED
            };
            client.sendNotification(notification);
        });
    

    The process of send message is asynchronous and the status of sent messages is delivered to application by notifications. If you need to send any other message content type click here

    4. Sending a command (js)

    A command allows querying and manipulation of server resources and the consumption of BLiP extensions and integrations. To see more details about what are the commands click here.

    Using sendCommand method

    
    let resource = { category: 'payments', action: 'success-order' };
    
    client.sendCommand({
        id: Lime.Guid(),
        method: Lime.CommandMethod.SET,
        type: 'application/vnd.iris.eventTrack+json',
        uri: '/event-track',
        resource: resource
    })
    

    One of the most common extension is Event Analysis that allows to register chatbot's events to create analytics reports in portal.

    Let see some samples of how to send commands:

    Go to Extensions or Integrations sections to see all commands available to be used.

    5. Samples using Javascript

    Click here to see same bots sample created using SDK Javascript.

    Using HTTP

    Webhook enables an integration between your bot and BLiP via HTTP endpoints to exchange messages, notifications and commands. If you are not able to create your chatbot using C# or Javascript languages you must use BLiP's HTTP API agnostic for any language.

    The diagram below shows the messages flow between BLiP and your endpoint (API).

    Requirements

    Before start

    Get the Authorization token of your bot to be able to connect to the BLiP. To get them:

    imagem

    1. Receiving messages

    Any message will be delivered as a HTTP POST request on the configured chatbot's message URL. These messages have a JSON format as defined on Content Types section. A sample of a received text message is presented below.

    {
      "id": "99cf454e-f25d-4ebd-831f-e48a1c612cd4",
      "from": "551100001111@0mn.io/4ac58r6e3",
      "to": "blipmessaginghubapp@msging.net",
      "type": "text/plain",
      "content": "Help"
    }
    

    2. Sending messages

    To send messages, it is necessary to make a HTTP POST request to BLiP using the URL https://msging.net/messages. The request must contain an authorization header (Authorization) with Key type, as showed on chatbot settings. To know more about BLiP authentication process click here.

    The message data must be sent on the request body as a JSON following the LIME protocol format. For more details go to Content Types section.

    Imagine a chatbot with an Authorization token Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=. To send a message from this bot to a BLiP user, use:

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Length: 131
    
    {
      "id": "123e4567-e89b-12d3-a456-426655440000",
      "to": "551100001111@0mn.io",
      "type": "text/plain",
      "content": "Hello, how can I help you?"
    }
    

    For more information about messages, check the Messages documentation page or the supported content types specification.

    3. Receiving notification

    All notifications will be delivered on the configured chatbot's notification URL. Each notification contains the status of messages. Observe that notifications are sent by clients, informing if received or not some message.

    A sample of notification is presented below. This notification will be deliverd as a HTTP POST request on the chatbot notification URL.

    {
      "id": "123e4567-e89b-12d3-a456-426655440000",
      "from": "551100001111@0mn.io/4ac58r6e3",
      "to": "blipmessaginghubapp@msging.net/7a8fr233x",
      "event": "received"
    }
    

    For more information, check the Notification documentation page

    4. Sending notifications

    In order to correctly show the message history, it is important that the chatbots send notifications of messages processed to originator clients.

    For each message processed, it is important to send a notification with the consumed event. In case of problems, the chatbot must send a notification with the failed event. The request must use the URL https://msging.net/notifications and contain an authorization header (Authorization) with Key type, as showed on chatbot settings.

    For instance, imagine that the received message from the example above (whit id 99cf454e-f25d-4ebd-831f-e48a1c612cd4) was processed with success. The code below shows a complete notification request including the headers and the body request.

    POST https://msging.net/notifications HTTP/1.1
    Content-Type: application/json
    Authorization: Key bWVzc2FnaW5naHViQHRha2VuZXQuY29tLmJyOjEyMzQ=
    Content-Length: 131
    
    {
      "id": "99cf454e-f25d-4ebd-831f-e48a1c612cd4",
      "from": "551100001111@0mn.io/4ac58r6e3",
      "event": "consumed"
    }
    

    5. Sending commands

    In order to use BLiP's extensions (like schedule and directory), it is necessary to send commands. To do that, a HTTP POST request on /commands URL must be made.

    For instance, send a command to schedule some message:

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "1",
      "to": "postmaster@scheduler.msging.net",
      "method": "set",
      "uri": "/schedules",
      "type": "application/vnd.iris.schedule+json",
      "resource": {  
        "message": {  
          "id": "ad19adf8-f5ec-4fff-8aeb-2e7ebe9f7a67",
          "to": "destination@0mn.io",
          "type": "text/plain",
          "content": "Scheduling test."
        },
        "when": "2016-07-25T17:50:00.000Z",
        "name": "New Schedule"
      }
    }
    

    The command response is immediately delivered on HTTP response, as below:

    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "1",
      "from": "postmaster@scheduler.msging.net/#az-iris4",
      "to": "destination@0mn.io",
      "metadata": {
        "#command.uri": "lime://destination@0mn.io/schedules"
      }
    }
    

    Aditional informations

    Code Description
    202 (Accepted) Envelope was accepted by the server
    400 (Bad Request) Alert to some problem with format or fields of sent envelope.
    401 (Unauthorized) Alert to some problem or Authorization header missing
    Name Description
    Url to receive messages Endpoint where BLiP will post the messages
    Url to receive notification Endpoint where BLiP will post the notifications

    Postman Collection

    Postman is a popular tool to help test APIs. To make it more convenient for developers who are integrating with the BLiP APIs, we've developed a Postman collection that contains the full set of APIs.

    Setup

    To get started, download and install Postman.

    After installed click on the Run in Postman button download and import the collection into your app.

    Postman logo

    Configure

    Postman offers a configurable variable map which is essentially a set of key-value pairs. It allows you to create commonly used variables that can be reference across multiple requests. You can read more about it here. Before to start using BLiP's Postman Collection you need to add the Authorization variable.

    imagem

    imagem

    Testing

    In order to test the collection access the Resource folder click in Store a resource request and than click in Send button. This request add a sample resource in your bot. Go to BLiP portal access Resources module and check the content.

    imagem

    Content Types

    If you want to see all content-types working, clone our SDK sample project:
    github.com/takenet/blip-sdk-csharp/tree/master/src/Samples/MessageTypes
    

    BLiP uses message content types defined by LIME protocol and performs the conversion of these types to the most adequate format for each destination channel. For more details, check the LIME protocol content types specification.

    Besides that, it's possible to send native contents to some channels - like Messenger -, which allows the usage of the channel capabilities without restrictions. See more details on Native contents item on the left menu.

    Metadata

    Messages received from some channels may have unique metadata information coming from the channel. This information is included in the metadata property of the BLiP messages.

    An example of a message received from Messenger:

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    {
      "id": "9dc08447-8b23-4bc2-8673-664dca202ee2",
      "from": "128271320123982@messenger.gw.msging.net",
      "to": "mybot@msging.net",
      "type": "text/plain",
      "content": "Hello",
      "metadata": {
          "messenger.mdi": "mid.$cAAAu_n30PEFiJQdYSlb8785KMO5E",
          "messenger.seq": "19062"
      }
    }
    

    The properties messenger.mdi and messenger.seq are specific to Messenger, but they are delivered together with incoming messages. In Messenger specifically, several different metadata properties can be delivered, one of the most important being the messenger.ref, which is the referral generated when a client clicks on a m.me/bot-name?ref=value link from your chatbot or when it scans a code for the bot.

    HTTP/1.1 200 OK
    Content-Type: application/json
    {
      "id": "2dc05467-4b23-1bc2-8673-664dca202ee2",
      "from": "128271320123982@messenger.gw.msging.net",
      "to": "mybot@msging.net",
      "type": "text/plain",
      "content": "Get started",
      "metadata": {
          "messenger.ref": "website",
          "messenger.source": "SHORTLINK",
          "messenger.type": "OPEN_THREAD"
      }
    }
    

    Chat state

    Sending status typing to bot user:

    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace MessageTypes
    {
    public class OptionChatStateMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionChatStateMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var chatState = new ChatState
        {
            State = ChatStateEvent.Composing
        };
        await _sender.SendMessageAsync(chatState, message.From, cancellationToken);
    }
    
    }
    }
    
    client.sendMessage({
            id: Lime.Guid(),
            to:"104222@telegram.gw.msging.net",
            type:"application/vnd.lime.chatstate+json",
            content: {
                "state": "composing"
            }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "to":"104222@telegram.gw.msging.net",
        "type":"application/vnd.lime.chatstate+json",
        "content": {
            "state": "composing"
        }
    }
    
    MIME type
    application/vnd.lime.chatstate+json

    Allows sending and receiving information about the conversation's current status. Possible status are:

    State Description
    starting Initiating new conversation
    composing Typing/preparing a message
    paused New message typing interrupted, message not sent
    deleting Deleting message (which was being prepared)
    gone Exit/Conversation finished

    In general, there is no need to receive delivery notifications messages with this content, thus it is recommended to omit the Id in these messages. For more details, check the LIME protocol specification.

    Channel mapping

    Channel Type Supported states
    BLiP Chat Chat State All
    Messenger Sender Actions and Referral composing and paused (sending only) and starting (referral of an existing thread)
    Whatsapp - None
    SMS - None
    Skype - None
    Telegram SendChatAction composing (sending only)

    Collection

    A text Collection

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class OptionDocumentCollectionMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionDocumentCollectionMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    PlainText[] documents = new PlainText[]
    {
        new PlainText
        {
            Text = "Text 1"
        },
        new PlainText
        {
            Text = "Text 2"
        },
        new PlainText
        {
            Text = "Text 3"
        }
    };
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new DocumentCollection
        {
            ItemType = "text/plain",
            Items = documents
        };
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
        client.sendMessage({
            id: Lime.Guid(),
            type: "application/vnd.lime.collection+json",
            to: "128271320123982@messenger.gw.msging.net",
            content: {
                itemType: "text/plain",
                items: [
                    "Text 1",
                    "Text 2",
                    "Text 3"
                ]
            }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "to": "553199990000@0mn.io",
        "type": "application/vnd.lime.collection+json",
        "content": {
            "itemType": "text/plain",
            "items": [
                "Text 1",
                "Text 2",
                "Text 3"
            ]
        }
    }
    

    A different type of collection, using container

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class CollectionWithDiferentTypes : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public CollectionWithDiferentTypes(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    DocumentContainer[] documents = new DocumentContainer[]
    {
        new DocumentContainer{
            Value = new MediaLink
            {
                Uri = new Uri("http://www.petshoplovers.com/wp-content/uploads/2014/03/CUIDADOS-B%C3%81SICOS-PARA-CRIAR-COELHOS.jpg"),
                Text = "Welcome to our store!",
                Type = "image/jpeg"
            }
        },
        new DocumentContainer{
            Value = new Select
            {
                Text = "Choose what you need",
                Options = new SelectOption[]
                {
                    new SelectOption
                    {
                        Order = 1,
                        Text = "See our stock"
                    },
                    new SelectOption
                    {
                        Order = 2,
                        Text = "Follow an order"
                    }
                }
    
            }
        }
    };
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new DocumentCollection
        {
            ItemType = "application/vnd.lime.container+json",
            Items = documents
        };
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
        id: Lime.Guid(),
        type: "application/vnd.lime.collection+json",
        to: "128271320123982@messenger.gw.msging.net",
        content: {
            itemType: "application/vnd.lime.container+json",
            items: [
                {
                    type: "application/vnd.lime.media-link+json",
                    value: {
                        text: "Welcome to our store!",
                        type: "image/jpeg",
                        uri: "http://www.petshoplovers.com/wp-content/uploads/2014/03/CUIDADOS-B%C3%81SICOS-PARA-CRIAR-COELHOS.jpg"
                    }
                },
                {
                    type: "application/vnd.lime.select+json",
                    value: {
                        text: "Choose what you need",
                        options: [
                            {
                                order: 1,
                                text: "See our stock"
                            },
                            {
                                order: 2,
                                text: "Follow an order"
                            }
                        ]
                    }
                }
            ]
        }
    });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "to": "553199990000@0mn.io",
        "type": "application/vnd.lime.collection+json",
        "content": {
            "itemType": "application/vnd.lime.container+json",
            "items": [
                {
                    "type": "application/vnd.lime.media-link+json",
                    "value": {
                        "text": "Welcome to our store!",
                        "type": "image/jpeg",
                        "uri": "http://www.petshoplovers.com/wp-content/uploads/2014/03/CUIDADOS-B%C3%81SICOS-PARA-CRIAR-COELHOS.jpg"
                    }
                },
                {
                    "type": "application/vnd.lime.select+json",
                    "value": {
                        "text": "Choose what you need",
                        "options": [
                            {
                                "order": 1,
                                "text": "See our stock"
                            },
                            {
                                "order": 2,
                                "text": "Follow an order"
                            }
                        ]
                    }
                }
            ]
        }
    }
    
    

    A multimedia menu collection

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class CollectionMultimidiaMenu : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    JsonDocument jsonDocuments;
    JsonDocument jsonDocuments2;
    JsonDocument jsonDocuments3;
    
    public CollectionMultimidiaMenu(ISender sender)
    {
        _sender = sender;
    }
    
    DocumentSelect[] documents = new DocumentSelect[]
    {
        jsonDocuments = new JsonDocument();
        jsonDocuments2 = new JsonDocument();
        jsonDocuments3 = new JsonDocument();
    
        jsonDocuments.Add("Key1", "value1");
        jsonDocuments.Add("Key2", "2");
    
        jsonDocuments2.Add("Key3", "value3");
        jsonDocuments2.Add("Key4", "4");
    
        jsonDocuments3.Add("Key5", "value5");
        jsonDocuments3.Add("Key6", "6");
    
        DocumentSelect[] documents = new DocumentSelect[]
        {
            new DocumentSelect
            {
                Header = new DocumentContainer
                {
                    Value = new MediaLink
                    {
                        Title = "Title",
                        Text = "This is a first item",
                        Type = "image/jpeg",
                        Uri = new Uri("http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"),
                    }
                },
                Options = new DocumentSelectOption[]
                {
                    new DocumentSelectOption
                    {
                        Label = new DocumentContainer
                        {
                            Value = new WebLink
                            {
                                Title = "Link",
                                Uri = new Uri("http://www.adoteumgatinho.org.br/")
                            }
                        }
                    },
                    new DocumentSelectOption
                    {
                        Label = new DocumentContainer
                        {
                            Value = new PlainText
                            {
                                Text = "Text 1"
                            }
                        },
                        Value = new DocumentContainer
                        {
                            Value = jsonDocuments
                        }
                    }
                }
            },
            new DocumentSelect
            {
                Header = new DocumentContainer
                {
                    Value = new MediaLink
                    {
                        Title = "Title 2",
                        Text = "This is another item",
                        Type = "image/jpeg",
                        Uri = new Uri("http://www.freedigitalphotos.net/images/img/homepage/87357.jpg")
                    }
                },
                Options = new DocumentSelectOption[]
                {
                    new DocumentSelectOption
                    {
                        Label = new DocumentContainer
                        {
                            Value = new WebLink
                            {
                                Title = "Second link",
                                Text = "Weblink",
                                Uri = new Uri("https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058")
                            }
                        }
                    },
                    new DocumentSelectOption
                    {
                        Label = new DocumentContainer
                        {
                            Value = new PlainText {
                                Text = "Second text"
                            }
                        },
                        Value = new DocumentContainer
                        {
                            Value = jsonDocuments2
                        }
                    },
                    new DocumentSelectOption
                    {
                        Label = new DocumentContainer
                        {
                            Value = new PlainText {
                                Text = "More one text"
                            }
                        },
                        Value = new DocumentContainer
                        {
                            Value = jsonDocuments3
                        }
                    }
                }
            }
        };
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new DocumentCollection
        {
            ItemType = "application/vnd.lime.document-select+json",
            Items = documents,
        };
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
        client.sendMessage({
            id: Lime.Guid(),
            type: "application/vnd.lime.collection+json",
            to: "128271320123982@messenger.gw.msging.net",
            content: {
                itemType: "application/vnd.lime.document-select+json",
                items: [
                    {
                        header: {
                            type: "application/vnd.lime.media-link+json",
                            value: {
                                title: "Title",
                                text: "This is a first item",
                                type: "image/jpeg",
                                uri: "http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"
                            }
                        },
                        options: [
                            {
                                label: {
                                    type: "application/vnd.lime.web-link+json",
                                    value: {
                                        title: "Link",
                                        uri: "http://www.adoteumgatinho.org.br/"
                                    }
                                }
                            },
                            {
                                label: {
                                    type: "text/plain",
                                    value: "Text 1"
                                },
                                value: {
                                    type: "application/json",
                                    value: {
                                        key1: "value1",
                                        key2: 2
                                    }
                                }
                            }
                        ]
                    },
                    {
                        header: {
                            type: "application/vnd.lime.media-link+json",
                            value: {
                                title: "Title 2",
                                text: "This is another item",
                                type: "image/jpeg",
                                uri: "http://www.freedigitalphotos.net/images/img/homepage/87357.jpg"
                            }
                        },
                        options: [
                            {
                                label: {
                                    type: "application/vnd.lime.web-link+json",
                                    value: {
                                        title: "Second link",
                                        text: "Weblink",
                                        uri: "https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058"
                                    }
                                }
                            },
                            {
                                label: {
                                    type: "text/plain",
                                    value: "Second text"
                                },
                                value: {
                                    type: "application/json",
                                    value: {
                                        key3: "value3",
                                        key4: 4
                                    }
                                }
                            },
                            {
                                label: {
                                    type: "text/plain",
                                    value: "More one text"
                                },
                                value: {
                                    type: "application/json",
                                    value: {
                                        key5: "value5",
                                        key6: 6
                                    }
                                }
                            }
                        ]
                    }
                ]
            }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "5",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.collection+json",
        "content": {
            "itemType": "application/vnd.lime.document-select+json",
            "items": [
                {
                    "header": {
                        "type": "application/vnd.lime.media-link+json",
                        "value": {
                            "title": "Title",
                            "text": "This is a first item",
                            "type": "image/jpeg",
                            "uri": "http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"
                        }
                    },
                    "options": [
                        {
                            "label": {
                                "type": "application/vnd.lime.web-link+json",
                                "value": {
                                    "title": "Link",
                                    "uri": "http://www.adoteumgatinho.org.br"
                                }
                            }
                        },
                        {
                            "label": {
                                "type": "text/plain",
                                "value": "Text 1"
                            },
                            "value": {
                                "type": "application/json",
                                "value": {
                                    "key1": "value1",
                                    "key2": 2
                                }
                            }
                        }
                    ]
                },
                {
                    "header": {
                        "type": "application/vnd.lime.media-link+json",
                        "value": {
                            "title": "Title 2",
                            "text": "This is another item",
                            "type": "image/jpeg",
                            "uri": "http://www.freedigitalphotos.net/images/img/homepage/87357.jpg"
                        }
                    },
                    "options": [
                        {
                            "label": {
                                "type": "application/vnd.lime.web-link+json",
                                "value": {
                                    "title": "Second link",
                                    "text": "Weblink",
                                    "uri": "https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058"
                                }
                            }
                        },
                        {
                            "label": {
                                "type": "text/plain",
                                "value": "Second text"
                            },
                            "value": {
                                "type": "application/json",
                                "value": {
                                    "key3": "value3",
                                    "key4": 4
                                }
                            }
                        },
                        {
                            "label": {
                                "type": "text/plain",
                                "value": "More one text"
                            },
                            "value": {
                                "type": "application/json",
                                "value": {
                                    "key5": "value5",
                                    "key6": 6
                                }
                            }
                        }
                    ]
                }
            ]
        }
    }
    
    MIME type C#
    application/vnd.lime.collection+json Lime.Protocol.DocumentCollection

    Allows sending multiple contents of the same type in a single message. Some channels support this type of aggregation with special layouts (for example, in Facebook Messenger a multimedia menu collection is displayed as a carousel). In other channels, multiple messages are sent instead.

    Note: It is possible to send different content types using a collection of the container type.

    For more details, check the LIME protocol specification.

    Channel mapping

    Channel Type
    BLiP Chat Collection
    Messenger Multiple messages / Generic template (if is a multimedia menu collection)
    Wathsapp Text (multiple lines)
    SMS Text (multiple lines)
    Skype Activity (multiple lines)
    Telegram Message (multiple lines)

    Input

    Requesting a user's name:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class OptionUserInputMessaReceiver : IMessageReceiver
    {
        private readonly ISender _sender;
    
        public OptionUserInputMessaReceiver(ISender sender)
        {
            _sender = sender;
            _settings = settings;
        }
    
        public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
        {
            var document = new Input
            {
                Label = new DocumentContainer{
                    Value = new PlainText {
                        Text = "What is your name?"
                    }
                },
                Validation = new InputValidation{
                    Rule = InputValidationRule.Text
                }
            };
    
            await _sender.SendMessageAsync(document, message.From, cancellationToken);
        }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.input+json",
          to: "1042225583186385@messenger.gw.msging.net",
          content: {
              label: {
                type: "text/plain",
                value: "What is your name?"
              },
              validation: {
                rule: "text"
              }
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.input+json",
        "content": {
            "label": {
              "type": "text/plain",
              "value": "What is your name?"
            },
            "validation": {
              "rule": "text"
            }
        }
    }
    

    Requesting a user's location:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class UserInputLocationReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    
    public UserInputLocationReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new Input
        {
            Label = new DocumentContainer{
                Value = "Send your location please!"
            },
            Validation = new InputValidation{
                Rule = InputValidationRule.Type,
                Type = "application/vnd.lime.location+json"
            }
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.input+json",
          to: "1042225583186385@messenger.gw.msging.net",
          content: {
              label: {
                type: "text/plain",
                value: "Send your location please!"
              },
              validation: {
                rule: "type",
                type: "application/vnd.lime.location+json"
              }
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "2",
        "to": "1334448323284655@messenger.gw.msging.net",
        "type": "application/vnd.lime.input+json",
        "content": {
            "label": {
              "type": "text/plain",
              "value": "Send your location please!"
            },
            "validation": {
              "rule": "type",
              "type": "application/vnd.lime.location+json"
            }
        }
    }
    
    MIME type
    application/vnd.lime.input+json

    Allows sending of structured information requests to the user, where it is possible to define validations rules. This is useful for building question forms and getting specific user information - like name or phone number - or typed information - like an image or location. The execution of validation rules depends of channel's support.

    For more details, check the LIME protocol specification.

    Channel mapping

    Channel Type
    BLiP Chat Uer input (for Location type only)
    Messenger Location
    Whatsapp Text
    SMS Text
    Skype Activity
    Telegram Message

    List

    Sending a list with a weblink header to a Messenger user:

    using System;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace MessageTypes
    {
    public class OptionListMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionListMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new DocumentList
        {
            Header = new DocumentContainer
            {
                Value = new WebLink
                {
                    Title = "Classic T-Shirt Collection",
                    Text = "See all our colors",
                    PreviewUri = new Uri("http://streetwearvilla.com/image/cache/data/Products/Supreme/T-shirt/supreme-box-logo-t-shirt-collection-600x600.png"),
                    Uri = new Uri("http://streetwearvilla.com/supreme-box-logo-t-shirt-white"),
                    Target = WebLinkTarget.SelfTall
                }
            },
            Items = new DocumentContainer[]{
                new DocumentContainer
                {
                    Value = new WebLink
                    {
                        Title = "Classic White T-Shirt",
                        Text = "100% Cotton, 200% Comfortable",
                        PreviewUri = new Uri("http://www.plainwhitetshirt.co.uk/image/cache/catalog/images/GD010vwhiteteegildan-750x750.jpg"),
                        Uri = new Uri("http://www.plainwhitetshirt.co.uk/gildan-soft-style-white-vneck-tshirt"),
                        Target = WebLinkTarget.SelfTall
                    }
                },
                new DocumentContainer
                {
                    Value = new WebLink
                    {
                        Title = "Classic Blue T-Shirt",
                        Text = "100% Cotton, 200% Comfortable",
                        PreviewUri = new Uri("https://cdn.shopify.com/s/files/1/1475/5420/products/Classic_Blue_Front_12068_1024x1024.jpg?"),
                        Uri = new Uri("https://www.theringboxingclubshop.com/products/ring-classic-blue-t-shirt"),
                        Target = WebLinkTarget.SelfTall
    
                    }
                },
                new DocumentContainer
                {
                    Value = new WebLink
                    {
                        Title = "Classic Black T-Shirt",
                        Text = "100% Cotton, 200% Comfortable",
                        PreviewUri = new Uri("http://www.lvnlifestyle.com/wp-content/uploads/2014/08/mens.black_.tshirt.jpg"),
                        Uri = new Uri("http://www.lvnlifestyle.com/product/black-mens-bamboo-organic-cotton-classic-t-shirt/"),
                        Target = WebLinkTarget.SelfTall
                    }
                }
            }
        };
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    
    }
    }
    
    
    client.sendMessage({
        id: Lime.Guid(),
        type: "application/vnd.lime.list+json",
        to: "123129898129832@msging.gw.msging.net",
        content: {
          header:{
              type: "application/vnd.lime.web-link+json",
              value: {
                  title: "Classic T-Shirt Collection",
                  text: "See all our colors",
                  previewUri: "http://streetwearvilla.com/image/cache/data/Products/Supreme/T-shirt/supreme-box-logo-t-shirt-collection-600x600.png",
                  uri: "http://streetwearvilla.com/supreme-box-logo-t-shirt-white",
                  target: "selfTall"
              }
          },
          items:[
              {
                  type: "application/vnd.lime.web-link+json",
                  value:{
                      title: "Classic White T-Shirt",
                      text: "100% Cotton, 200% Comfortable",
                      previewUri: "http://www.plainwhitetshirt.co.uk/image/cache/catalog/images/GD010vwhiteteegildan-750x750.jpg",
                      uri: "http://www.plainwhitetshirt.co.uk/gildan-soft-style-white-vneck-tshirt",
                      target: "selfTall"
                  }
              },
              {
                  type: "application/vnd.lime.web-link+json",
                  value:{
                      title: "Classic Blue T-Shirt",
                      text: "100% Cotton, 200% Comfortable",
                      previewUri: "https://cdn.shopify.com/s/files/1/1475/5420/products/Classic_Blue_Front_12068_1024x1024.jpg?",
                      uri: "https://www.theringboxingclubshop.com/products/ring-classic-blue-t-shirt",
                      target: "selfTall"
                  }
              },
              {
                  type: "application/vnd.lime.web-link+json",
                  value:{
                      title: "Classic Black T-Shirt",
                      text: "100% Cotton, 200% Comfortable",
                      previewUri: "http://www.lvnlifestyle.com/wp-content/uploads/2014/08/mens.black_.tshirt.jpg",
                      uri: "http://www.lvnlifestyle.com/product/black-mens-bamboo-organic-cotton-classic-t-shirt/",
                      target: "selfTall"
                  }
              }
          ]
        }
      });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id":"1",
      "to":"123129898129832@msging.gw.msging.net",
      "type":"application/vnd.lime.list+json",
      "content":{
        "header":{
          "type":"application/vnd.lime.web-link+json",
          "value":{
            "title":"Classic T-Shirt Collection",
            "text":"See all our colors",
            "previewUri":"http://streetwearvilla.com/image/cache/data/Products/Supreme/T-shirt/supreme-box-logo-t-shirt-collection-600x600.png",
            "uri":"http://streetwearvilla.com/supreme-box-logo-t-shirt-whitemessengerExtensions=true",
            "target":"selfTall"
          }
        },
        "items":[
          {
            "type":"application/vnd.lime.web-link+json",
            "value":{
              "title":"Classic White T-Shirt",
              "text":"100% Cotton, 200% Comfortable",
              "previewUri":"http://www.plainwhitetshirt.co.uk/image/cache/catalog/images/GD010vwhiteteegildan-750x750.jpg",
              "uri":"http://www.plainwhitetshirt.co.uk/gildan-soft-style-white-vneck-tshirt&messengerExtensions=true",
              "target":"selfTall"
            }
          },
          {
            "type":"application/vnd.lime.web-link+json",
            "value":{
              "title":"Classic Blue T-Shirt",
              "text":"100% Cotton, 200% Comfortable",
              "previewUri":"https://cdn.shopify.com/s/files/1/1475/5420/products/Classic_Blue_Front_12068_1024x1024.jpg?",
              "uri":"https://www.theringboxingclubshop.com/products/ring-classic-blue-t-shirt&messengerExtensions=true",
              "target":"selfTall"
            }
          },
          {
            "type":"application/vnd.lime.web-link+json",
            "value":{
              "title":"Classic Black T-Shirt",
              "text":"100% Cotton, 200% Comfortable",
              "previewUri":"http://www.lvnlifestyle.com/wp-content/uploads/2014/08/mens.black_.tshirt.jpg",
              "uri":"http://www.lvnlifestyle.com/product/black-mens-bamboo-organic-cotton-classic-t-shirt/&messengerExtensions=true",
              "target":"selfTall"
            }
          }
        ]
      }
    }
    
    MIME type
    application/vnd.lime.list+json

    Allows sending of a list of different documents on a single message. It's also possible to define a document as a list header.

    Channel support

    Channel Type
    BLiP Chat Not supported yet
    Messenger List template
    Whatsapp Text
    SMS Text
    Skype Activity
    Telegram Message

    Location

    Sending a location with latitude, longitude and altitude:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    //A chatbot can send and receive a location entity. For those cases, use Location type:
    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 Location
        {
            Latitude = -19.918899,
            Longitude = -43.959275,
            Altitude = 853,
            Text = "Take's place"
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.location+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            latitude: -19.918899,
            longitude: -43.959275,
            altitude: 853,
            text: "Take's place"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.location+json",
        "content": {
            "latitude": -19.918899,
            "longitude": -43.959275,
            "altitude": 853,
            "text": "Take's place"
        }
    }
    

    Request location

        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.input+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            label: {
              type: "text/plain",
              value: "Send your location please!"
            },
            validation: {
              rule: "type",
              type: "application/vnd.lime.location+json"
            }
          }
        });
    
    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class RequestLocation : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public RequestLocation(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var location = new Input
        {
            Label = new DocumentContainer{
                Value = new PlainText
                {
                    Text = "Send your location please!"
                }
            },
            Validation = new InputValidation{
                Rule = InputValidationRule.Type,
                Type = Location.MediaType
            }
        };
    
    await _sender.SendMessageAsync(location, message.From, cancellationToken);
    }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "2",
        "to": "1334448323284655@messenger.gw.msging.net",
        "type": "application/vnd.lime.input+json",
        "content": {
            "label": {
              "type": "text/plain",
              "value": "Send your location please!"
            },
            "validation": {
              "rule": "type",
              "type": "application/vnd.lime.location+json"
            }
        }
    }
    
    MIME type
    application/vnd.lime.location+json

    Allows sending and receiving of geographic information.

    For more details, check the LIME protocol specification.

    Channel mapping

    Channel Type
    BLiP Chat Location
    Messenger Starting August 15, 2019, updated versions of the Messenger app will no longer render Location quick reply.
    Whatsapp Text with link
    SMS Text with link
    Skype Activity
    Telegram Location

    Asks the user for her location

    Request Location

    using System;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace MessageTypes
    {
        public class OptionUserInputMessageReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public OptionUserInputMessageReceiver(ISender sender)
            {
                _sender = sender;
            }
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                Document document = new Input
                {
                    Label = new DocumentContainer
                    {
                        Value = "Send your location please!"
                    },
                    Validation = new InputValidation
                    {
                        Rule = InputValidationRule.Type,
                        Type = "application/vnd.lime.location+json"
                    }
                };
    
                await _sender.SendMessageAsync(document, message.From, cancellationToken);
            }
        }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.input+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            label: {
              type: "text/plain",
              value: "Send your location please!"
            },
            validation: {
              rule: "type",
              type: "application/vnd.lime.location+json"
            }
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "2",
        "to": "1334448323284655@messenger.gw.msging.net",
        "type": "application/vnd.lime.input+json",
        "content": {
            "label": {
              "type": "text/plain",
              "value": "Send your location please!"
            },
            "validation": {
              "rule": "type",
              "type": "application/vnd.lime.location+json"
            }
        }
    }
    

    You can send a location request by using input content-type

    Sending a location request:

    Messenger BLiPChat
    imagem imagem

    Send Location

    using System;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace MessageTypes
    {
        public class OptionLocationMessageReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public OptionLocationMessageReceiver(ISender sender)
            {
                _sender = sender;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                Document document = new Location
                {
                    Latitude = -19.919715,
                    Longitude = -43.959753,
                    Altitude = 853,
                    Text = "Take's place"
                };;
    
                await _sender.SendMessageAsync(document, message.From, cancellationToken);
            }
        }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.location+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            latitude: -19.919715,
            longitude: -43.959753,
            altitude: 853,
            text: "Take's place"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.location+json",
        "content": {
            "latitude": -19.918899,
            "longitude": -43.959275,
            "altitude": 853,
            "text": "Take's place"
        }
    }
    

    You can send a location by using location.

    Sending a location with latitude, longitude and altitude:

    Messenger BLiPChat
    imagem imagem

    Sending the link of an image including title, descriptive text and metadata:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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 imageUri = new Uri("http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg", UriKind.Absolute);
        var previewUri = new Uri("https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX", UriKind.Absolute);
    
        var document = new MediaLink
        {
            Title = "Cat",
            Text = "Here is a cat image for you!",
            Type = MediaType.Parse("image/jpeg"),
            AspectRatio = "1:1",
            Size = 227791,
            Uri = imageUri,
            PreviewUri = previewUri
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "title": "Cat",
            "text": "Here is a cat image for you!",
            "type": "image/jpeg",
            "uri": "http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg",
            "aspectRatio": "1:1",
            "size": 227791,
            "previewUri": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX",
            "previewType": "image/jpeg"
        }
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.media-link+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            title: "Cat",
            text: "Here is a cat image for you!",
            type: "image/jpeg",
            uri: "http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg",
            aspectRatio: "1:1",
            size: 227791,
            previewUri: "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX",
            previewType: "image/jpeg"
          }
        });
    

    Sending an audio link: (For more details, check the LIME protocol specification)

    var audioMediaLink = new MediaLink
    {
        Title = "Audio",
        Type = MediaType.Parse("audio/mp3"),
        Uri = new Uri("http://blaamandagjazzband.dk/jazz/mp3/basin_street_blues.mp3"),
        Size = 3124123,
        AspectRatio = "1:1"
    };
    
    await _sender.SendMessageAsync(audioMediaLink, message.From, cancellationToken);
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "2",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "type": "audio/mp3",
            "uri": "http://blaamandagjazzband.dk/jazz/mp3/basin_street_blues.mp3",
            "size": 3124123
        }
    }
    
    MIME type
    application/vnd.lime.media-link+json

    Allows sending and receiving of links for multimedia content. The link can be any valid URI, but most part of the channels only support content served by HTTP/HTTPS protocol. It is possible to include a title and a text, besides image metadada such as MIME type, size and preview.

    Some channels allow defining the display's aspect ratio for certain media types. For instance, in Messenger, you should set the 1:1 value for the aspectRatio property to send squared images.

        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.media-link+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            type: "audio/mp3",
            uri: "http://blaamandagjazzband.dk/jazz/mp3/basin_street_blues.mp3",
            size: 3124123
          }
        });
    

    For more details, check the LIME protocol specification.

    Channel mapping

    Channel Type
    BLiP Chat Media Link
    Messenger Attachments (image/audio/video/file, depending of MIME type)
    Whatsapp Media Link
    SMS Text with link
    Skype Activity
    Telegram Message

    Audio

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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)
    {
        Document document = new MediaLink
        {
            Type = MediaType.Parse("audio/mp3"),
            Uri = new Uri("http://blaamandagjazzband.dk/jazz/mp3/basin_street_blues.mp3"),
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.media-link+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            type: "audio/mp3",
            uri: "http://blaamandagjazzband.dk/jazz/mp3/basin_street_blues.mp3",
            size: 3124123
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "2",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "type": "audio/mp3",
            "uri": "http://blaamandagjazzband.dk/jazz/mp3/basin_street_blues.mp3",
            "size": "3124123"
        }
    }
    

    You can send sounds by uploading them or sharing a URL using the Media Link content type.

    Messenger BLiPChat
    imagem imagem

    Document/Files

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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 uriLink = new Uri("https://gradcollege.okstate.edu/sites/default/files/PDF_linking.pdf");
        var mediaTypeLink = new MediaType(MediaType.DiscreteTypes.Application, "pdf");
        var title = "pdf_open_parameters.pdf";
    
        Document document = new MediaLink
        {
            Title = title,
            Uri = uriLink,
            Type = mediaTypeLink,
            Size = 5540,
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.media-link+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            title: "pdf_open_parameters.pdf",
            uri: "https://gradcollege.okstate.edu/sites/default/files/PDF_linking.pdf",
            type: "application/pdf",
            size: 5540
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "title": "pdf_open_parameters.pdf",
            "uri": "https://gradcollege.okstate.edu/sites/default/files/PDF_linking.pdf",
            "type": "application/pdf",
            "size": 5540
        }
    }
    

    You can send documents like PDF's by uploading them or sharing a URL using the Media Link content type.

    Messenger BLiPChat
    imagem imagem

    Gif

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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 imageUri = new Uri("http://i.giphy.com/14aUO0Mf7dWDXW.gif");
    
        Document document = new MediaLink
        {
            Type = "image/gif",
            Uri = imageUri
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          to: "128271320123982@messenger.gw.msging.net",
          type: "application/vnd.lime.media-link+json",
          content: {
            type: "image/gif",
            uri: "http://i.giphy.com/14aUO0Mf7dWDXW.gif"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "uri": "http://i.giphy.com/14aUO0Mf7dWDXW.gif",
            "type": "image/gif"
        }
    }
    

    You can send gifs by uploading them or sharing a URL using the Media Link content type.

    Messenger BLiPChat
    imagem imagem

    Images

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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 imageUri = new Uri("http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg", UriKind.Absolute);
        var previewUri = new Uri("https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX", UriKind.Absolute);
    
        Document document = new MediaLink
        {
            Title = "Cat",
            Text = "Here is a cat image for you!",
            Type = MediaType.Parse("image/jpeg"),
            AspectRatio = "1:1",
            Size = 227791,
            Uri = imageUri,
            PreviewUri = previewUri
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
     client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.media-link+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            title: "Cat",
            text: "Here is a cat image for you!",
            type: "image/jpeg",
            uri: "http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg",
            aspectRatio: "1:1",
            size: 227791,
            previewUri: "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX",
            previewType: "image/jpeg"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "title": "Cat",
            "text": "Here is a cat image for you!",
            "type": "image/jpeg",
            "uri": "http://2.bp.blogspot.com/-pATX0YgNSFs/VP-82AQKcuI/AAAAAAAALSU/Vet9e7Qsjjw/s1600/Cat-hd-wallpapers.jpg",
            "aspectRatio": "1:1",
            "size": 227791,
            "previewUri": "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcS8qkelB28RstsNxLi7gbrwCLsBVmobPjb5IrwKJSuqSnGX4IzX",
            "previewType": "image/jpeg"
        }
    }
    

    You can send images by uploading them or sharing a URL using the Media Link content type. Supported formats are jpg, png and gif.

    Messenger BLiPChat
    imagem imagem

    Video

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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)
    {
        Document document = new MediaLink
        {
            Type = MediaType.Parse("video/mp4"),
            Uri = new Uri("http://techslides.com/demos/sample-videos/small.mp4"),
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          to: "128271320123982@messenger.gw.msging.net",
          type: "application/vnd.lime.media-link+json",
          content: {
            type: "video/mp4",
            uri: "http://techslides.com/demos/sample-videos/small.mp4"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "553199991111@0mn.io",
        "type": "application/vnd.lime.media-link+json",
        "content": {
            "uri": "http://techslides.com/demos/sample-videos/small.mp4",
            "type": "video/mp4"
        }
    }
    

    You can send videos by uploading them or sharing a URL using the Media Link content type.

    Messenger BLiPChat
    imagem imagem

    Creating a menu with 3 options

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    //Send an options list to give your client the choice between multiple answers using Select type:
    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)
    {
        jsonDocuments = new JsonDocument();
        jsonDocuments.Add("Key1", "value1");
        jsonDocuments.Add("Key2", "2");
    
        var document = new Select
        {
            //Scope = SelectScope.Immediate, (create a quickreply instead menu)
            Text = "Choose an option:",
            Options = new SelectOption[]
            {
                new SelectOption
                {
                    Order = 1,
                    Text = "First option!",
                    Value = new PlainText { Text = "1" }
                },
                new SelectOption
                {
                    Order = 2,
                    Text = "Second option",
                    Value = new PlainText { Text = "2" }
                },
                new SelectOption
                {
                    Order = 3,
                    Text = "Third option",
                    Value = jsonDocuments
                }
            }
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    
    }
    Note:
    
    //NOTE:
    //Value field is optional. If informed, your value will be sent to the chatbot when the user chooses the option.
    //If Value field is not provided, one of the following fields must be provided: Order or Text. The Order field will be used only if Value and Text is not provided.
    //
    //Limitations:
    //Facebook Messenger: Limit of 3 options. Otherwise, your message will not be delivered.
    //If sending more than 3 options is necessary, divide them into multiple messages.
    //Tangram SMS: The Value field will be ignored. Only the Order field will be sent if the option be selected.
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.select+json",
          to: "1042221589186385@messenger.gw.msging.net",
          content: {
            text: "Choose an option",
            options: [
                {
                    text: "First option"
                },
                {
                    order: 2,
                    text: "Second option"
                },
                {
                    order: 3,
                    text: "Third option",
                    type: "application/json",
                    value: {
                        key1: "value1",
                        key2: 2
                    }
                }
            ]
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id":"311F87C0-F938-4FF3-991A-7C5AEF7771A5",
        "to":"1042221589186385@messenger.gw.msging.net",
        "type":"application/vnd.lime.select+json",
        "content":{
            "text":"Choose an option",
            "options":[
                {
                    "text":"First option"
                },
                {
                    "order":2,
                    "text":"Second option"
                },
                {
                    "order":3,
                    "text":"Third option",
                    "type":"application/json",
                    "value":{
                        "key1":"value1",
                        "key2":2
                    }
                }
            ]
        }
    }
    
    MIME type
    application/vnd.lime.select+json

    Allows sending of a text menu to customers to make a choice. It is possible to define a document that may be delivered to the chatbot when the customer selects an option - depending on the channel support. The options can also be numbered, if needed.

    Some channels support the options scope limitation, which determines for how much time they are valid for the user selection. For example, in some cases, sent options can only be selected by the customer at that time and must disappear after the choice. In this case, the scope is immediate. In others, the options are valid for the selection at any time, and the scope is persistent.

    BLiP uses Select content type to send persistent or immediate menus. For more details, check the LIME protocol specification.

    Messenger BLiPChat
    imagem imagem

    JSON 1

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "f8cf7a7a-be4f-473a-8516-60d55534b5a6",
        "from": "1042221589186385@messenger.gw.msging.net",
        "to": "blipcontact@msging.net",
        "type": "text/plain",
        "content": "First option"
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.select+json",
          to: "blipcontact@msging.net",
          content: "First option"
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "f8cf7a7a-be4f-473a-8516-60d55534b5a6",
        "from": "1042221589186385@messenger.gw.msging.net",
        "to": "blipcontact@msging.net",
        "type": "text/plain",
        "content": "First option"
    }
    

    JSON 2

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "76CB408D-39E6-4212-8AA1-7435B42A6993",
        "from": "1042221589186385@messenger.gw.msging.net",
        "to": "blipcontact@msging.net",
        "type": "text/plain",
        "content": "Second option"
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.select+json",
          to: "blipcontact@msging.net",
          content: "Second option"
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "76CB408D-39E6-4212-8AA1-7435B42A6993",
        "from": "1042221589186385@messenger.gw.msging.net",
        "to": "blipcontact@msging.net",
        "type": "text/plain",
        "content": "Second option"
    }
    

    JSON 3

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "035E675C-D25B-437D-80BD-057AD6F70671",
        "from": "1042221589186385@messenger.gw.msging.net",
        "to": "blipcontact@msging.net",
        "type": "application/json",
        "content": {
            "key1":"value1",
            "key2":2
        }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.select+json",
          to: "blipcontact@msging.net",
          content: {
                key1: "value1",
                key2: 2
            }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "035E675C-D25B-437D-80BD-057AD6F70671",
        "from": "1042221589186385@messenger.gw.msging.net",
        "to": "blipcontact@msging.net",
        "type": "application/json",
        "content": {
            "key1":"value1",
            "key2":2
        }
    }
    

    When the user selects one option, a message returns according to the rule:

    Return example of the above mentioned menu:

    The return message type will always be the same as the chosen option. When a value for the field value is not defined, the type will be text/plain.

    Channel mapping

    Channel Type
    BLiP Chat Select
    Messenger Button template (on default scope) e Quick replies (on immediate scope)
    Whatsapp Text
    SMS Text
    Skype Activity
    Telegram Message

    Quick Replies

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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)
    {
        jsonDocuments = new JsonDocument();
        jsonDocuments.Add("Key1", "value1");
        jsonDocuments.Add("Key2", "2");
    
        Document document = new Select
        {
            Scope = SelectScope.Immediate,// (create a quickreply instead menu)
            Text = "Choose an option:",
            Options = new SelectOption[]
            {
                new SelectOption
                {
                    Order = 1,
                    Text = "First option!",
                    Value = new PlainText { Text = "1" }
                },
                new SelectOption
                {
                    Order = 2,
                    Text = "Second option",
                    Value = new PlainText { Text = "2" }
                },
                new SelectOption
                {
                    Order = 3,
                    Text = "Third option",
                    Value = jsonDocuments
                }
            }
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.select+json",
          to: "1042221589186385@messenger.gw.msging.net",
          content: {
            scope:"immediate", // (create a quickreply instead menu)
            text: "Choose an option",
            options: [
                {
                    text: "First option"
                },
                {
                    order: 2,
                    text: "Second option"
                },
                {
                    order: 3,
                    text: "Third option",
                    type: "application/json",
                    value: {
                        key1: "value1",
                        key2: 2
                    }
                }
            ]
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id":"311F87C0-F938-4FF3-991A-7C5AEF7771A5",
        "to":"1042221589186385@messenger.gw.msging.net",
        "type":"application/vnd.lime.select+json",
        "content":{
            "scope":"immediate",
            "text":"Choose an option",
            "options":[
                {
                    "text":"First option"
                },
                {
                    "order":2,
                    "text":"Second option"
                },
                {
                    "order":3,
                    "text":"Third option",
                    "type":"application/json",
                    "value":{
                        "key1":"value1",
                        "key2":2
                    }
                }
            ]
        }
    }
    

    Quick replies provide a way to present a set of up to 11 buttons in-conversation that contain a title and an optional image, and appear prominently above the composer. You can also use quick replies to request a person's location.

    You can send quick replies by using Select. To switch between menu and quick reply you only need to change the scope attribute. Quick replies requires scope to be 'immediate'.

    Messenger BLiPChat
    imagem imagem

    Multimedia menu

    Menu with image in the header and a link and text as options:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class OptionMultimidiaMenuMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionMultimidiaMenuMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    DocumentSelectOption[] options = new DocumentSelectOption[]
    {
        new DocumentSelectOption
        {
            Label = new DocumentContainer
            {
                Value = new WebLink
                {
                    Text = "Go to your site",
                    Uri = new Uri("https://meusanimais.com.br/14-nomes-criativos-para-o-seu-gato/")
                }
            }
        },
        new DocumentSelectOption
        {
            Label = new DocumentContainer
            {
                Value = new PlainText
                {
                    Text = "Show stock here!"
                }
            },
            Value = new DocumentContainer
            {
                Value = new JsonDocument()
            }
        }
    };
    
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new DocumentSelect
            {
                Header = new DocumentContainer
                {
                    Value = new MediaLink
                    {
                        Title = "Welcome to mad hatter",
                        Text = "Here we have the best hats for your head.",
                        Type = "image/jpeg",
                        Uri = new Uri("http://i.overboard.com.br/imagens/produtos/0741720126/Ampliada/chapeu-new-era-bucket-print-vibe.jpg"),
                        AspectRatio = "1.1"
                    }
                },
                Options = options
            };
    
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.document-select+json",
        "content": {
            "header": {
                "type": "application/vnd.lime.media-link+json",
                "value": {
                    "title": "Welcome to mad hatter",
                    "text": "Here we have the best hats for your head.",
                    "type": "image/jpeg",
                    "uri": "http://petersapparel.parseapp.com/img/item100-thumb.png",
                    "aspectRatio": "1:1"
                }
            },
            "options": [
                {
                    "label": {
                        "type": "application/vnd.lime.web-link+json",
                        "value": {
                            "text": "Go to our site",
                            "uri": "https://petersapparel.parseapp.com/view_item?item_id=100"
                        }
                    }
                },
                {
                    "label": {
                        "type": "text/plain",
                        "value": "Show stock"
                    },
                    "value": {
                        "type": "application/json",
                        "value": {
                            "action": "show-items"
                        }
                    }
                }
            ]
        }
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.document-select+json",
          to: "1042221589186385@messenger.gw.msging.net",
          content: {
                header: {
                    type: "application/vnd.lime.media-link+json",
                    value: {
                        title: "Welcome to mad hatter",
                        text: "Here we have the best hats for your head.",
                        type: "image/jpeg",
                        uri: "http://petersapparel.parseapp.com/img/item100-thumb.png",
                        aspectRatio: "1:1"
                    }
                },
                options: [
                    {
                        label: {
                            type: "application/vnd.lime.web-link+json",
                            value: {
                                text: "Go to our site",
                                uri: "https://petersapparel.parseapp.com/view_item?item_id=100"
                            }
                        }
                    },
                    {
                        label: {
                            type: "text/plain",
                            value: "Show stock"
                        },
                        value: {
                            type: "application/json",
                            value: {
                                action: "show-items"
                            }
                        }
                    }
                ]
            }
        });
    
    MIME type
    application/vnd.lime.document-select+json

    Allows sending an options menu to customers where the header and options can be of any content type, such as media link or web link, and not only text - like in the Select type. For each option, it is possible to define a document that is delivered to the contact when the customer performs a choice (depending on the channel support).

    For more details, check the LIME protocol specification.

    You can send carousels by using Document Collection content type and passing an array of Select type as the Items atribute.

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace MessageTypes
    {
        public class OptionDocumentCollectionMessageReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
            Document[] documents;
            JsonDocument jsonDocuments;
            JsonDocument jsonDocuments2;
            JsonDocument jsonDocuments3;
    
            public OptionDocumentCollectionMessageReceiver(ISender sender)
            {
                _sender = sender;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                Document document;
                document = getDocumentCollectionMenuMultimidia();
    
                await _sender.SendMessageAsync(document, message.From, cancellationToken);
            }
    
            public DocumentCollection getDocumentCollectionMenuMultimidia()
            {
                jsonDocuments = new JsonDocument();
                jsonDocuments2 = new JsonDocument();
                jsonDocuments3 = new JsonDocument();
    
                jsonDocuments.Add("Key1", "value1");
                jsonDocuments.Add("Key2", "2");
    
                jsonDocuments2.Add("Key3", "value3");
                jsonDocuments2.Add("Key4", "4");
    
                jsonDocuments3.Add("Key5", "value5");
                jsonDocuments3.Add("Key6", "6");
    
                DocumentSelect[] documents = new DocumentSelect[]
                {
                    new DocumentSelect
                    {
                        Header = new DocumentContainer
                        {
                            Value = new MediaLink
                            {
                                Title = "Title",
                                Text = "This is a first item",
                                Type = "image/jpeg",
                                Uri = new Uri("http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"),
                            }
                        },
                        Options = new DocumentSelectOption[]
                        {
                            new DocumentSelectOption
                            {
                                Label = new DocumentContainer
                                {
                                    Value = new WebLink
                                    {
                                        Title = "Link",
                                        Uri = new Uri("http://www.adoteumgatinho.org.br/")
                                    }
                                }
                            },
                            new DocumentSelectOption
                            {
                                Label = new DocumentContainer
                                {
                                    Value = new PlainText
                                    {
                                        Text = "Text 1"
                                    }
                                },
                                Value = new DocumentContainer
                                {
                                    Value = jsonDocuments
                                }
                            }
                        }
                    },
                    new DocumentSelect
                    {
                        Header = new DocumentContainer
                        {
                            Value = new MediaLink
                            {
                                Title = "Title 2",
                                Text = "This is another item",
                                Type = "image/jpeg",
                                Uri = new Uri("http://www.freedigitalphotos.net/images/img/homepage/87357.jpg")
                            }
                        },
                        Options = new DocumentSelectOption[]
                        {
                            new DocumentSelectOption
                            {
                                Label = new DocumentContainer
                                {
                                    Value = new WebLink
                                    {
                                        Title = "Second link",
                                        Text = "Weblink",
                                        Uri = new Uri("https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058")
                                    }
                                }
                            },
                            new DocumentSelectOption
                            {
                                Label = new DocumentContainer
                                {
                                    Value = new PlainText {
                                        Text = "Second text"
                                    }
                                },
                                Value = new DocumentContainer
                                {
                                    Value = jsonDocuments2
                                }
                            },
                            new DocumentSelectOption
                            {
                                Label = new DocumentContainer
                                {
                                    Value = new PlainText {
                                        Text = "More one text"
                                    }
                                },
                                Value = new DocumentContainer
                                {
                                    Value = jsonDocuments3
                                }
                            }
                        }
                    }
    
                };
    
                var document = new DocumentCollection
                {
                    ItemType = "application/vnd.lime.document-select+json",
                    Items = documents,
                };
    
                return document;
            }
        }
    }
    
    
     client.sendMessage({
            id: Lime.Guid(),
            type: "application/vnd.lime.collection+json",
            to: "128271320123982@messenger.gw.msging.net",
            content: {
                itemType: "application/vnd.lime.document-select+json",
                items: [
                    {
                        header: {
                            type: "application/vnd.lime.media-link+json",
                            value: {
                                title: "Title",
                                text: "This is a first item",
                                type: "image/jpeg",
                                uri: "http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"
                            }
                        },
                        options: [
                            {
                                label: {
                                    type: "application/vnd.lime.web-link+json",
                                    value: {
                                        title: "Link",
                                        uri: "http://www.adoteumgatinho.org.br/"
                                    }
                                }
                            },
                            {
                                label: {
                                    type: "text/plain",
                                    value: "Text 1"
                                },
                                value: {
                                    type: "application/json",
                                    value: {
                                        key1: "value1",
                                        key2: 2
                                    }
                                }
                            }
                        ]
                    },
                    {
                        header: {
                            type: "application/vnd.lime.media-link+json",
                            value: {
                                title: "Title 2",
                                text: "This is another item",
                                type: "image/jpeg",
                                uri: "http://www.freedigitalphotos.net/images/img/homepage/87357.jpg"
                            }
                        },
                        options: [
                            {
                                label: {
                                    type: "application/vnd.lime.web-link+json",
                                    value: {
                                        title: "Second link",
                                        text: "Weblink",
                                        uri: "https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058"
                                    }
                                }
                            },
                            {
                                label: {
                                    type: "text/plain",
                                    value: "Second text"
                                },
                                value: {
                                    type: "application/json",
                                    value: {
                                        key3: "value3",
                                        key4: 4
                                    }
                                }
                            },
                            {
                                label: {
                                    type: "text/plain",
                                    value: "More one text"
                                },
                                value: {
                                    type: "application/json",
                                    value: {
                                        key5: "value5",
                                        key6: 6
                                    }
                                }
                            }
                        ]
                    }
                ]
            }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "5",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.collection+json",
        "content": {
            "itemType": "application/vnd.lime.document-select+json",
            "items": [
                {
                    "header": {
                        "type": "application/vnd.lime.media-link+json",
                        "value": {
                            "title": "Title",
                            "text": "This is a first item",
                            "type": "image/jpeg",
                            "uri": "http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"
                        }
                    },
                    "options": [
                        {
                            "label": {
                                "type": "application/vnd.lime.web-link+json",
                                "value": {
                                    "title": "Link",
                                    "uri": "http://www.adoteumgatinho.org.br"
                                }
                            }
                        },
                        {
                            "label": {
                                "type": "text/plain",
                                "value": "Text 1"
                            },
                            "value": {
                                "type": "application/json",
                                "value": {
                                    "key1": "value1",
                                    "key2": "2"
                                }
                            }
                        }
                    ]
                },
                {
                    "header": {
                        "type": "application/vnd.lime.media-link+json",
                        "value": {
                            "title": "Title 2",
                            "text": "This is another item",
                            "type": "image/jpeg",
                            "uri": "http://www.freedigitalphotos.net/images/img/homepage/87357.jpg"
                        }
                    },
                    "options": [
                        {
                            "label": {
                                "type": "application/vnd.lime.web-link+json",
                                "value": {
                                    "title": "Second link",
                                    "text": "Weblink",
                                    "uri": "https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058"
                                }
                            }
                        },
                        {
                            "label": {
                                "type": "text/plain",
                                "value": "Second text"
                            },
                            "value": {
                                "type": "application/json",
                                "value": {
                                    "key3": "value3",
                                    "key4": "4"
                                }
                            }
                        },
                        {
                            "label": {
                                "type": "text/plain",
                                "value": "More one text"
                            },
                            "value": {
                                "type": "application/json",
                                "value": {
                                    "key5": "value5",
                                    "key6": "6"
                                }
                            }
                        }
                    ]
                }
            ]
        }
    }
    
    Messenger
    imagem imagem
    BLiPChat
    imagem imagem

    Multimedia Menu Channel mapping

    Channel Type
    BLiP Chat Document select
    Messenger Generic template
    Whatsapp Text
    SMS Text
    Skype Activity
    Telegram Message

    Native Content

    Sending a Messenger text message:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace MessageTypes
    {
      public class OptionNativeContentReceiver : IMessageReceiver
      {
          private readonly ISender _sender;
          private readonly Settings _settings;
    
          public OptionNativeContentReceiver(ISender sender)
          {
              _sender = sender;
              _settings = settings;
          }
    
          public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
          {
              JsonDocument document = new JsonDocument();
    +         document.Add("text", "hello, world!"); //exemplo funcional no messenger
    
              await _sender.SendMessageAsync(document, message.From, cancellationToken);
          }
      }
    
    }
    
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id":"1",
      "to":"949839515125748@messenger.gw.msging.net",
      "type":"application/json",
      "content":{
        "text": "hello, world!"
      }
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.payment-receipt+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
              text: "hello, world!"
          }
        });
    

    2 - Sending an airline boardingpass template message type to Messenger:

    /*
    No examples for C# here
    still possible but is too big for this doc
    */
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.payment-receipt+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            attachment:{
              type: "template",
              payload:{
                template_type: "airline_boardingpass",
                intro_message: "You are checked in.",
                locale: "en_US",
                boarding_pass:[
                  {
                    passenger_name: "SMITH\/NICOLAS",
                    pnr_number: "CG4X7U",
                    travel_class: "business",
                    seat: "74J",
                    auxiliary_fields:[
                      {
                        label: "Terminal",
                        value: "T1"
                      },
                      {
                        label: "Departure",
                        value: "30OCT 19:05"
                      }
                    ],
                    secondary_fields:[
                      {
                        label: "Boarding",
                        value: "18:30"
                      },
                      {
                        label: "Gate",
                        value: "D57"
                      },
                      {
                        label: "Seat",
                        value: "74J"
                      },
                      {
                        label: "Sec.Nr.",
                        value: "003"
                      }
                    ],
                    logo_image_url: "https://www.example.com/en/logo.png",
                    header_image_url: "https://www.example.com/en/fb/header.png",
                    qr_code: "M1SMITH/NICOLAS  CG4X7U nawouehgawgnapwi3jfa0wfh",
                    above_bar_code_image_url: "https://www.example.com/en/PLAT.png",
                    flight_info:{
                      flight_number: "KL0642",
                      departure_airport:{
                        airport_code: "JFK",
                        city: "New York",
                        terminal: "T1",
                        gate: "D57"
                      },
                      arrival_airport:{
                        airport_code: "AMS",
                        city: "Amsterdam"
                      },
                      flight_schedule:{
                        departure_time: "2016-01-02T19:05",
                        arrival_time: "2016-01-05T17:30"
                      }
                    }
                  },
                  {
                    passenger_name: "JONES/FARBOUND",
                    pnr_number: "CG4X7U",
                    travel_class: "business",
                    seat: "74K",
                    auxiliary_fields:[
                      {
                        label: "Terminal",
                        value: "T1"
                      },
                      {
                        label: "Departure",
                        value: "30OCT 19:05"
                      }
                    ],
                    secondary_fields:[
                      {
                        label: "Boarding",
                        value: "18:30"
                      },
                      {
                        label: "Gate",
                        value: "D57"
                      },
                      {
                        label: "Seat",
                        value: "74K"
                      },
                      {
                        label: "Sec.Nr.",
                        value: "004"
                      }
                    ],
                    logo_image_url: "https://www.example.com/en/logo.png",
                    header_image_url: "https://www.example.com/en/fb/header.png",
                    qr_code: "M1JONES/FARBOUND  CG4X7U nawouehgawgnapwi3jfa0wfh",
                    above_bar_code_image_url: "https://www.example.com/en/PLAT.png",
                    flight_info:{
                      flight_number: "KL0642",
                      departure_airport:{
                        airport_code: "JFK",
                        city: "New York",
                        terminal: "T1",
                        gate: "D57"
                      },
                      arrival_airport:{
                        airport_code: "AMS",
                        city: "Amsterdam"
                      },
                      flight_schedule:{
                        departure_time: "2016-01-02T19:05",
                        arrival_time: "2016-01-05T17:30"
                      }
                    }
                  }
                ]
              }
            }
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id":"2",
      "to":"949839515125748@messenger.gw.msging.net",
      "type":"application/json",
      "content":{
        "attachment":{
          "type":"template",
          "payload":{
            "template_type":"airline_boardingpass",
            "intro_message":"You are checked in.",
            "locale":"en_US",
            "boarding_pass":[
              {
                "passenger_name":"SMITH\/NICOLAS",
                "pnr_number":"CG4X7U",
                "travel_class":"business",
                "seat":"74J",
                "auxiliary_fields":[
                  {
                    "label":"Terminal",
                    "value":"T1"
                  },
                  {
                    "label":"Departure",
                    "value":"30OCT 19:05"
                  }
                ],
                "secondary_fields":[
                  {
                    "label":"Boarding",
                    "value":"18:30"
                  },
                  {
                    "label":"Gate",
                    "value":"D57"
                  },
                  {
                    "label":"Seat",
                    "value":"74J"
                  },
                  {
                    "label":"Sec.Nr.",
                    "value":"003"
                  }
                ],
                "logo_image_url":"https://www.example.com/en/logo.png",
                "header_image_url":"https://www.example.com/en/fb/header.png",
                "qr_code":"M1SMITH/NICOLAS  CG4X7U nawouehgawgnapwi3jfa0wfh",
                "above_bar_code_image_url":"https://www.example.com/en/PLAT.png",
                "flight_info":{
                  "flight_number":"KL0642",
                  "departure_airport":{
                    "airport_code":"JFK",
                    "city":"New York",
                    "terminal":"T1",
                    "gate":"D57"
                  },
                  "arrival_airport":{
                    "airport_code":"AMS",
                    "city":"Amsterdam"
                  },
                  "flight_schedule":{
                    "departure_time":"2016-01-02T19:05",
                    "arrival_time":"2016-01-05T17:30"
                  }
                }
              },
              {
                "passenger_name":"JONES/FARBOUND",
                "pnr_number":"CG4X7U",
                "travel_class":"business",
                "seat":"74K",
                "auxiliary_fields":[
                  {
                    "label":"Terminal",
                    "value":"T1"
                  },
                  {
                    "label":"Departure",
                    "value":"30OCT 19:05"
                  }
                ],
                "secondary_fields":[
                  {
                    "label":"Boarding",
                    "value":"18:30"
                  },
                  {
                    "label":"Gate",
                    "value":"D57"
                  },
                  {
                    "label":"Seat",
                    "value":"74K"
                  },
                  {
                    "label":"Sec.Nr.",
                    "value":"004"
                  }
                ],
                "logo_image_url":"https://www.example.com/en/logo.png",
                "header_image_url":"https://www.example.com/en/fb/header.png",
                "qr_code":"M1JONES/FARBOUND  CG4X7U nawouehgawgnapwi3jfa0wfh",
                "above_bar_code_image_url":"https://www.example.com/en/PLAT.png",
                "flight_info":{
                  "flight_number":"KL0642",
                  "departure_airport":{
                    "airport_code":"JFK",
                    "city":"New York",
                    "terminal":"T1",
                    "gate":"D57"
                  },
                  "arrival_airport":{
                    "airport_code":"AMS",
                    "city":"Amsterdam"
                  },
                  "flight_schedule":{
                    "departure_time":"2016-01-02T19:05",
                    "arrival_time":"2016-01-05T17:30"
                  }
                }
              }
            ]
          }
        }
      }
    }
    
    MIME type
    application/json

    Allows sending of a native content of some channel using JSON format. It is possible to use any channel's available resource, even if this content is not yet supported as a BLiP canonical type.

    Note that, for a multi channel chatbot, it is the chatbot developer's responsibility to send the correct content type to each channel.

    Channel mapping

    Channel Type
    BLiP App Does not support
    Messenger Supported (the property content refers to message element of Messenger Send API
    Whatsapp Does not support
    SMS Does not support
    Skype Does not support
    Telegram Does not support

    Payment Invoice

    Example - Sending a payment request to a Facebook Messenger user using PagSeguro:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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 Invoice
        {
            Currency = "BLR",
            DueTo = DateTime.Now.AddDays(1),
            Total = 10,
            Items =
                new InvoiceItem[]
                {
                    new InvoiceItem
                    {
                        Currency = "BRL",
                        Unit = 10,
                        Description = "Subscription for product: Hit",
                        Quantity = 1,
                        Total = 10
                    }
                },
        };
    
        var toPagseguro = $"{Uri.EscapeDataString(message.From.ToIdentity().ToString())}@pagseguro.gw.msging.net";
    
        await _sender.SendMessageAsync(document, toPagseguro, cancellationToken);
    }
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.invoice+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            created: "2016-08-26T19:03:37.024Z",
            dueTo: "2016-08-27T19:03:37.024Z",
            currency: "BRL",
            total: 10.85,
            items: [
                {
                    quantity: 1.0,
                    unit: 10.85,
                    currency: "BRL",
                    total: 10.85,
                    description:"Subscription for product: Hit"
                }
            ]
        }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385%40messenger.gw.msging.net@pagseguro.gw.msging.net",
        "type": "application/vnd.lime.invoice+json",
        "content": {
            "created":"2016-08-26T19:03:37.024Z",
            "dueTo":"2016-08-27T19:03:37.024Z",
            "currency":"BRL",
            "total":10.85,
            "items":[
                {
                    "quantity":1.0,
                    "unit":10.85,
                    "currency":"BRL",
                    "total":10.85,
                    "description":"Subscription for product: Hit"
                }
            ]
        }
    }
    
    MIME type
    application/vnd.lime.invoice+json

    Allows sending of a payment request to a payment channel.

    Note: Payment invoices are not mapped to channel's cards. The purpose of such messages is only to control the payment's life cycle.

    Payment receipt

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class InvoiceStatusReceiver : IMessageReceiver
    {
    private readonly IMessagingHubSender _sender;
    
    public InvoiceStatusReceiver(IMessagingHubSender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var invoiceStatus = message.Content as InvoiceStatus;
        switch (invoiceStatus?.Status)
        {
            case InvoiceStatusStatus.Cancelled:
                await _sender.SendMessageAsync("Ok, you don't need pay anything.", message.From, cancellationToken);
                break;
            case InvoiceStatusStatus.Completed:
                await _sender.SendMessageAsync("Thank you for your payment, this is only a test", message.From, cancellationToken);
                var document = new PaymentReceipt
                {
                    Currency = "BLR",
                    Total = 10
                    Items =
                        new[]
                        {
                            new InvoiceItem
                            {
                                Currency = "BRL",
                                Unit = 10,
                                Description = "Item 1",
                                Quantity = 10,
                                Total = 10
                            }
                        },
                };
                await _sender.SendMessageAsync(document, message.From, cancellationToken);
                break;
            case InvoiceStatusStatus.Refunded:
                await _sender.SendMessageAsync("Ok, your payment was refunded by PagSeguro!", message.From, cancellationToken);
                break;
        }
    }
    }
    
        client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.payment-receipt+json",
          to: "128271320123982@messenger.gw.msging.net",
          content: {
            paidOn: "2016-08-26T19:03:37.024Z",
            code: "215BF6B5-01EF-4F9A-A944-0BC05FD0F228",
            method: {
                    name: "Credit Card"
            },
            currency: "BRL",
            total: 10.85,
            items: [{
                    quantity: 1.0,
                    unit: 10.85,
                    currency: "BRL",
                    total: 10.85,
                    description: "Item 1"
                }
            ]
        }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.payment-receipt+json",
        "content": {
            "paidOn": "2016-08-26T19:03:37.024Z",
            "code": "215BF6B5-01EF-4F9A-A944-0BC05FD0F228",
            "method": {
                    "name": "Credit Card"
            },
            "currency": "BRL",
            "total": 10.85,
            "items": [{
                    "quantity": 1.0,
                    "unit": 10.85,
                    "currency": "BRL",
                    "total": 10.85,
                    "description": "Item 1"
                }
            ]
        }
    }
    
    MIME type
    application/vnd.lime.payment-receipt+json

    Allows sending of a payment receipt to a customer.

    In order to realize a payment on your chatbot, it is necessary to use the payment channel. For now, only the PagSeguro channel is supported. To request a payment, the chatbot must send a message of type Invoice to the payment channel informing the user address using the format at right bar.

    Example

    Sending a payment receipt to a Messenger user:

    Channel mapping

    Channel Type
    BLiP Chat Not supported yet
    Messenger Receipt template
    Whatsapp Text
    SMS Text
    Skype Activity
    Telegram Message

    Plain Text

    MIME type
    text/plain

    Allows sending and receiving simple text messages.

    Sending a message to a Messenger recipient:

        client.sendMessage({
            id: Lime.Guid(),
            type: "text/plain",
            to: "128271320123982@messenger.gw.msging.net",
            content: "Welcome to our service! How can I help you?"
            });
    
    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, message.From, cancellationToken);
    }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "128271320123982@messenger.gw.msging.net",
        "type": "text/plain",
        "content": "Welcome to our service! How can I help you?"
    }
    

    For more details, check the specification of LIME protocol.

    Messenger BLiPChat
    imagem imagem

    Channel mapping

    Channel Type
    BLiP Chat Text
    Messenger Text message
    Whatsapp Text
    SMS Text
    Skype Activity
    Telegram Message

    Redirect

    1 - Redirecting to the attendance service

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class OptionRedirectMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionRedirectMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new Redirect
        {
            Address = "atendimento"
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "54f1dd2e-42d2-43f2-9100-68fbbabb9c83@tunnel.msging.net",
        "type": "application/vnd.lime.redirect+json",
        "content": {
            "address": "attendance"
        }
    }
    
    client.sendMessage({
        id: Lime.Guid(),
        to: "54f1dd2e-42d2-43f2-9100-68fbbabb9c83@tunnel.msging.net",
        type: "application/vnd.lime.redirect+json",
        content: {
            address: "attendance",
        }
    });
    

    From this moment, the messages sent by the client will be forwarded to the chatbot configured as service attendance in the master model settings tab. Note: The customer identifier is not the same for the other bot.

    2 - Redirecting to the chatbot with identifier mysdkbot , passing a document as the context of the conversation.

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class SpecificRedirectPassingContext : IMessageReceiver
    {
        private readonly ISender _sender;
        private readonly Settings _settings;
    
        public SpecificRedirectPassingContext(ISender sender)
        {
            _sender = sender;
            _settings = settings;
        }
    
        public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
        {
           var document = new Redirect
            {
                Address = "mysdkbot@msging.net",
                Context = new DocumentContainer {
                    Value = new PlainText {
                        Text = "Get Started"
                    }
                }
            };
    
            await _sender.SendMessageAsync(document, message.From, cancellationToken);
        }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "2",
        "to": "54f1dd2e-42d2-43f2-9100-68fbbabb9c83@tunnel.msging.net",
        "type": "application/vnd.lime.redirect+json",
        "content": {
            "address": "mysdkbot@msging.net",
            "context": {
                "type": "text/plain",
                "value": "Get started"
            }
        }
    }
    
    client.sendMessage({
        id: Lime.Guid(),
        to: "54f1dd2e-42d2-43f2-9100-68fbbabb9c83@tunnel.msging.net",
        type: "application/vnd.lime.redirect+json",
        content: {
            address: "mysdkbot@msging.net",
            context: {
                type: "text/plain",
                value: "Get started"
            }
        }
    });
    

    In this example, the chatbot with mysdkbot identifier will receive the messages sent by the client, in addition to receiving a message with the content defined in the context, as if it had been sent by the client:

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "3",
        "from": "2bdcd8d0-9e69-484f-a88a-d5a529708864@tunnel.msging.net",
        "to": "mysdkbot@msging.net",
        "type": "text/plain",
        "content": "Get started"
    }
    
    {
        id: "3",
        from: "2bdcd8d0-9e69-484f-a88a-d5a529708864@tunnel.msging.net",
        to: "mysdkbot@msging.net",
        type: "text/plain",
        content: "Get started"
    }
    
    MIME type
    application/vnd.lime.redirect+json

    Allows the redirection of a particular chatbot conversation to a new address. In practice, it makes the handover of a conversation between different chatbots possible, which can be of any template (FAQ, Human Operator) or SDK / Webhooks.

    Currently, redirection is only supported on chatbots configured as services in master template. This can be done using the chatbot (identifier) address or the service name defined in the master model settings in the portal.

    It is possible to define a document that represents the context of the conversation and that will be received by the chatbot to which the conversation was directed. The context is useful for defining a specific flow in the destination chatbot, for example.

    Channel mapping

    Redirect is currently supported only by chatbots configured as services in the master template. In this case, all messages will have the domain @tunnel.msging.net, since the master template uses the tunnel extension for communication with services (sub-bots).

    Resource

    Sending a resource message with the welcome-message identifier:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class OptionResourceMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionResourceMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var document = new Resource
        {
            Key = "welcome-message" //recurso previamente adicionado com extensão 'recursos' ou através do portal
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.iris.resource+json",
        "content": {
            "key": "welcome-message"
        }
    }
    
    client.sendMessage({
        id: Lime.Guid(),
        type: "application/vnd.iris.resource+json",
        to: "1042221589186385@messenger.gw.msging.net",
        content: {
            key: "welcome-message"
        }
    });
    

    In case there is a resource with this key, the server replaces the content and forwards it to the destination. Imagining that the resource with welcome-message key is a text/plain document with value Welcome to our service, the final message would be like this:

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "text/plain",
        "content": "Welcome to our service"
    }
    
    {
        id: "1",
        to: "1042221589186385@messenger.gw.msging.net",
        type: "text/plain",
        content: "Welcome to our service"
    }
    
    MIME type
    application/vnd.iris.resource+json

    Allows sending of a message where the content is a resource stored in the server. The resource should be stored through the resources extension. The server automatically replaces the content with the stored resource, in case the resource key already exists for the caller chatbot.

    The resource may contain variables which can be replaced by values specified during sending time, through the variables property.

    You can enter substitution variables for the resource using the variables property. In this case, the variables present in the resource with the ${variableName} format are replaced by the specified values.

    For example, imagine that the resource in the welcome-message key has the value Welcome to our service, ${name}!'. If you send the following:

    Request

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class ResourceMessageReplace : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public ResourceMessageReplace(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var openWith = new Dictionary<string, string>();
        openWith.Add("name",message.From.Name);
    
        var document = new Resource
        {
            Key = "welcome-message",
            Variables = openWith
    
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "application/vnd.iris.resource+json",
        "content": {
            "key": "welcome-message",
            "variables": {
                "name": "John Doe"
            }
        }
    }
    
    client.sendMessage({
        id: Lime.Guid(),
        to: "1042221589186385@messenger.gw.msging.net",
        type: "application/vnd.iris.resource+json",
        content: {
            key: "welcome-message",
            variables: {
                name: "John Doe"
            }
        }
    });
    

    The final message will be:

    Response

    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042221589186385@messenger.gw.msging.net",
        "type": "text/plain",
        "content": "Welcome to our service, John Doe!"
    }
    
    {
        id: "1",
        to: "1042221589186385@messenger.gw.msging.net",
        type: "text/plain",
        content: "Welcome to our service, John Doe!"
    }
    

    Channel mapping

    This content type is supported on all channels.

    Quick Replies

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    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)
    {
        jsonDocuments = new JsonDocument();
        jsonDocuments.Add("Key1", "value1");
        jsonDocuments.Add("Key2", "2");
    
        Document document = new Select
        {
            Scope = SelectScope.Immediate,// (create a quickreply instead menu)
            Text = "Choose an option:",
            Options = new SelectOption[]
            {
                new SelectOption
                {
                    Order = 1,
                    Text = "First option!",
                    Value = new PlainText { Text = "1" }
                },
                new SelectOption
                {
                    Order = 2,
                    Text = "Second option",
                    Value = new PlainText { Text = "2" }
                },
                new SelectOption
                {
                    Order = 3,
                    Text = "Third option",
                    Value = jsonDocuments
                }
            }
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.select+json",
          to: "1042221589186385@messenger.gw.msging.net",
          content: {
            scope:"immediate", // (create a quickreply instead menu)
            text: "Choose an option",
            options: [
                {
                    text: "First option"
                },
                {
                    order: 2,
                    text: "Second option"
                },
                {
                    order: 3,
                    text: "Third option",
                    type: "application/json",
                    value: {
                        key1: "value1",
                        key2: 2
                    }
                }
            ]
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id":"311F87C0-F938-4FF3-991A-7C5AEF7771A5",
        "to":"1042221589186385@messenger.gw.msging.net",
        "type":"application/vnd.lime.select+json",
        "content":{
            "scope":"immediate",
            "text":"Choose an option",
            "options":[
                {
                    "text":"First option"
                },
                {
                    "order":2,
                    "text":"Second option"
                },
                {
                    "order":3,
                    "text":"Third option",
                    "type":"application/json",
                    "value":{
                        "key1":"value1",
                        "key2":2
                    }
                }
            ]
        }
    }
    

    Quick replies provide a way to present a set of up to 11 buttons in-conversation that contain a title and an optional image, and appear prominently above the composer. You can also use quick replies to request a person's location.

    You can send quick replies by using Select. To switch between menu and quick reply you only need to change the scope attribute. Quick replies requires scope to be 'immediate'.

    Messenger BLiPChat
    imagem imagem

    Sensitive information

    Sending a password using text content for a Messenger user:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class OptionSensitiveMessageReceiver : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public OptionSensitiveMessageReceiver(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
    
        var document = new SensitiveContainer
        {
            Value = "Your password is 123456"
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.sensitive+json",
          to: "1042225583186385@messenger.gw.msging.net",
          content: {
            type: "text/plain",
            value: "Your password is 123456"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "1",
      "to": "1334448251684655@messenger.gw.msging.net",
      "type": "application/vnd.lime.sensitive+json",
      "content": {
        "type": "text/plain",
        "value": "Your password is 123456"
      }
    }
    
    

    Sending a weblink:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    public class SensitiveWeblinkMessage : IMessageReceiver
    {
    private readonly ISender _sender;
    private readonly Settings _settings;
    
    public SensitiveWeblinkMessage(ISender sender)
    {
        _sender = sender;
        _settings = settings;
    }
    
    public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
    {
        var url = new Uri("https://mystore.com/checkout?ID=A8DJS1JFV98AJKS9");
        var document = new SensitiveContainer
        {
            Value = new WebLink
            {
                Text = "Please follow this link for the checkout",
                Uri = url
            }
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    }
    
    client.sendMessage({
          id: Lime.Guid(),
          type: "application/vnd.lime.sensitive+json",
          to: "1042225583186385@messenger.gw.msging.net",
          content: {
            type: "application/vnd.lime.web-link+json",
            value: {
              text: "Please follow this link for the checkout",
              uri: "https://mystore.com/checkout?ID=A8DJS1JFV98AJKS9"
            }
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "2",
      "to": "1334448251684655@messenger.gw.msging.net",
      "type": "application/vnd.lime.sensitive+json",
      "content": {
        "type": "application/vnd.lime.web-link+json",
        "value": {
          "text": "Please follow this link for the checkout",
          "uri": "https://mystore.com/checkout?ID=A8DJS1JFV98AJKS9"
        }
      }
    }
    
    
    MIME type
    application/vnd.lime.sensitive+json

    Wraps a message content in order to signal that the information is confidential or sensitive. In this case, the server will not store the message content in any moment. The wrapped content can be of any available BLiP type.

    Important note: This is restricted to the BLiP servers. External channels (Messenger, Telegram, etc.) still can store your information in some way. Pay attention on particular security polices for each channel.

    Sending a message to a Messenger recipient:

    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Messaging.Contents;
    using Lime.Protocol;
    using Take.Blip.Client;
    //To send a web page link use the WebLink type:
    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 url = new Uri("http://limeprotocol.org/content-types.html#web-link");
        var previewUri =
            new Uri("techbeacon.scdn7.secure.raxcdn.com/sites/default/files/styles/article_hero_image/public/documents-stack-documentation-agile-devops.jpg?itok=cFDq9Y95");
    
        var document = new WebLink
        {
            Text = "Here is a documentation weblink",
    +       Target = WebLinkTarget.Self,
            PreviewUri = previewUri,
            Uri = url
        };
    
        await _sender.SendMessageAsync(document, message.From, cancellationToken);
    }
    
    }
    
    client.sendMessage({s
          id: Lime.Guid(),
          type: "application/vnd.lime.web-link+json",
          to: "1042225583186385@messenger.gw.msging.net",
          content: {
            uri: "http://limeprotocol.org/content-types.html#web-link",
            target: "self",
            text: "Here is a documentation weblink"
          }
        });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "1",
        "to": "1042225583186385@messenger.gw.msging.net",
        "type": "application/vnd.lime.web-link+json",
        "content": {
            "uri": "http://limeprotocol.org/content-types.html#web-link",
            "target": "self",
            "text": "Here is a documentation weblink"
        }
    }
    
    MIME type
    application/vnd.lime.web-link+json

    Allows sending of a link for a webpage to the client including metadata, such as link's title, description and a miniature image.

    Sending a message to a Messenger recipient:

    In some channels, it is possible to define how the webpage will be displayed (on the same window, openning a new window or occupying part of the device window) through the target property. For more details, check the LIME protocol specification.

    Channel mapping

    Channel Type
    BLiP Chat Web Link
    Messenger Generic template or Button (if used with the Multimedia Menu).
    Whatsapp Media Link
    SMS Text with link
    Skype Activity
    Telegram Message

    It is also possible in some channels to use special URI schemes to create links with specific behaviors as below:

    Channel URI Scheme Description Example
    Messenger tel Defines a link for the telephone call to the specific number. Mapped to a Call button. tel:+5531999990000
    Messenger share Defines a link to share current message. Mapped to a Share button. share:

    Extensions

    Extensions are BLiP connected services that provide developers with different features for their chatbots. The extensions can receive commands and messages from the chatbots and execute special tasks, e.g. schedule or send a message broadcast. Through BLiP extensions the bot's developer can reuse a lot of code and focus only on bot's logic.

    As the other platform nodes, each extension has a unique address with postmaster@[identifier].msging.net format. The identifier value is the extension sub domain. Thus, to send commands and messages, use this address. If you don't know what is a command or how you can use this on BLiP, please go to Concepts > Commands section.

    Some extensions can require permission to send messages in name of the chatbot. The command delegation is used to grant this permission and must be sent to server with postmaster@msging.net address. To learn more details, check the delegation documentation.

    Artificial Intelligence

    Address
    postmaster@ai.msging.net

    The Artificial Intelligence extension allows the creation, training and publication of artificial intelligence models in the providers associated with the chatbot, besides performing sentence analysis to identify intents and entities. The configuration of the chatbot providers is done through the Artificial Intelligence menu in the BLiP portal.

    You can associate response documents with the model that should be submitted when an intent is matched in a sentence. In addition, the extension can be used to improve the model by associating questions with intents.

    The training of the model is performed simultaneously on all of the AI ​​providers associated with chatbot. In that case, a snapshot of the model is stored and can be retrieved later to compare its effectiveness with other versions. To use a trained template, you must publish it.

    All manipulation of the model can be done through the portal of the BLiP, and this extension can be used only to perform the analysis of sentences of the users of the chabot.

    API Resources

    URI Method Description
    /intentions set Creates a new intent. The id of the intent is returned in the command response.
    /intentions get Search in all intents that are associated to the chatbot. It is possible to paginate the request using $skip and $take arguments.
    /intentions/{id} get Retrieves an intent by its id.
    /entities set Creates a new entity. The id of the entity is returned in the command response.
    /entities get Search in all intents that are associated to the chatbot. It is possible to paginate the request using $skip and $take arguments.
    /entities/{id} get Retrieves an entity by its id.
    /intentions/{id}/questions set Create questions associated to the intent id.
    /intentions/{id}/questions get Search in all questions that are associated to the intent id. It is possible to paginate the request using $skip and $take arguments.
    /intentions/{id}/questions/{qid} delete Removes the question with id qid.
    /intentions/{id}/answers set Create answers associated to the intent id.
    /intentions/{id}/answers get Search in all answers that are associated to the intent id. It is possible to paginate the request using $skip and $take arguments.
    /intentions/{id}/answers/{aid} delete Removes the answer with id aid.
    /models set Executes the training or publishing of the model. The action depends of the type of the resource (see the table below).
    /models get Search in all trained and/or published models.
    /analysis set Analyzes an user sentence using a published model.
    /analysis get Retrieves the history of performed analysis. It is possible to paginate the request using using $skip and $take arguments and filter with $filter, using the OData syntax.
    /analysis/{id}/feedback set Provides feedback to a performed analysis and suggest an intent to improve the model.

    The resource types are:

    Name MIME Type Description
    Intent application/vnd.iris.ai.intention+json Intent expressed through a sentence.
    Entity application/vnd.iris.ai.entity+json Entity identified in an intent, with its synonyms.
    Question application/vnd.iris.ai.question+json A user's question that is associated with an intent for model training.
    Answer application/vnd.iris.ai.answer+json Response that can be sent in case a user's intent is identified.
    Training application/vnd.iris.ai.model-training+json Model training request.
    Publishing application/vnd.iris.ai.model-publishing+json Model publishing request, to make it available for use.
    Analisys request application/vnd.iris.ai.analysis-request+json Sentence analysis request.
    Analisys response application/vnd.iris.ai.analysis-response+json Sentence analysis response with the identified intents and entities.
    Analisys application/vnd.iris.ai.analysis+json History information about a performed analysis.
    Analisys feedback application/vnd.iris.ai.analysis-feedback+json Feedback information about a performed analysis.

    Create an entity

    Defining the entities present in user phrases.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/entities',
        type: 'application/vnd.iris.ai.entity+json',
        resource: {
          name: 'Flavor',
          values: [
            {
              name: 'Pepperoni',
              synonymous: [
                'Peperoni',
                'Pepperonee',
                'Pepperouni',
                'Peperony'
              ]
            },
            {
              name: 'Mushrooms',
              synonymous: [
                'Mashrooms',
                'Mushroom',
                'Mshrooms'
              ]
            }
          ]
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "1",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/entities",
      "type": "application/vnd.iris.ai.entity+json",
      "resource": {
        "name": "Flavor",
        "values": [
          {
            "name": "Pepperoni",
            "synonymous": [
              "Peperoni",
              "Pepperonee",
              "Pepperouni",
              "Peperony"
            ]
          },
          {
            "name": "Mushrooms",
            "synonymous": [
              "Mashrooms",
              "Mushroom",
              "Mshrooms"
            ]
          }
        ]
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.iris.ai.entity+json",
      "resource": {
        "id": "flavor"
      },
      "method": "set",
      "status": "success",
      "id": "1",
      "from": "postmaster@ai.msging.net/#az-iris6",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/entities"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extensions
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var entity = new Entity{
                    Name = "Flavor",
                    Values = new [] { 
                        new EntityValues {
                            Name = "Pepperoni",
                            Synonymous = new [] {
                                "Peperoni",
                                "Pepperonee",
                                "Pepperouni",
                                "Peperony"
                            },
                        },
                        new EntityValues {
                            Name = "Mushrooms",
                            Synonymous = new [] {
                                "Mashrooms",
                                "Mushroom",
                                "Mshrooms"
                            }
                        }
                    }
                };
    
                await _artificialIntelligenceExtension.SetEntityAsync(entity, cancellationToken);
            }
        }
    }
    

    Create an intent

    The set intent command creates a new intent, or set of intents, and cleans the old intents on the knowledge base.

    Defining how the chatbot should interpret and respond to the user.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/intentions',
        type: 'application/vnd.iris.ai.intention+json',
        resource: {
          name: 'Order pizza'
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "2",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/intentions",
      "type": "application/vnd.iris.ai.intention+json",
      "resource": {
          "name": "Order pizza"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.iris.ai.intention+json",
      "resource": {
        "id": "order_pizza"
      },
      "method": "set",
      "status": "success",
      "id": "2",
      "from": "postmaster@ai.msging.net/#az-iris2",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/intentions"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var intention = new Intention { Name = "Order pizza" };
    
                await _artificialIntelligenceExtension.SetIntentionAsync(intention, cancellationToken);
            }
        }
    }
    

    Merge an intent into a base

    The merge intent command creates a new intent, or set of intents, and merges them into the knowledge base without deleting the old intents. Note that there is currently no implementation for this method using the C# SDK.

    Defining how the chatbot should interpret and respond to the user.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.MERGE,
        uri: '/intentions',
        type: 'application/vnd.iris.ai.intention+json',
        resource: {
          name: 'Order pizza'
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "2",
      "to": "postmaster@ai.msging.net",
      "method": "merge",
      "uri": "/intentions",
      "type": "application/vnd.iris.ai.intention+json",
      "resource": {
          "name": "Order pizza"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.iris.ai.intention+json",
      "resource": {
        "id": "order_pizza"
      },
      "method": "merge",
      "status": "success",
      "id": "2",
      "from": "postmaster@ai.msging.net/#az-iris2",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/intentions"
      }
    }
    

    Delete an intent

    Deleting an intent, where {intent_id} is the intent identifier of an already created intent.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.DELETE,
        uri: '/intentions/{intent_id}',
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "10",
      "to": "postmaster@ai.msging.net",
      "method": "delete",
      "uri": "/intentions/{intent_id}",
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "delete",
      "status": "success",
      "id": "10",
      "from": "postmaster@ai.msging.net/#az-iris4",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/intentions/{intent_id}"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Delete,
                    Uri = new LimeUri("/intentions/{intent_id}")
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    

    Delete all intents

    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Delete,
                    Uri = new LimeUri("/intentions")
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.DELETE,
        uri: '/intentions'    
      });
    });
    
    
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "10",
      "to": "postmaster@ai.msging.net",
      "method": "delete",
      "uri": "/intentions"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "method": "delete",
        "status": "success",
        "id": "10",
        "from": "postmaster@ai.msging.net",
        "to": "contact@msging.net",
        "metadata": {
            "#command.uri": "lime://botname@msging.net/intentions"
        }
    }
    

    Query the first 10 intents

    Querying the first 10 intents.

    Property Description Example
    skip The number of intents to be skipped. 0
    take The number of intents to be returned. 100
    ascending Sets ascending alphabetical order. -
    client.addMessageReceiver('text/plain', async (message) => {
      var intents = await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/intentions?$skip=0&$take=10',
      });
    
      intents.resource.items.forEach(function (item) {
        console.log(item);
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "3",
      "to": "postmaster@ai.msging.net",
      "method": "get",
      "uri": "/intentions?$skip=0&$take=10"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "total": 2,
        "itemType": "application/vnd.iris.ai.intention+json",
        "items": [
          {
            "id": "order_pizza",
            "name": "Order pizza",
            "healthScore": 0,
            "storageDate": "2019-06-26T17:37:56.570Z"
          },
          {
            "id": "choose_flavor",
            "name": "Choose flavor",
            "healthScore": 0,
            "storageDate": "2019-06-26T17:38:08.880Z"
          }
        ]
      },
      "method": "get",
      "status": "success",
      "id": "3",
      "from": "postmaster@ai.msging.net/#az-iris2",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/intentions?$skip=0&$take=10"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver4 : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver4(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var intentions = await _artificialIntelligenceExtension.GetIntentionsAsync(0, 10, cancellationToken: cancellationToken);
            }
        }
    }
    

    Associate questions to an intent

    Associating examples of questions from the user. A variety of examples may be added to train the artificial intelligence model.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/intentions/order_pizza/questions',
        type: 'application/vnd.lime.collection+json',
        resource: {
          itemType: 'application/vnd.iris.ai.question+json',
          items: [
            {
              text: 'I want a pizza'
            },
            {
              text: 'I wanna order a pizza'
            },
            {
              text: 'Give me a pizza'
            }
          ]
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "4",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/intentions/order_pizza/questions",
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "itemType": "application/vnd.iris.ai.question+json",
        "items":[
          {
            "text": "I want a pizza"
          },
          {
            "text": "I wanna order a pizza"
          },
          {
            "text": "Give me a pizza"
          }
        ]
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "4",
      "from": "postmaster@ai.msging.net/#az-iris5",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/intentions/order_pizza/questions"
      }
    }
    
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var intentId = "order_pizza";
    
                var questions = new List<Question>(){
                    new Question{ Text = "I want a pizza" },
                    new Question{ Text = "I wanna order a pizza" },
                    new Question{ Text = "Give me a pizza" }
                };
    
                await _artificialIntelligenceExtension.SetQuestionsAsync(intentId, questions, cancellationToken);
            }
        }
    }
    

    Get questions from intent

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/intentions/order_pizza/questions'
      });
    });
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extensions
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {            
                var intentId = "order_pizza";
                var skip = 0; //optional
                var take = 100; //optional
                var ascending = true; //optional
    
                await _artificialIntelligenceExtension.GetQuestionsAsync(intentId, cancellationToken);
            }
        }
    }
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "10",
      "to": "postmaster@ai.msging.net",
      "method": "get",
      "uri": "/intentions/pesquisa_veiculo/questions"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "type": "application/vnd.lime.collection+json",
        "resource": {
            "total": 33,
            "itemType": "application/vnd.iris.ai.question+json",
            "items": [
                {
                    "id": "32",
                    "text": "O carro saiu de linha?"
                },
                {
                    "id": "33",
                    "text": "Qual o valor do fiat"
                }
            ]
        },
        "method": "get",
        "status": "success",
        "id": "10",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris1",l
        "to": "test@msging.net",
        "metadata": {
            "#command.uri": "lime://test@msging.net/intentions/pesquisa_veiculo/questions"
        }
    }
    

    Associate answers to an intent

    Associating possible answers to send to the user.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/intentions/order_pizza/answers',
        type: 'application/vnd.lime.collection+json',
        resource: {
          itemType: 'application/vnd.iris.ai.answer+json',
          items: [
            {
              type: 'text/plain',
              value: 'Which flavor do you want?'
            }
          ]
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "5",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/intentions/order_pizza/answers",
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "itemType": "application/vnd.iris.ai.answer+json",
        "items":[
          {
            "type":"text/plain",
            "value":"Which flavor do you want?"
          }
        ]
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "5",
      "from": "postmaster@ai.msging.net/#az-iris1",
      "to": "contact@msging.net",
      "metadata": {
          "#command.uri": "lime://contact@msging.net/intentions/order_pizza/answers"
      }
    }
    
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var intentId = "order_pizza";
    
                var answers = new List<Answer>(){ new Answer{ Value = "Which flavor do you want?" } };
    
                await _artificialIntelligenceExtension.SetAnswersAsync(intentId, answers, cancellationToken);
            }
        }
    }
    

    Get intent's answers

    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extensions
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {            
                var intentId = "order_pizza";
                var skip = 0; //optional
                var take = 100; //optional
                var ascending = true; //optional
    
                await _artificialIntelligenceExtension.GetAnswersAsync(intentId, cancellationToken);
            }
        }
    }
    
    
    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/intentions/{intentId}/answers?skip=0&take=100&ascending=false'
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "10",
        "method": "get",
        "to": "postmaster@ai.msging.net",
        "uri": "/intentions/{intentId}/answers?skip=0&take=100&ascending=false"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "type": "application/vnd.lime.collection+json",
        "resource": {
            "total": 1,
            "itemType": "application/vnd.iris.ai.answer+json",
            "items": [
                {
                    "id": "1",
                    "type": "text/plain",
                    "value": "Agendaremos pra você"
                }
            ]
        },
        "method": "get",
        "status": "success",
        "id": "10",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris2",
        "to": "test@msging.net",
        "metadata": {
            "#command.uri": "lime://test@msging.net/intentions/agendar/answers?skip=0&take=100&ascending=false"
        }
    }
    

    Delete answer from intent

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.DELETE,
        uri: '/intentions/{intentId}/answers/{answerId}'
      });
    });
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Delete,
                    Uri = new LimeUri("/intentions/{intentId}/answers/{answerId}")
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "10",
      "to": "postmaster@ai.msging.net",
      "method": "delete",
      "uri": "/intentions/{intentId}/answers/{answerId}"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "method": "delete",
        "status": "success",
        "id": "10",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris1",
        "to": "test@msging.net",
        "metadata": {
            "#command.uri": "lime://test@msging.net/intentions/pesquisa_veiculo/answers/1"
        }
    }
    

    Train model

    Before you train an artificial intelligence model, you need to configure the artificial intelligence provider that will be associated with chatbot and add user intents to the model.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/models',
        type: 'application/vnd.iris.ai.model-training+json',
        resource: {}
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "6",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/models",
      "type": "application/vnd.iris.ai.model-training+json",
      "resource": {}
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "6",
      "from": "postmaster@ai.msging.net/#az-iris1",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/models"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                await _artificialIntelligenceExtension.TrainModelAsync(cancellationToken);
            }
        }
    }
    

    Query the trained

    Querying information about created models.

    Property Description Example
    skip The number of models to be skipped. 0
    take The number of models to be returned. 100
    ascending Sets ascending alphabetical order. -
    client.addMessageReceiver('text/plain', async (message) => {
      var models = await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/models',
      });
    
      models.resource.items.forEach(function (item) {
        console.log(item);
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "7",
      "to": "postmaster@ai.msging.net",
      "method": "get",
      "uri": "/models"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "total": 4,
        "itemType": "application/vnd.iris.ai.model+json",
        "items": [
          {
            "id": "12345",
            "culture": "pt-br",
            "provider": "Watson",
            "externalId": "678910",
            "storageDate": "2019-07-01T13:35:36.930Z",
            "trainingDate": "2019-07-01T13:35:36.930Z",
            "apiUri": "https://gateway.watsonplatform.net/assistant/api",
            "status": "Training"
          },
          {
            "id": "111213",
            "culture": "pt-br",
            "provider": "Dialogflow",
            "externalId": "141516",
            "storageDate": "2019-07-01T13:35:34.330Z",
            "trainingDate": "2019-07-01T13:35:34.330Z",
            "status": "Trained"
          },
          {
            "id": "171819",
            "culture": "pt-br",
            "provider": "Watson",
            "storageDate": "2019-07-01T13:28:05.520Z",
            "trainingDate": "2019-07-01T13:28:05.520Z",
            "apiUri": "https://gateway.watsonplatform.net/assistant/api",
            "status": "Deleted"
          },
          {
            "id": "202122",
            "culture": "pt-br",
            "provider": "Dialogflow",
            "storageDate": "2019-07-01T13:28:01.870Z",
            "trainingDate": "2019-07-01T13:28:01.870Z",
            "status": "Deleted"
          }
        ]
      },
      "method": "get",
      "status": "success",
      "id": "7",
      "from": "postmaster@ai.msging.net/#az-iris5",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/models"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var models = await _artificialIntelligenceExtension.GetModelsAsync(0, 100, cancellationToken: cancellationToken);
            }
        }
    }
    

    Publish model

    Publishing an existing artificial intelligence model.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/models',
        type: 'application/vnd.iris.ai.model-publishing+json',
        resource: {
          id: '{your_model_id}'
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "8",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/models",
      "type": "application/vnd.iris.ai.model-publishing+json",
      "resource": {
        "id": "{your_model_id}"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "8",
      "from": "postmaster@ai.msging.net/#az-iris2",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/models"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                await _artificialIntelligenceExtension.PublishModelAsync("{your_model_id}", cancellationToken);
            }
        }
    }
    

    Analyze a sentence in the last published model

    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Set,
                    Uri = new LimeUri("/analysis"),
                    Type = 'application/vnd.iris.ai.analysis-request+json',
                    Resource = new AnalysisRequest {
                      Text = 'I want a pepperoni pizza'
                    }
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/analysis',
        type: 'application/vnd.iris.ai.analysis-request+json',
        resource: {
          text: 'I want a pepperoni pizza'
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "9",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/analysis",
      "type": "application/vnd.iris.ai.analysis-request+json",
      "resource": {
        "text":"I want a pepperoni pizza"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "9",
      "from": "postmaster@ai.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success",
      "type": "application/vnd.iris.ai.analysis-response+json",
      "resource": {
        "text":"I want a pepperoni pizza",
        "intentions":[
          {
            "id":"order_pizza",
            "name":"Order pizza",
            "score": 0.95
          }
        ],
        "entities":[
          {
            "id":"flavor",
            "name":"Flavor",
            "value":"Pepperoni"
          }
        ]
      }
    }
    

    Analyze a sentence with a specific model

    It is possible to analyze a sentence with a specific model, to improve the model.

    client.addMessageReceiver('text/plain', async (message) => {
      var result = await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/analysis',
        type: 'application/vnd.iris.ai.analysis-request+json',
        resource: {
          text: 'I want a pepperoni pizza',
          modelId: '12345'
        }
      });
    
      result.resource.intentions.forEach(function (intent) {
        console.log(intent);
      });
    
      result.resource.entities.forEach(function (entity) {
        console.log(entity);
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "10",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/analysis",
      "type": "application/vnd.iris.ai.analysis-request+json",
      "resource": {
        "text":"I want a pepperoni pizza",
        "modelId":"12345"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.iris.ai.analysis-response+json",
      "resource": {
        "id": "456789",
        "text": "i want a pepperoni pizza",
        "intentions": [
          {
            "id": "order_pizza",
            "name": "Order pizza",
            "score": 0.5535872,
            "answer": {
              "id": "1",
              "type": "text/plain",
              "value": "Which flavor do you want?"
            }
          }
        ],
        "entities": [
          {
            "id": "flavor",
            "name": "Flavor",
            "value": "pepperoni"
          }
        ],
        "provider": "Dialogflow",
        "modelId": "12345"
      },
      "method": "set",
      "status": "success",
      "id": "10",
      "from": "postmaster@ai.msging.net/#az-iris4",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/analysis"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver10 : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver10(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var analysisRequest = new AnalysisRequest{
                    Text = "I want a pepperoni pizza",
                    ModelId = "12345"
                };
    
                var result = await _artificialIntelligenceExtension.AnalyzeAsync(analysisRequest, cancellationToken);
            }
        }
    }
    

    Get the last 10 analysis

    Getting the last 10 analysis given by the artificial intelligence provider for user phrases.

    Property Description Example
    skip The number of analysis to be skipped. 0
    take The number of analysis to be returned. 100
    client.addMessageReceiver('text/plain', async (message) => {
      var analisys = await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/analysis?$skip=0&$take=10',
      });
    
      analisys.resource.items.forEach(function (item) {
        console.log(item);
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "11",
      "to": "postmaster@ai.msging.net",
      "method": "get",
      "uri": "/analysis?$skip=0&$take=10"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "total": 6,
        "itemType": "application/vnd.iris.ai.analysis+json",
        "items": [
          {
            "id": "2b05bb98-b470-475c-a6fb-016bb411bfb9",
            "requestDateTime": "2019-07-02T19:03:09.660Z",
            "text": "i want a pepperoni pizza",
            "intention": "order_pizza",
            "score": 0.9580827713012696,
            "intentions": [
              {
                "id": "order_pizza",
                "name": "Order pizza",
                "score": 0.9580827713012696,
                "answer": {
                  "id": "1",
                  "type": "text/plain",
                  "value": "{}"
                }
              },
              {
                "id": "help",
                "name": "help",
                "score": 0.24191724956035615
              }
            ],
            "entities": [
              {
                "id": "flavor",
                "name": "Flavor",
                "value": "pepperoni"
              }
            ]
          },
          {
            "id": "d011e14d-5bb6-4dce-82c7-016bb308a973",
            "requestDateTime": "2019-07-02T14:13:36.040Z",
            "text": "i want a mushrooms pizza",
            "intention": "order_pizza",
            "score": 0.5515909,
            "intentions": [
              {
                "id": "order_pizza",
                "name": "Order pizza",
                "score": 0.5515909,
                "answer": {
                  "id": "1",
                  "type": "text/plain",
                  "value": "{}"
                }
              }
            ],
            "entities": [
              {
                "id": "flavor",
                "name": "Flavor",
                "value": "mushrooms"
              }
            ]
          },
          {
            "id": "a3d8e978-a57b-4f0f-9abc-016baf4d338a",
            "requestDateTime": "2019-07-01T20:49:58.980Z",
            "text": "i want a mushrooms pizza",
            "intention": "order_pizza",
            "score": 0.5515909,
            "feedback": "rejected",
            "intentions": [
              {
                "id": "order_pizza",
                "name": "Order pizza",
                "score": 0.5515909,
                "answer": {
                  "id": "1",
                  "type": "text/plain",
                  "value": "{}"
                }
              }
            ],
            "entities": [
              {
                "id": "flavor",
                "name": "Flavor",
                "value": "mushrooms"
              }
            ]
          },
          {
            "id": "4e0892f9-4188-47ee-9527-016baf12d13f",
            "requestDateTime": "2019-07-01T19:46:13.260Z",
            "text": "i want a mushrooms pizza",
            "intention": "order_pizza",
            "score": 0.5515909,
            "intentions": [
              {
                "id": "order_pizza",
                "name": "Order pizza",
                "score": 0.5515909,
                "answer": {
                  "id": "1",
                  "type": "text/plain",
                  "value": "{}"
                }
              }
            ],
            "entities": [
              {
                "id": "flavor",
                "name": "Flavor",
                "value": "mushrooms"
              }
            ]
          },
          {
            "id": "60b6716f-7e43-46fe-823c-016baf0db599",
            "requestDateTime": "2019-07-01T19:40:38.260Z",
            "text": "i want a pepperoni pizza",
            "intention": "order_pizza",
            "score": 0.5535872,
            "intentions": [
              {
                "id": "order_pizza",
                "name": "Order pizza",
                "score": 0.5535872,
                "answer": {
                  "id": "1",
                  "type": "text/plain",
                  "value": "{}"
                }
              }
            ],
            "entities": [
              {
                "id": "flavor",
                "name": "Flavor",
                "value": "pepperoni"
              }
            ]
          },
          {
            "id": "bde80a9f-9374-4f09-b0bf-016baf047fbd",
            "requestDateTime": "2019-07-01T19:30:34.630Z",
            "text": "i want a pepperoni pizza",
            "intention": "order_pizza",
            "score": 0.5535872,
            "intentions": [
              {
                "id": "order_pizza",
                "name": "Order pizza",
                "score": 0.5535872,
                "answer": {
                  "id": "1",
                  "type": "text/plain",
                  "value": "{}"
                }
              }
            ],
            "entities": [
              {
                "id": "flavor",
                "name": "Flavor",
                "value": "pepperoni"
              }
            ]
          }
        ]
      },
      "method": "get",
      "status": "success",
      "id": "11",
      "from": "postmaster@ai.msging.net/#az-iris4",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/analysis?$skip=0&$take=10"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
                _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var skip = 0;
                var take = 10;
    
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Get,
                    To = Node.Parse("postmaster@ai.msging.net"),
                    Uri = new LimeUri($"/analysis?$skip={skip}&$take={take}")
                };
    
               var analisys = await _sender.ProcessCommandAsync(command, cancellationToken);
            }
        }
    }
    

    Send an 'approved' feedback

    Sending positive feedback about an analysis.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/analysis/{analyze_id}/feedback',
        type: 'application/vnd.iris.ai.analysis-feedback+json',
        resource: {
          feedback: 'approved'
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id":"12",
      "to":"postmaster@ai.msging.net",
      "method":"set",
      "uri":"/analysis/{analyze_id}/feedback",
      "type":"application/vnd.iris.ai.analysis-feedback+json",
      "resource":{
        "feedback":"approved"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "12",
      "from": "postmaster@ai.msging.net/#az-iris3",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/analysis/{analyze_id}/feedback"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var analysisFeedback = new AnalysisFeedback{
                    Feedback = AnalysisModelFeedback.Approved
                };
    
                await _artificialIntelligenceExtension.SendFeedbackAsync("{analyze_id}", analysisFeedback, cancellationToken);
            }
        }
    }
    

    Send a 'rejected' feedback

    To submit a rejection feedback, it is necessary to enter the id of the correct intent for the case.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: '/analysis/{analyze_id}/feedback',
        type: 'application/vnd.iris.ai.analysis-feedback+json',
        resource: {
          feedback: 'rejected',
          intentionId: '{other_intent_id}}'
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "13",
      "to": "postmaster@ai.msging.net",
      "method": "set",
      "uri": "/analysis/{analyze_id}/feedback",
      "type": "application/vnd.iris.ai.analysis-feedback+json",
      "resource": {
        "feedback": "rejected"
        "intentionId": "{other_intent_id}}"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "method": "set",
      "status": "success",
      "id": "13",
      "from": "postmaster@ai.msging.net/#az-iris3",
      "to": "contact@msging.net",
      "metadata": {
        "#command.uri": "lime://contact@msging.net/analysis/{analyze_id}/feedback"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.ArtificialIntelligence;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly IArtificialIntelligenceExtension _artificialIntelligenceExtension;
    
            public ArtificialIntelligenceReceiver(IArtificialIntelligenceExtension artificialIntelligenceExtension)
            {
                _artificialIntelligenceExtension = artificialIntelligenceExtension;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var analysisFeedback = new AnalysisFeedback{
                    Feedback = AnalysisModelFeedback.Rejected,
                    IntentionId = "{other_intent_id}"
                };
    
                await _artificialIntelligenceExtension.SendFeedbackAsync("{analyze_id}", analysisFeedback, cancellationToken);
            }
        }
    }
    

    Send enhancement analysis models by email

    The filter can be sent empty.

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: "/enhancement/send-by-email",
        type:"application/json",
        resource:{  
          email:"test%40take.net",
          filter:"requestDateTime%20ge%20datetimeoffset'2019-04-29T16%3A31%3A00.000Z'%20and%20requestDateTime%20le%20datetimeoffset'2019-05-30T16%3A31%3A00.000Z'"
        }
      });
    });
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
              _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
              var command = new Command{
                Id = EnvelopeId.NewId(),
                Method = CommandMethod.Set,
                Uri = new LimeUri("/enhancement/send-by-email"),
                Resource = new {  
                  email = "test%40take.net",
                  filter = "requestDateTime%20ge%20datetimeoffset'2019-04-29T16%3A31%3A00.000Z'%20and%20requestDateTime%20le%20datetimeoffset'2019-05-30T16%3A31%3A00.000Z'"
                },
                Type :"application/json"
              };
    
              await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    {  
       "id":"10",
       "method":"set",
       "resource":{  
          "email":"test%40take.net",
          "filter":"requestDateTime%20ge%20datetimeoffset'2019-04-29T16%3A31%3A00.000Z'%20and%20requestDateTime%20le%20datetimeoffset'2019-05-30T16%3A31%3A00.000Z'"
       },
       "to":"postmaster@ai.msging.net",
       "type":"application/json",
       "uri":"/enhancement/send-by-email"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    {
      {
        "method": "set",
        "status": "success",
        "id": "10",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris1",
        "to": "test@msging.net",
        "metadata": {
            "#command.uri": "lime://test@msging.net/enhancement/send-by-email"
        }
    }
    

    Create a confusion matrix

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.SET,
        uri: "/analytics/confusion-matrix",
        type: "application/vnd.iris.ai.confusion-matrix+json",
        resource: {
            version: "test",
            sampleSize: 2
        }
      });
    });
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Takenet.Iris.Messaging.Resources.ArtificialIntelligence;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Set,
                    Uri = new LimeUri("/analytics/confusion-matrix")
                    Type= "application/vnd.iris.ai.confusion-matrix+json",
                    Resource = new ConfusionMatrix{
                      Version = "teste",
                      SampleSize = 2
                    }
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "10",
        "to": "postmaster@ai.msging.net",
        "method": "set",
        "uri": "/analytics/confusion-matrix",
        "type": "application/vnd.iris.ai.confusion-matrix+json",
        "resource": {
            "version": "teste",
            "sampleSize": 2
        }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "type": "application/vnd.iris.ai.confusion-matrix+json",
        "resource": {
            "OwnerIdentity": "botbot1@msging.net",
            "id": "d0b71e41-897c-48c4-a565-29d227013111",
            "modelId": "botbot1_543659e7-902a-4326-8a2e-016adbc4b100",
            "version": "teste",
            "score": 0,
            "sampleSize": 2,
            "createdDate": "2019-05-30T17:22:02.139Z",
            "accuracy": 0,
            "avgScore": 0,
            "precision": 0,
            "recall": 0,
            "f1Score": 0,
            "numberOfSamples": 0
        },
        "method": "set",
        "status": "success",
        "id": "10",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris2",
        "to": "botbot1@msging.net",
        "metadata": {
            "#command.uri": "lime://botbot1@msging.net/analytics/confusion-matrix"
        }
    }
    

    Get confusion matrices

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/analytics/confusion-matrix'
      });
    });
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Get,
                    Uri = new LimeUri("/analytics/confusion-matrix")
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "10",
        "to": "postmaster@ai.msging.net",
        "method": "get",
        "uri": "/analytics/confusion-matrix"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "type": "application/vnd.lime.collection+json",
        "resource": {
            "total": 2,
            "itemType": "application/vnd.iris.ai.confusion-matrix+json",
            "items": [
                {
                    "OwnerIdentity": "botbot1@msging.net",
                    "id": "{confusionMatrixId}",
                    "modelId": "botbot1_5fcc572f-f9c5-47f9-964f-016ac7541425",
                    "version": "Reportão",
                    "score": 0,
                    "sampleSize": 30,
                    "createdDate": "2019-05-17T21:18:33.540Z",
                    "accuracy": 0.96,
                    "avgScore": 0.61698660140000006,
                    "precision": 0.92207792207792216,
                    "recall": 0.90238095238095239,
                    "f1Score": 0.980796980796981,
                    "numberOfSamples": 50
                },
                {
                    "OwnerIdentity": "botbot1@msging.net",
                    "id": "4dcb1b00-dc95-488e-a38f-95f8d213f842",
                    "modelId": "botbot1_5fcc572f-f9c5-47f9-964f-016ac7541425",
                    "version": "Reportão",
                    "score": 0,
                    "sampleSize": 30,
                    "createdDate": "2019-05-17T21:18:30.520Z",
                    "accuracy": 1,
                    "avgScore": 0.67095285047619058,
                    "precision": 1,
                    "recall": 1,
                    "f1Score": 1,
                    "numberOfSamples": 21
                }
            ]
        },
        "method": "get",
        "status": "success",
        "id": "71c0b1f1-332d-498e-afa6-792dbe86d464",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris1",
        "to": "test@msging.net",
        "metadata": {
            "#command.uri": "lime://test@msging.net/analytics/confusion-matrix"
        }
    }
    

    Get a confusion matrix

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.GET,
        uri: '/analytics/confusion-matrix/{confusionMatrixId}'
      });
    });
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Get,
                    Uri = new LimeUri("/analytics/confusion-matrix/{confusionMatrixId}")
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "10",
        "to": "postmaster@ai.msging.net",
        "method": "get",
        "uri": "/analytics/confusion-matrix/{confusionMatrixId}"
    }
    
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "type": "application/vnd.iris.ai.confusion-matrix+json",
        "resource": {
            "OwnerIdentity": "botbot1@msging.net",
            "id": "{confusionMatrixId}",
            "modelId": "botbot1_5fcc572f-f9c5-47f9-964f-016ac7541425",
            "version": "Reportão",
            "score": 0,
            "sampleSize": 30,
            "createdDate": "2019-05-17T21:18:33.540Z",
            "accuracy": 0.96,
            "avgScore": 0.61698660140000006,
            "precision": 0.92207792207792216,
            "recall": 0.90238095238095239,
            "f1Score": 0.980796980796981,
            "numberOfSamples": 50,
            "matrix": [[],...],
            "perClasses": [{},...]
        },
        "method": "get",
        "status": "success",
        "id": "e909fedf-fb70-463e-88c1-1cd02218c712",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris1",
        "to": "test@msging.net",
        "metadata": {
            "#command.uri": "lime://test@msging.net/analytics/confusion-matrix/{confusionMatrixId}"
        }
    }
    

    Delete a confusion matrix

    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    
    namespace Extension
    {
        public class ArtificialIntelligenceReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
    
            public ArtificialIntelligenceReceiver(ISender sender)
            {
               _sender = sender;
            }
    
            public async Task ReceiveAsync(Message envelope, CancellationToken cancellationToken)
            {
                var command = new Command{
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Delete,
                    Uri = new LimeUri("/analytics/confusion-matrix/{confusionMatrixId}")
                };
    
               await _sender.SendCommandAsync(command, cancellationToken);     
            }           
        }
    }
    
    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'postmaster@ai.msging.net',
        method: Lime.CommandMethod.DELETE,
        uri: '/analytics/confusion-matrix/{confusionMatrixId}'    
      });
    });
    
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
        "id": "10",
        "method": "delete",
        "to": "postmaster@ai.msging.net",
        "uri": "/analytics/confusion-matrix/{confusionMatrixId}",
        "from": "postmaster@ai.msging.net/#hmg-az-lx-iris1"
    }
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "id": "10",
        "method": "delete",
        "status": "success",
        "to": "test.net/portal-test%40take.net"
    }
    
    

    Broadcast

    The broadcast extension allows creation and management of distribution lists and their members for sending messages to multiple destinations simultaneously.

    Each distribution list has a unique address in the format list-name@broadcast.msging.net in addition to the members, who are the recipients of messages sent to this list. Only the chatbot that created a remote list has permission to send messages to it.

    Notifications are forwarded to the chatbot when received by the extension.

    In order to use broadcast extension features, you must send commands with the following properties:

    Name Description
    id Unique identifier of the command.
    method The command verb
    resource The schedule document.
    type "application/vnd.iris.distribution-list+json"
    uri /lists
    to postmaster@broadcast.msging.net

    The command's properties resource and method can change according to the feature. An schedule object passed as a document resource has the following properties:

    Property Description Example
    identity Identifier of a distribution list. news@broadcast.msging.net

    Default list

    BLiP automatically creates a distribution list with all clients that have already contacted your chatbot. Its address is [bot-identifier]+senders@broadcast.msging.net where bot-identifier is the identifier of your chatbot, which is used with the access key for authentication.

    For example, for a chatbot with identifier mychatbot, this list address would be mychatbot+senders@broadcast.msging.net.

    Replacement variables

    It is possible to use contact replacement variables in the sent messages. For more information, please check the documentation of the Contacts extension.

    Availability

    The Broadcast service is available in the following domains:

    Domain Available Observation
    Messenger x Needed initial user interaction with chatbot
    BLiP Chat x Not necessary initial user interaction with chatbot
    Skype x Needed initial user interaction with chatbot
    SMS x Not necessary initial user interaction with chatbot
    Telegram x Needed initial user interaction with chatbot
    Workplace x Needed initial user interaction with chatbot

    Create a list

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: "postmaster@broadcast.msging.net",
        method: Lime.CommandMethod.SET,
        type: "application/vnd.iris.distribution-list+json",
        uri: "/lists",
        resource: {
            "identity": "your_distributionList@broadcast.msging.net"
        }
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "1",
      "to": "postmaster@broadcast.msging.net",
      "method": "set",
      "type": "application/vnd.iris.distribution-list+json",
      "uri": "/lists",
      "resource": {  
        "identity": "your_distributionList@broadcast.msging.net"
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "1",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var listName = "your_distributionList";
    
                await _broadcastExtension.CreateDistributionListAsync(listName);
            }
        }
    }
    

    Before making a broadcast, it is necessary to create a distribution list and add some members to it. To create a distribution list with your_distributionList identifier you must send command with SET method and a resource document with identity equal to your_distributionList@broadcast.msging.net.

    Get all lists

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: "postmaster@broadcast.msging.net",
        method: Lime.CommandMethod.GET,
        uri: "/lists"
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "2",
      "to": "postmaster@broadcast.msging.net",
      "method": "get",
      "uri": "/lists"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "2",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "get",
      "status": "success",
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "total": 2,
        "itemType": "application/vnd.lime.identity",
        "items": [
          "list1@msging.net",
          "contact+senders@msging.net"
        ]
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                // 0 is the initial position (number of lists to be skipped)
                // 5 is the number os lists to be returned
                await _broadcastExtension.GetRecipientsAsynGetAllDistributionListsAsync(0, 5, cancellationToken);
            }
        }
    }
    

    To get all distribution lists associated with your chatbot, you must send a command with GET method.

    Add a member to list

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({  
          id: Lime.Guid(),
          to: "postmaster@broadcast.msging.net",
          method: Lime.CommandMethod.SET,
          uri: "/lists/your_distributionList@broadcast.msging.net/recipients",
          type: "application/vnd.lime.identity",
          resource: message.from //user identity
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "3",
      "to": "postmaster@broadcast.msging.net",
      "method": "set",
      "uri": "/lists/your_distributionList@broadcast.msging.net/recipients",
      "type": "application/vnd.lime.identity",
      "resource": "551100001111@0mn.io"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "3",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var listName = "your_distributionList";
    
                await _broadcastExtension.AddRecipientAsync(listName, Identity.Parse("551100001111@0mn.io"));
            }
        }
    }
    

    After creating a distribution list, you must add some members to receive your broadcasts. To add a member with 551100001111@0mn.io identity to a list with your_distributionList identifier, you must send a command with SET method and resource document equal to a member identity (551100001111@0mn.io). Note that the command URI also must contains the list identifier (/lists/your_distributionList@broadcast.msging.net/recipients)

    Remove members from list

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({  
        id: Lime.Guid(),
        to: "postmaster@broadcast.msging.net",
        method: Lime.CommandMethod.DELETE,
        uri: "/lists/your_distributionList@broadcast.msging.net/recipients/user_identity@0mn.io"
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "4",
      "to": "postmaster@broadcast.msging.net",
      "method": "delete",
      "uri": "/lists/your_distributionList@broadcast.msging.net/recipients/551100001111@0mn.io"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "4",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var listName = "your_distributionList";
    
                await _broadcastExtension.DeleteRecipientAsync(listName, Identity.Parse("551100001111@0mn.io"));
            }
        }
    }
    

    As the same way you add some members into a distribution list, it is possible to remove its members. To remove a member with 551100001111@0mn.io identity from a list with your_distributionList identifier, you must send a command with DELETE method and command URI with the list and memeber identifier (/lists/your_distributionList@broadcast.msging.net/recipients/551100001111@0mn.io)

    Get all members of a list

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: "postmaster@broadcast.msging.net",
        method: Lime.CommandMethod.GET,
        uri: "/lists/your_distributionList@broadcast.msging.net/recipients?$skip=0&$take=5"
      });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "5",
      "to": "postmaster@broadcast.msging.net",
      "method": "get",
      "uri": "/lists/your_distributionList@broadcast.msging.net/recipients?$skip=0&$take=5"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "5",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "get",
      "status": "success",
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "total": 30,
        "itemType": "application/vnd.lime.identity",
        "items": [
          "contact+senders@msging.net",
          "list1@msging.net",
          "list2@msging.net",
          "list3@msging.net",
          "list4@msging.net"
        ]
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var listName = "your_distributionList";
    
                await _broadcastExtension.GetRecipientsAsync(listName, 0, 5, cancellationToken);
            }
        }
    }
    

    To get all members of a distribution list, you must send a command with GET method and command URI with the list identifier (/lists/your_distributionList@broadcast.msging.net/recipients)

    Property Description Example
    skip The number of members to be skipped 0
    take The number of members to be returned 100

    Send message

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendCommand({
        id: Lime.Guid(),
        to: 'your_distributionList@broadcast.msging.net',
        type: 'text/plain',
        content: 'Hello participants of this list!'
      });
    });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "6",
      "to": "your_distributionList@broadcast.msging.net",
      "type": "text/plain",
      "content": "Hello participants of this list!"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "6",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      event": "received"
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "6",
      "from": "postmaster@broadcast.msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "event": "consumed"
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    using Lime.Messaging.Contents;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var listName = "your_distributionList";
    
                await _broadcastExtension.SendMessageAsync(listName, new PlainText { Text = "Hello participants of this list!" });
            }
        }
    }
    

    If you already have a distribution list with some members, you can send messages to this list. Any message sent to a specific list will be received by all of its members.

    Send message with replacement variable

    client.addMessageReceiver('text/plain', async (message) => {
      await client.sendMessage({  
        id: Lime.Guid(),
        to: "your_distributionList@broadcast.msging.net",
        type: "text/plain",
        content: "Hello ${contact.name}, come to check out our prices!"
      });
    });
    
    POST https://msging.net/messages HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "7",
      "to": "your_distributionList@broadcast.msging.net",
      "type": "text/plain",
      "content": "Hello ${contact.name}, come to check out our prices!"
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Broadcast;
    using Lime.Messaging.Contents;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBroadcastExtension _broadcastExtension;
    
            public SampleMessageReceiver(IBroadcastExtension broadcastExtension)
            {
                _broadcastExtension = broadcastExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var listName = "your_distributionList";
    
                await _broadcastExtension.SendMessageAsync(listName, new PlainText { Text = "Hello ${contact.name}, come to check out our prices!" });
            }
        }
    }
    

    For more information, please check the documentation of the Contacts extension.

    Bucket

    The bucket extension allows the storage of documents in the server on an isolated chatbot's container. This extension is useful to store information about clients that have interacted with the chatbot, like preferences and navigation state.

    Each document has an identifier which is provided during the write operation and this identifier should be used for retrieving the value later. It is possible to set an optional expiration date for the document. Both the identifier and the expiration date are specified in the URI of the command which is sent to the extension.

    Note: If expiration date is not provided, the document will never expire.

    To use the bucket extension, send a command with the following properties:

    Name Description
    id Unique identifier of the command.
    method The command verb
    resource The document to be stored.
    type The document type
    uri /buckets
    to postmaster@msging.net (not required)

    The command's properties resource and method can change according to the feature. The document to be stored must be passed on the resource property.

    Store a JSON document

    client.addMessageReceiver('text/plain', async (message) => {
        await client.sendCommand({
            id: Lime.Guid(),
            method: Lime.CommandMethod.SET,
            uri: '/buckets/xyz1234',
            type: 'application/json',
            resource: {  
                'key1': 'value1',
                'key2': 2,
                'key3': [  
                    '3a', '3b', '3c'
                ]
            }
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "1",
      "method": "set",
      "uri": "/buckets/xyz1234",
      "type": "application/json",
      "resource": {  
        "key1": "value1",
        "key2": 2,
        "key3": [  
          "3a", "3b", "3c"
        ]
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "1",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    using System;
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Bucket;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBucketExtension _bucketExtension;
    
            public SampleMessageReceiver(IBucketExtension bucketExtension)
            {
                _bucketExtension = bucketExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var jsonDocument = new JsonDocument();
                jsonDocument.Add("key1", "value1");
                jsonDocument.Add("key2", 2);
                jsonDocument.Add("key3", new string[] { "3a", "3b", "3c"} );
    
                await _bucketExtension.SetAsync("xyz1234", jsonDocument);
            }
        }
    }
    

    Storing a JSON object {"key1": "value1", "key2": 2, "key3": ["3a", "3b", "3c"]} identified by xyz1234 key.

    Store a custom document

    client.addMessageReceiver('text/plain', async (message) => {
        await client.sendCommand({
            id: Lime.Guid(),
            method: Lime.CommandMethod.SET,
            uri: "/buckets/abcd9876?expiration=30000",
            type: "application/x-my-type+json",
            resource: {  
                "myTypeKey1": "value1",
                "myTypeKey2": 2
            }
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "2",
      "method": "set",
      "uri": "/buckets/abcd9876?expiration=30000",
      "type": "application/x-my-type+json",
      "resource": {  
        "myTypeKey1": "value1",
        "myTypeKey2": 2
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "2",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Bucket;
    using System.Runtime.Serialization;
    using Take.Blip.Client.Extensions;
    
    namespace Extensions
    {
        [DataContract]
        public class MyType : Document
        {
            public const string MIME_TYPE = "application/x-my-type+json";
    
            public static readonly MediaType MediaType = MediaType.Parse(MIME_TYPE);
    
            public MyType()
                : base(MediaType)
            {
            }
    
            [DataMember]
            public string MyTypeKey1 { get; set; }
    
            [DataMember]
            public int MyTypeKey2 { get; set; }
        }
    
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBucketExtension _bucketExtension;
    
            public SampleMessageReceiver(IBucketExtension bucketExtension)
            {
                _bucketExtension = bucketExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                // Storing a custom document without expiration
                var myTypeDocument = new MyType();
                myTypeDocument.MyTypeKey1 = "value1";
                myTypeDocument.MyTypeKey2 = 2;
                await _bucketExtension.SetAsync("abcd9876", myTypeDocument);
    
                // Storing a custom document with expiration
                var bucketId = "abcd9876";
                var expiration = 3000;
                var command = new Command(){
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Set,
                    Uri = new LimeUri($"/buckets/{bucketId}?expiration={expiration}"), 
                    Resource = myTypeDocument
                };
    
            }
        }
    }
    

    Storing a custom document with type application/x-my-type+json and abcd9876 identifier, setting the expiration to 30000 milisseconds (or 30 seconds):

    Get a document

    client.addMessageReceiver('text/plain', async (message) => {
        await client.sendCommand({  
            id: Lime.Guid(),
            method: Lime.CommandMethod.GET,
            uri: '/buckets/xyz1234'
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "3",
      "method": "get",
      "uri": "/buckets/xyz1234"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "3",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "get",
      "status": "success",
      "type": "application/json",
      "resource": {  
        "key1": "value1",
        "key2": 2,
        "key3": [  
          "3a", "3b", "3c"
        ]
      }  
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Bucket;
    
    namespace Extensions
    {
        public class SampleMessageReceiver : IMessageReceiver
        {
            private readonly IBucketExtension _bucketExtension;
    
            public SampleMessageReceiver(IBucketExtension bucketExtension)
            {
                _bucketExtension = bucketExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var document = await _bucketExtension.GetAsync<JsonDocument>("xyz1234", cancellationToken);
            }
        }
    }
    

    Retrieving a JSON document identified by xyz1234 key.

    Builder

    Address
    postmaster@msging.net

    Builder is a visual tool for create any type of bots with no code. Behind the scenes Builder is a state machine fully integrated with the others BLiP's components.

    The Builder extension allows change some Builder's behaviors programmaticaly. You can change or reset a user state with a command. In addition, the extension can be used to manage the whole bot flow.

    Reset user state

    In order to reset a user state, send a command with the following properties:

    Name Description
    id Unique identifier of the command.
    method delete
    uri /contexts/{{user-identity}}/stateid%400
    to postmaster@msging.net (not required)
    client.addMessageReceiver('text/plain', async (message) => {
        await client.sendCommand({  
            id: Lime.Guid(),
            method: Lime.CommandMethod.DELETE,
            uri: '/contexts/30e26f51-25e5-4dfc-b2bf-6c0ba80027a8.docstest@0mn.io/stateid%400'
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "0094447a-2581-4597-be6a-a5dff33af156",
      "method": "delete",
      "uri": "/contexts/30e26f51-25e5-4dfc-b2bf-6c0ba80027a8.docstest@0mn.io/stateid%400"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "method": "delete",
        "status": "success",
        "id": "0094447a-2581-4597-be6a-a5dff33af156",
        "from": "postmaster@msging.net/#az-iris1",
        "to": "docstest@msging.net",
        "metadata": {
            "#command.uri": "lime://docstest@msging.net/contexts/30e26f51-25e5-4dfc-b2bf-6c0ba80027a8.docstest@0mn.io/stateid%400"
        }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Session;
    
    namespace Extensions
    {
        public class ResetUserStateReceiver : IMessageReceiver
        {
            private readonly IStateManager _stateManager;
    
            public ResetUserStateReceiver(IStateManager stateManager)
            {
                _stateManager = stateManager;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                await _stateManager.ResetStateAsync(message.From, cancellationToken);
            }
        }
    }
    

    Change user state

    In order to change a user state, send a command with the following properties:

    Name Description
    id Unique identifier of the command.
    method set
    uri /contexts/{{user-identity}}/stateid%40{{flow-identifier}}
    to postmaster@msging.net (not required)
    type text/plain
    resource {{state-id}}

    Access the portal, go to Builder and click on the block contextual menu to get its ID (as picture below).

    image

    To get the flow identifier, click in Builder's settings and go to Flow Identifier section (as picture below).

    image

    client.addMessageReceiver('text/plain', async (message) => {
        await client.sendCommand({  
            id: Lime.Guid(),
            to: 'postmaster@msging.net',
            method: Lime.CommandMethod.SET,
            uri: '/contexts/30e26f51-25e5-4dfc-b2bf-6c0ba80027a8.docstest@0mn.io/stateid%400',
            type: 'text/plain',
            resource: 'state-one'
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {
      "id": "1294447a-2581-4597-be6a-a5dff33af156",
      "to": "postmaster@msging.net",
      "method": "set",
      "uri": "/contexts/30e26f51-25e5-4dfc-b2bf-6c0ba80027a8.docstest@0mn.io/stateid%400",
      "type": "text/plain",
      "resource": "state-one"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "method": "set",
        "status": "success",
        "id": "1294447a-2581-4597-be6a-a5dff33af156",
        "from": "postmaster@msging.net/#az-iris3",
        "to": "docstest@msging.net",
        "metadata": {
            "#command.uri": "lime://docstest@msging.net/contexts/30e26f51-25e5-4dfc-b2bf-6c0ba80027a8.docstest@0mn.io/stateid%400"
        }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Session;
    
    namespace Extensions
    {
        public class ChangeUserStateReceiver : IMessageReceiver
        {
            private readonly IStateManager _stateManager;
    
            public ChangeUserStateReceiver(IStateManager stateManager)
            {
                _stateManager = stateManager;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                await _stateManager.SetStateAsync(message.From, "state-one", cancellationToken);
            }
        }
    }
    

    Chatbot profile

    The profile extension allows the configuration of chatbot profile properties, which can reflect on the clients in the published channel - if supported. Each property is a document of a type supported by the platform.

    To manage chatbot's profile information, send commands with the following properties:

    Name Description
    id Unique identifier of the command.
    method The command verb
    resource The profile property document.
    type The resource document type
    uri /profile
    to postmaster@msging.net (not required)

    The command's properties resource and method can change according to the feature.

    The current supported profile properties are:

    Name Identifier Document type Supported channels
    Start button get-started Text Messenger, BLiP Chat
    Greeting message greeting Text Messenger, BLiP Chat
    Persistent menu persistent-menu Multimedia menu Messenger

    Note: In Messenger, the value of get-started must be defined before the value of persistent-menu.

    Setting Greeting Message

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "1",
      "method": "set",
      "uri": "/profile/greeting",
      "type": "text/plain",
      "resource": "Hello and welcome to our service!"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "1",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    client.sendCommand({
      id: Lime.Guid(),
      method: Lime.CommandMethod.SET,
      uri: "/profile/greeting",
      type: "text/plain",
      resource: "Hello and welcome to our service!"
    })
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Lime.Messaging.Contents;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Profile;
    
    namespace Extensions
    {
        public class ProfileMessageReceiver : IMessageReceiver
        {
            private readonly IMessagingHubSender _sender;
            private readonly IProfileExtension _profileExtension;
    
            public ProfileMessageReceiver(IMessagingHubSender sender, IProfileExtension profileExtension)
            {
                _sender = sender;
                _settings = settings;
                _profileExtension = profileExtension;
            }
    
            public async Task ReceiveAsync(Message m, CancellationToken cancellationToken)
            {
                await _profileExtension.SetGreetingAsync(new PlainText { Text = "Hello and welcome to our service!" }, cancellationToken);
            }
        }
    }
    

    In order to set a text greeting message for your chatbot, use a set command on /profile/greeting URI. This sample shows how to add a greeting message with the content "Hello and welcome to our service!".

    Setting simple persistent menu

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "2",
      "method": "set",
      "uri":"/profile/persistent-menu",
      "type":"application/vnd.lime.document-select+json",
      "resource": {
        "options":[
          {
            "label":{
              "type":"text/plain",
              "value":"Option 1"
            }
          },
          {
            "label":{
              "type":"text/plain",
              "value":"Option 2"
            }
          },
          {
            "label":{
              "type":"text/plain",
              "value":"Option 3"
            }
          }
        ]
      }
    }
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "2",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    client.sendCommand({  
        id: Lime.Guid(),
        method: Lime.CommandMethod.SET,
        uri:"/profile/persistent-menu",
        type:"application/vnd.lime.document-select+json",
        resource: {
            "options":[
            {
                "label":{
                "type":"text/plain",
                "value":"Option 1"
                }
            },
            {
                "label":{
                "type":"text/plain",
                "value":"Option 2"
                }
            },
            {
                "label":{
                "type":"text/plain",
                "value":"Option 3"
                }
            }
            ]
        }
    })
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Lime.Messaging.Contents;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Profile;
    
    namespace Extensions
    {
        public class ProfileMessageReceiver : IMessageReceiver
        {
            private readonly IMessagingHubSender _sender;
            private readonly IProfileExtension _profileExtension;
    
            public ProfileMessageReceiver(IMessagingHubSender sender, IProfileExtension profileExtension)
            {
                _sender = sender;
                _settings = settings;
                _profileExtension = profileExtension;
            }
    
            public async Task ReceiveAsync(Message m, CancellationToken cancellationToken)
            {
                var menu = new DocumentSelect
                {
                    Options = new DocumentSelectOption[]
                    {
                        new DocumentSelectOption
                        {
                            Label = new DocumentContainer
                            {
                                Value = new PlainText
                                {
                                    Text = "Option 1"
                                }
                            }
                        },
                        new DocumentSelectOption
                        {
                            Label = new DocumentContainer
                            {
                                Value = new PlainText
                                {
                                    Text = "Option 2"
                                }
                            }
                        },
                        new DocumentSelectOption
                        {
                            Label = new DocumentContainer
                            {
                                Value = new PlainText
                                {
                                    Text = "Option 3"
                                }
                            }
                        }
                    }
                };
    
                await _profileExtension.SetPersistentMenuAsync(menu, cancellationToken);
            }
        }
    }
    

    In order to set a Messenger persistent menu for your chatbot, use a set command on /profile/persistent-menu URI. This sample shows how to add a simple persistent menu (only on Facebook Messenger channel) with 3 options Option 1, Option 2 and Option 3.

    Setting complex persistent menu

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "3",
      "method": "set",
      "uri":"/profile/persistent-menu",
      "type":"application/vnd.lime.document-select+json",
        "resource":{
          "options":[
            {
              "label":{
                "type":"application/vnd.lime.document-select+json",
                "value":{
                  "header":{
                    "type":"text/plain",
                    "value":"Option 1"
                  },
                  "options":[
                    {
                      "label":{
                        "type":"text/plain",
                        "value":"Option 1.1"
                      }
                    },
                    {
                      "label":{
                        "type":"application/vnd.lime.web-link+json",
                      "value":{
                        "text":"Option 1.2",
                        "uri":"https://address.com/option1.2"
                      }
                    }
                  },
                  {
                    "label":{
                      "type":"application/vnd.lime.document-select+json",
                      "value":{
                        "header":{
                          "type":"text/plain",
                          "value":"Option 1.3"
                        },
                        "options":[
                          {
                            "label":{
                              "type":"text/plain",
                              "value":"Option 1.3.1"
                            }
                          },
                          {
                            "label":{
                              "type":"text/plain",
                              "value":"Option 1.3.2"
                            }
                          },
                          {
                            "label":{
                              "type":"text/plain",
                              "value":"Option 1.3.3"
                            }
                          }
                        ]
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "label":{
              "type":"text/plain",
              "value":"Option 2"
            }
          },
          {
            "label":{
              "type":"application/vnd.lime.web-link+json",
              "value":{
                "text":"Option 3",
                "uri":"https://address.com/option1.3"
              }
            }
          }
        ]
      }
    }
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "3",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    client.sendCommand({  
        id: Lime.Guid(),
        method: Lime.CommandMethod.SET,
        type:"application/vnd.lime.document-select+json",
        resource:{
          "options":[
            {
              "label":{
                "type":"application/vnd.lime.document-select+json",
                "value":{
                  "header":{
                    "type":"text/plain",
                    "value":"Option 1"
                  },
                  "options":[
                    {
                      "label":{
                        "type":"text/plain",
                        "value":"Option 1.1"
                      }
                    },
                    {
                      "label":{
                        "type":"application/vnd.lime.web-link+json",
                      "value":{
                        "text":"Option 1.2",
                        "uri":"https://address.com/option1.2"
                      }
                    }
                  },
                  {
                    "label":{
                      "type":"application/vnd.lime.document-select+json",
                      "value":{
                        "header":{
                          "type":"text/plain",
                          "value":"Option 1.3"
                        },
                        "options":[
                          {
                            "label":{
                              "type":"text/plain",
                              "value":"Option 1.3.1"
                            }
                          },
                          {
                            "label":{
                              "type":"text/plain",
                              "value":"Option 1.3.2"
                            }
                          },
                          {
                            "label":{
                              "type":"text/plain",
                              "value":"Option 1.3.3"
                            }
                          }
                        ]
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "label":{
              "type":"text/plain",
              "value":"Option 2"
            }
          },
          {
            "label":{
              "type":"application/vnd.lime.web-link+json",
              "value":{
                "text":"Option 3",
                "uri":"https://address.com/option1.3"
              }
            }
          }
        ]
      }
    })
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Lime.Messaging.Contents;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Profile;
    using System;
    
    namespace Extensions
    {
        public class ProfileMessageReceiver : IMessageReceiver
        {
            private readonly IMessagingHubSender _sender;
            private readonly IProfileExtension _profileExtension;
    
            public ProfileMessageReceiver(IMessagingHubSender sender, IProfileExtension profileExtension)
            {
                _sender = sender;
                _settings = settings;
                _profileExtension = profileExtension;
            }
    
            public async Task ReceiveAsync(Message m, CancellationToken cancellationToken)
            {
                var complexMenu = new DocumentSelect
                {
                    Options = new DocumentSelectOption[]
                    {
                        new DocumentSelectOption
                        {
                            Label = new DocumentContainer
                            {
                                Value = new DocumentSelect
                                {
                                    Header = new DocumentContainer{
                                        Value = new PlainText
                                        {
                                            Text = "Option 1"
                                        }
                                    },
                                    Options = new DocumentSelectOption[]
                                    {
                                        new DocumentSelectOption
                                        {
                                            Label = new DocumentContainer
                                            {
                                                Value = new PlainText
                                                {
                                                    Text = "Option 1.1"
                                                }
                                            }
                                        },
                                        new DocumentSelectOption
                                        {
                                            Label = new DocumentContainer
                                            {
                                                Value = new WebLink
                                                {
                                                    Text = "Option 1.2",
                                                    Uri = new Uri("https://address.com/option1.2")
                                                }
                                            }
                                        },
                                        new DocumentSelectOption
                                        {
                                            Label = new DocumentContainer
                                            {
                                                Value = new DocumentSelect
                                                {
                                                    Header = new DocumentContainer{
                                                        Value = new PlainText
                                                        {
                                                            Text = "Option 1.3"
                                                        }
                                                    },
                                                    Options = new DocumentSelectOption[]
                                                    {
                                                        new DocumentSelectOption
                                                        {
                                                            Label = new DocumentContainer{
                                                                Value = new PlainText
                                                                {
                                                                    Text = "Option 1.3.1"
                                                                }
                                                            },
                                                        },
                                                        new DocumentSelectOption
                                                        {
                                                            Label = new DocumentContainer{
                                                                Value = new PlainText
                                                                {
                                                                    Text = "Option 1.3.2"
                                                                }
                                                            },
                                                        },
                                                        new DocumentSelectOption
                                                        {
                                                            Label = new DocumentContainer{
                                                                Value = new PlainText
                                                                {
                                                                    Text = "Option 1.3.3"
                                                                }
                                                            },
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        new DocumentSelectOption
                        {
                            Label = new DocumentContainer
                            {
                                Value = new PlainText
                                {
                                    Text = "Option 2"
                                }
                            }
                        },
                        new DocumentSelectOption
                        {
                            Label = new DocumentContainer
                            {
                                Value = new PlainText
                                {
                                    Text = "Option 3"
                                }
                            }
                        }
                    }
                };
    
                await _profileExtension.SetPersistentMenuAsync(complexMenu, cancellationToken);
            }
        }
    }
    

    Last but not least, you can also add a complex persistent menu (with links and submenus) using a SET command on /profile/persistent-menu URI. This sample shows how to add a complex persistent menu (only on Facebook Messenger channel) with 3 options SubMenu 1, Option 2 and Option 3 as a web link.

    Set start button

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "4",
      "method": "set",
      "uri": "/profile/get-started-label",
      "type": "text/plain",
      "resource": "Start now"
    }
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "4",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    client.sendCommand({
      id: Lime.Guid(),
      method: Lime.CommandMethod.SET,
      uri: "/profile/get-started-label",
      type: "text/plain",
      resource: "Start now"
    })
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Lime.Messaging.Contents;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Profile;
    
    namespace Extensions
    {
        public class ProfileMessageReceiver : IMessageReceiver
        {
            private readonly IMessagingHubSender _sender;
            private readonly IProfileExtension _profileExtension;
    
            public ProfileMessageReceiver(IMessagingHubSender sender, IProfileExtension profileExtension)
            {
                _sender = sender;
                _settings = settings;
                _profileExtension = profileExtension;
            }
    
            public async Task ReceiveAsync(Message m, CancellationToken cancellationToken)
            {
                var command = new Command()
                {
                    Id = EnvelopeId.NewId(),
                    Method = CommandMethod.Set,
                    Uri = new LimeUri("/profile/get-started-label"),
                    Resource = new PlainText { Text = "Start now" }
                };
    
                await _sender.SendCommandAsync(command, cancellationToken);
            }
        }
    }
    

    In order to set a get started button for your chatbot, use a set command on /profile/get-started-label URI. This sample shows how to add a button with Start now as label.

    Set a start message

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "4",
      "method": "set",
      "uri": "/profile/get-started",
      "type": "text/plain",
      "resource": "Let's begin"
    }
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "4",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "set",
      "status": "success"
    }
    
    client.sendCommand({
      id: Lime.Guid(),
      method: Lime.CommandMethod.SET,
      uri: "/profile/get-started",
      type: "text/plain",
      resource: "Let's begin"
    })
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Lime.Messaging.Contents;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Profile;
    
    namespace Extensions
    {
        public class ProfileMessageReceiver : IMessageReceiver
        {
            private readonly IMessagingHubSender _sender;
            private readonly IProfileExtension _profileExtension;
    
            public ProfileMessageReceiver(IMessagingHubSender sender, IProfileExtension profileExtension)
            {
                _sender = sender;
                _settings = settings;
                _profileExtension = profileExtension;
            }
    
            public async Task ReceiveAsync(Message m, CancellationToken cancellationToken)
            {
                await _profileExtension.SetGetStartedAsync(new PlainText { Text = "Let's begin" }, cancellationToken);
            }
        }
    }
    

    In order to set a get started button for your chatbot, use a set command on /profile/get-started URI. This sample shows how to add a button that sends the text Let's begin to your chatbot during the first client interaction.

    Get greeting message

    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "5",
      "method": "get",
      "uri": "/profile/greeting"  
    }
    
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "id": "5",
      "from": "postmaster@msging.net/#irismsging1",
      "to": "contact@msging.net/default",
      "method": "get",
      "status": "success",
      "type": "text/plain",
      "resource": "Hello and welcome to our service!"
    }
    
    client.sendCommand({
      id: Lime.Guid(),
      method: Lime.CommandMethod.GET,
      uri: "/profile/greeting"
    })
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Receivers;
    using Take.Blip.Client.Extensions.Profile;
    
    namespace Extensions
    {
        public class ProfileMessageReceiver : IMessageReceiver
        {
            private readonly IMessagingHubSender _sender;
            private readonly IProfileExtension _profileExtension;
    
            public ProfileMessageReceiver(IMessagingHubSender sender, IProfileExtension profileExtension)
            {
                _sender = sender;
                _settings = settings;
                _profileExtension = profileExtension;
            }
    
            public async Task ReceiveAsync(Message m, CancellationToken cancellationToken)
            {
                var greetingMessage = await _profileExtension.GetGreetingAsync(cancellationToken);
            }
        }
    }
    

    Retrieve a saved chatbot's greeting message using a get command on /profile/greeting URI.

    Chat history

    The threads (or chat history) extension allows the chatbot to retrieve the last threads and messages exchanged with the customers.

    To get client's threads or messages exchanged with a bot, send a command with the following properties:

    Name Description
    id Unique identifier of the command.
    method get
    uri /threads
    to postmaster@msging.net (not required)

    Get last threads

    client.addMessageReceiver('text/plain', async (message) => {
        var lastThreads = await client.sendCommand({  
            id: Lime.Guid(),
            method: Lime.CommandMethod.GET,
            uri: '/threads'
        });
        lastThreads.resource.items.forEach(function (item) {
            console.log(item);
        });  
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "0094447a-2581-4597-be6a-a5dff33af156",
      "method": "get",
      "uri": "/threads"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "itemType": "application/vnd.iris.thread+json",
        "items": [
          {
            "ownerIdentity": "contact@msging.net",
            "identity": "1180740631991418@messenger.gw.msging.net",
            "lastMessage": {
              "id": "39ed84b9-f89e-4090-a27e-6bd1e69bdfef",
              "direction": "sent",
              "type": "text/plain",
              "content": "Welcome to our service!",
              "date": "2016-12-06T12:32:44.799Z"
            },
            "unreadMessages": 0
          },
          {
            "ownerIdentity": "contact@msging.net",
            "identity": "29%3A1SaTsDWumQFx72srIXI8uhTlpRzPwuJ4TRVhRpSBB7mQ@skype.gw.msging.net",
            "lastMessage": {
              "id": "cc2b70ce-921b-4856-ae41-f00d897f1423",
              "direction": "received",
              "type": "text/plain",
              "content": "Hi",
              "date": "2016-11-24T20:41:38.940Z"
            },
            "unreadMessages": 1
          }
        ]
      },
      "method": "get",
      "status": "success",
      "id": "0094447a-2581-4597-be6a-a5dff33af156",
      "from": "postmaster@msging.net/#az-iris3",
      "to": "contact@msging.net",
      "metadata": {
          "#command.uri": "lime://contact@msging.net/threads"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.Threads;
    
    namespace Extensions
    {
        public class GetThreadsReceiver : IMessageReceiver
        {
            private readonly IThreadExtension _threadExtension;
    
            public GetThreadsReceiver(IThreadExtension threadExtension)
            {
                _threadExtension = threadExtension;
            }
    
            public async Task ReceiveAsync(Message receivedMessage, CancellationToken cancellationToken)
            {
                var lastThreads = await _threadExtension.GetThreadsAsync(cancellationToken);
            }
        }
    }
    

    Getting the last chatbot's threads. By default, BLiP returns the last 50 threads.

    The following uri filters are available to get chatbot's threads:

    QueryString Description
    $take Limit of total of items to be returned. The maximum value allowed is 100
    messageDate Initial date on the threads query

    Get last messages

    client.addMessageReceiver('text/plain', async (message) => {
        var lastMessages = await client.sendCommand({  
            id: Lime.Guid(),
            method: Lime.CommandMethod.GET,
            uri: '/threads/destination@0mn.io'
        });
        lastMessages.resource.items.forEach(function (item) {
            console.log(item);
        });  
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "0094447a-2581-4597-be6a-a5dff33af156",
      "method": "get",
      "uri": "/threads/1180740631991418@messenger.gw.msging.net"
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
      "type": "application/vnd.lime.collection+json",
      "resource": {
        "total": 3,
        "itemType": "application/vnd.iris.thread-message+json",
        "items": [
          {
            "id": "39ed84b9-f89e-4090-a27e-6bd1e69bdfef",
            "direction": "sent",
            "type": "text/plain",
            "content": "Welcome!",
            "date": "2016-12-06T12:32:44.799Z",
            "status": "consumed"
          },
          {
            "id": "15073ef5-9bab-493c-b630-8636eacba33e",
            "direction": "sent",
            "type": "text/plain",
            "content": "This is a test chatbot.",
            "date": "2016-12-06T12:32:40.640Z",
            "status": "consumed"
          },
          {
            "id": "9b49a7d6-d025-4bb6-a370-1d48fb457deb",
            "direction": "received",
            "type": "text/plain",
            "content": "Good morning",
            "date": "2016-12-06T12:32:35.398Z",
            "status": "accepted"
          }
        ]
      },
      "method": "get",
      "status": "success",
      "id": "0094447a-2581-4597-be6a-a5dff33af156",
      "from": "postmaster@msging.net/#az-iris1",
      "to": "contact@msging.net",
      "metadata": {
          "#command.uri": "lime://contact@msging.net/threads/destination@0mn.io"
      }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.Threads;
    
    namespace Extensions
    {
        public class GetMessagesReceiver : IMessageReceiver
        {
            private readonly IThreadExtension _threadExtension;
    
            public GetMessagesReceiver(IThreadExtension threadExtension)
            {
                _threadExtension = threadExtension;
            }
    
            public async Task ReceiveAsync(Message receivedMessage, CancellationToken cancellationToken)
            {
                var lastMessages = await _threadExtension.GetThreadAsync(
                    "destination@0mn.io", 
                    cancellationToken
                );
            }
        }
    }
    

    Getting the last chatbot's messages in a specific thread. The thread is identified by a client identity (for example: 1180740631991418@messenger.gw.msging.net). By default, BLiP will return the last 20 thread messages.

    The following uri filters are available to get a chatbot's thread:

    QueryString Description
    $take Limit of total of items to be returned. The maximum value allowed is 100
    messageId Initial message id for the thread messages query
    direction Possible values: asc and desc. Define if will be returned de messages after or before respectively

    Contacts

    The contacts extension allows the management of the chatbot's roster, which can be used to store data of the chatbot's clients. It is possible to save information like name, address, gender and other generic information, using the extras property. It is also possible to use the contacts fields as variables of the messages sent by the chatbot. This property only allows string values and does not allows complex objects. You can also set the group property for contacts organization. Events where the identity property is from a special group called 'testers' will be ignored on BLiP events dashboard.

    To use any feature of contacts extension send a command with the following properties:

    Name Description
    id Unique identifier of the command.
    method The command verb
    resource The contact document.
    type "application/vnd.lime.contact+json"
    uri /contacts
    to postmaster@msging.net (not required)

    The command's properties resource and method can change according to the feature. A contact object passed as a document resource has the following properties:

    Property Description Example
    identity The client identity in a specific channel. 11121023102013021@messenger.gw.msging.net (Messenger user)
    name Optional The client's name (string). "Rafael Pacheco"
    gender Optional The client's gender (string). "male"
    group Optional The client's group tag (string). "testers"
    address Optional The client's address (string). "83, Paraguassu Street"
    city Optional The client's city (string). "Belo Horizonte"
    email Optional The client's email (string). "rafaelpa@take.net"
    phoneNumber Optional The client's phone number (string). "5531000000000"
    cellPhoneNumber Optional The client's cell phone number (string). "5531999999999"
    timezone Optional The client's timezone id (int). -3
    culture Optional The client's culture info (string). "pt-br"
    extras Optional The client's extra informations. {"customerExternalId": "41231", "cpf": "00000000000" }

    For more information about the supported fields, please refer to the Lime protocol documentation.

    Message variable replacement

    The contacts fields can be used to replace variables on messages sent by the chatbot. To make a replacement in a message, the metadata key #message.replaceVariables should be present with the value true and the message text should have variables in the ${contact.<propertyName>} format, where <propertyName> is the contact property for replacement. It is possible to use all fields from the contact, including the keys in the extras property. In this case, is only required to use the ${contact.extras.<extraPropertyName>} convention, where <extraPropertyName> is the value for replacement. If the value is not available, it is only removed from the message.

    Add (or update) a contact

    client.addMessageReceiver('text/plain', async (message) => {
        await client.sendCommand({  
            id: Lime.Guid(),
            method: Lime.CommandMethod.SET,
            uri: '/contacts',
            type: 'application/vnd.lime.contact+json',
            resource: {
                identity: '11121023102013021@messenger.gw.msging.net',
                name: 'John Doe',
                gender:'male',
                group: 'friends',    
                extras: {
                    plan: 'Gold',
                    code: '1111'      
                }
            }
        });
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id": "1",
      "method": "set",
      "uri": "/contacts",
      "type": "application/vnd.lime.contact+json",
      "resource": {
        "identity": "11121023102013021@messenger.gw.msging.net",
        "name": "John Doe",
        "gender":"male",
        "group":"friends",    
        "extras": {
          "plan":"Gold",
          "code":"1111"      
        }
      }
    }
    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
        "method": "set",
        "status": "success",
        "id": "1",
        "from": "postmaster@crm.msging.net/#az-iris5",
        "to": "contact@msging.net",
        "metadata": {
            "#command.uri": "lime://contact@msging.net/contacts"
        }
    }
    
    using System.Threading;
    using System.Threading.Tasks;
    using Lime.Protocol;
    using Take.Blip.Client;
    using Take.Blip.Client.Extensions.Contacts;
    using Lime.Messaging.Resources;
    using System.Collections.Generic;
    
    namespace Extensions
    {
        public class ContactMessageReceiver : IMessageReceiver
        {
            private readonly ISender _sender;
            private readonly Settings _settings;
            private readonly IContactExtension _contactExtension;
    
            public ContactMessageReceiver(ISender sender, Settings settings, IContactExtension contactExtension)
            {
                _sender = sender;
                _settings = settings;
                _contactExtension = contactExtension;
            }
    
            public async Task ReceiveAsync(Message message, CancellationToken cancellationToken)
            {
                var identity = new Identity("11121023102013021", "messenger.gw.msging.net");
                var contact = new Contact
                {
                    Name = "John Doe",
                    Gender = Gender.Male,
                    Group = "friends",
                    Extras = new Dictionary<string, string>
                    {
                        {"plan", "gold" },
                        {"code", "1111" },
                    }
                };
    
                await _contactExtension.SetAsync(identity, contact, cancellationToken);
            }
        }
    }
    

    In order to store informations about a chatbot's client, it is possible to save and update data using contacts extension. This sample shows how to add a Messenger customer with identity 11121023102013021@messenger.gw.msging.net to the chatbot's roster.

    Get contact

    client.addMessageReceiver('text/plain', async (message) => {
        var data = await client.sendCommand({  
            id: Lime.Guid(),
            method: Lime.CommandMethod.GET,
            uri: '/contacts/11121023102013021@messenger.gw.msging.net'
        });
        console.log(data);
    });
    
    POST https://msging.net/commands HTTP/1.1
    Content-Type: application/json
    Authorization: Key {YOUR_TOKEN}
    
    {  
      "id":