Telegram Threshold messages mix customers - thingsboard

I'm new in this tecnologies and i got some questions and issues sending messsages with telegram botfather to customers, so here is my problem.
When a threshold alarm comes true for a customer expesific device the rule chain send messsages to all customers. Example:
"Customer A" with "Device A"
"Customer B" with "Device B".
When threshold alarm comes true with "Device A" should send message only to "customer A" but the warning it send it to customer B too and viceversa if i a have more customers.
How can i fix this?
i'll leave some pics.
Rule Chain: https://imagizer.imageshack.com/v2/640x480q90/923/QOBI21.png
Threshold script: https://imagizer.imageshack.com/img923/503/qLJ5ZW.png
Alarm Script: https://imagizer.imageshack.com/img923/9770/LGtq3Q.png
Message Script: https://imagizer.imageshack.com/img924/2285/AVPNcl.png
P.D: im using ESP32 with Arduino.

Related

Interactive Brokers is this error? 10197 "No market data during competing live session"

I'm trying to get the price for stock option for the Japan "6503" stock, and I get the error:
Error code 10197 No market data during competing live session
I don't have subscription for Japan Market, but I still can see the "last price" for the option in TWS User Interface (not for all but for some option contracts, for some it's unavailable and displayed as "n/a").
Question - it seems like this error code - is not actually an error and could be ignored, is that true? The error doesn't make sense at all as I don't have any competing session or paper session.
I'm using the TWS Java API with the following code to get the price:
val contract = Contract()
contract.exchange("OSE.JPN")
contract.currency("JPY")
contract.conid(455178173)
contract.secType(Types.SecType.OPT)
client.reqMarketDataType(MarketDataType.DELAYED_FROZEN)
client.reqMktData(request_id, contract, "", false, false, null)
I'm using the conid 455178173 to get the price, if you need the full info about the option, here it is:
symbol: "6503",
right: "call",
expiration: "2021-01-07",
strike: 1200.0,
option_exchange: "OSE.JPN",
currency: "JPY",
This error happens when you have a "live" session thats competing for data. Which means you have a live TWS terminal thats showing the live data and you are requesting data from your Paper account via the API.
The API won't return the requested data (showing this error) because the same data is being sent to the live account.

Twilio Target Worker Expression--blocking voice calls while on a text

I've read the documentation here: https://www.twilio.com/docs/taskrouter/multitasking#preventing-a-worker-from-receiving-chat-tasks-if-on-a-voice-task on how to block an agent from getting chats while they are on a voice call, but I want to do the reverse with a twist.
I successfully managed to stop workers from getting a voice call while they have an active chat going using "worker.channel.chat.assigned_tasks == 0" as the Expression. However, it also prevents a second chat, SMS, Facebook, or WhatsApp message coming in even though the worker's capacity is higher than 1.
Would love suggestions on what the expression should be so that the additional SMS or chats can come through up to the worker's capacity but not any voice calls when they have an active chat or SMS going.
The following filter should do the trick. The expression will only apply to voice tasks and the target routes to workers with no assigned chats.
{
"filter_friendly_name": "Do not assign Voice Tasks if assigned Chat",
"expression": "(task_channel_unique_name=='voice')",
"targets": [
{
"queue": <default queue sid>,
"expression": "worker.channel.chat.assigned_tasks == 0"
}
]
},

Does Firebase always guarantee added events in order?

I am developing messenger IOS app based on Firebase Realtime Database.
I want that all messages to be ordered based on timestamp.
There is a scenario as like below.
There are 3 clients. A, B and C.
1)
All clients register 'figure-1' listener to receive messages from others.
<figure-1>
ref.queryOrdered(byChild: "timestamp").queryStarting(atValue: startTime).observe(.childAdded, with:
{
....
// do work for the messages, print, save to storage, etc.
....
// save startTime to storage for next open.
startTime = max(timeOfSnapshot, startTime)
saveToStorage(startTime)
}
2)
Client A write message 1 to server with ServerValue.timestamp().
Client B write message 2 to server with ServerValue.timestamp().
Client C write message 3 to server with ServerValue.timestamp().
They sent messages extremely the same moment.
All clients have good speed wifi.
So, finally. Server data saved like 'figure-2'
<figure-2>
text : "Message 1", timestamp : 100000001
text : "Message 2", timestamp : 100000002
text : "Message 3", timestamp : 100000003
As my listener's code, i keep messages on storage and next listening timestamp for preventing downloading duplicated messages.
In this case.
Does Firebase always guarantee to trigger callback in order as like below?
Message 1
Message 2
Message 3
If it is not guaranteed, my strategy is absolutely wrong.
For example, some client received messages as like below.
Message 3 // the highest timestamp.
// app crash or out of storage
Message 1
Message 2
The client do not have chance to get message 1, 2 anymore.
I think if there are some nodes already, Firebase might trigger in order for those. Because, that is role of 'queryOrdered' functionality.
However, there are no node before register the listener and added new nodes additionally after then. What is will happen?
I suppose Firebase might send 3 packets to clients. (No matter how quickly the message arrives, Firebase has to send it out as soon as it arrives.)
Packet1 for message1
Packet2 for message2
Packet3 for message3
ClientA fail to receive for packet 1,2
ClientA success to receive for packet 3
Firebase re-send packet 1,2 again.
ClientA success to receive for packet 1,2
Eventually, all datas are consistent. But ordering is corrupted.
Does Firebase guarantee to occur events in order?
I have searched stack overflow and google and read official documents many times. However, i could not find the clear answer.
I have almost spent one week for this. Please give me piece of advice.
The order in which the data for a query is returns is consistent, and determined by the server. So all clients are guaranteed to get the results in the same order.
For new data that is sent to the database after the listeners are attached, all remote clients will receive it in the same order. The local client will see events for it's write operation right away though, before the data even reaches the database server.
In figure 2, it is actually quite simple: since each node has a unique timestamp, and they will be returned in the order of that timestamp. But even if they'd have the same timestamp, they'd be returned in the same order (timestamp first, then key) for each client.

