public async Task <IActionResult> SendMessage(string connectionId, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(RedirectToAction("Details", new { id = connectionId }));
            }

            var wallet = await _walletService.GetWalletAsync(_walletOptions.WalletConfiguration, _walletOptions.WalletCredentials);

            var messageRecord = new PrivateMessageRecord
            {
                Id           = Guid.NewGuid().ToString(),
                Direction    = MessageDirection.Outgoing,
                Text         = text,
                ConnectionId = connectionId
            };

            var message = new PrivateMessage {
                Text = text
            };
            var connection = await _connectionService.GetAsync(wallet, connectionId);

            // Save the outgoing message to the local wallet for chat history purposes
            await _recordService.AddAsync(wallet, messageRecord);

            // Send an agent message using the secure connection
            await _routerService.SendAsync(wallet, message, connection);

            return(RedirectToAction("Details", new { id = connectionId }));
        }
 /// <summary>
 /// Create a private message record
 /// </summary>
 /// <param name="privateMessageRecord">Record to insert in the database</param>
 public static void CreatePrivateMessage(PrivateMessageRecord privateMessageRecord)
 {
     PrivateMessagesCollection.InsertOne(privateMessageRecord);
 }