Combining a multi-message incoming SMS message from Twilio

I'm building an SMS-enabled app that allows the user to communicate with an external contact. As incoming messages arrive, I save them to my database so that they can be displayed in the app.
In testing, everything is working great for one-off messages, but I'm having trouble with messages longer than 160 characters, which are actually broken up into multiple messages.
When an incoming message comes in via SMS, I'm checking whether we already got a message from that number within the past few seconds. If we have, I append to the existing record in my DB, rather than saving a new record.
// First message arrives:
record == "This is the first message."
// Second message arrives:
record == "This is the first message. This is the second message."
My problem is that sometimes the two messages arrive so quickly that the first record hasn't finished saving yet. When the second process queries for an existing record, it doesn't find one and creates a new one.
// First message arrives:
record1 == "This is the first message."
// Second message arrives, first isn't saved yet:
record1 == "This is the first message."
record2 == "This is the second message."
This makes a particularly bad user experience when there's a message with three or more segments, when the following happens:
// First message arrives:
record1 == "This is the first message."
// Second message arrives, first isn't saved yet.
record1 == "This is the first message."
record2 == "This is the second message."
// Third message arrives, first has now been saved.
record1 == "This is the first message. This is the third message."
record2 == "This is the second message."
Without abandoning my plan to re-combine these messages, how can I get the messages to appear in the right order?
*Note: * Ideally, I'd like to know when saving a message whether it is a first (new) message or a follow-up message. Receiving a new message triggers an email notification to the user, but I don't want to send multiple notifications if they're receiving one long message.

Twilio sms not coming in mobile

I have implemented test twilio sms application. I have downloaded three files from https://github.com/benedmunds/CodeIgniter-Twilio
I have used my account_sid, auth_token in twilio.php file which is in config folder. I have also used 'from' number as +15005550006 in that file.
I have used following codes in my controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Twiliosms extends TL_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->library('twilio');
$from = '+15005550006';
$to = '+91xxxxxxxxxx';
$message = 'This is a test...';
$response = $this->twilio->sms($from, $to, $message);
//echo "<pre>";print_r($response);echo "</pre>";
if($response->IsError)
echo 'Error: ' . $response->ErrorMessage;
else
//echo 'Sent message to ' . $to;
echo 'Sent message';
}
}
Now when I run the controller file in the browser(not in my machine but in server), it runs successfully and it shows "Sent message".
But no sms is received. Please help.
My name is Jarod and I work at Twilio. There are multiple reasons this could be failing so lets walk through them one at a time.
1. Sending an sms using Twilio test credentials will not result in an sms being sent.
Test credentials are used for testing and debugging your application. They are "fake" numbers, that do not send any data via carrier, but instead return preset error codes and responses in order to test response-handling in your application. As you experienced this specific test credential +15005550006 will always return NO ERROR, whereas +15005550001 will always respond with "This phone number is invalid".
2. You can only send SMS from a Twilio number or a verified phone number.
You can always send an SMS from a number you bought on Twilio.com, but in order to send an SMS from any other number you must first verify that phone number with Twilio. Read more about the difference here.
These are the most common reasons for not receiving and actual SMS but in the case of the Indian phone numbers it could very well be one of these rare limitations.
If none of these work we probably need to look into your specific account to find out what's happening, in which case you should reach out to support#twilio.com.
Hope this helps.
I banged my head against the walls for three hours and tried to work out with the number Twilio gave me at the time of sign up . But It always gave me the following error
{ "code": 21212, "message": "The 'From' number +234234234 is not a
valid phone number or shortcode.", "more_info":
"https://www.twilio.com/docs/errors/21212", "status": 400 }
At the end i got the exact point from where I got my test phone number for sms / call
Get your test phone number from Here .
You will have to make the from number a number you have verified with Twilio that you own: you can't just pick any number and use it. Do you own +15005550006, and have you verified that number in the Twilio admin console?

Resources