I have programmed a telegram bot. This works fine when sending to groups or to users. However I do a special requirement. I need to be able to send to another bot. When adding both bots to a group as administrators. I still cannot receive the message with my second bot. I only see it with my real user account, that is added to this group.
What am I missing?
I used OKHttp to send the message
Request request = new Request.Builder()
.url("https://api.telegram.org/bot"+telSetup.getToken()+"/sendMessage?chat_id="+lAdr+"&parse_mode=HTML&text="+strMessage)
.build();
client.newCall(request).enqueue(new MyIPProcessing(request.toString()));
and
if (response.message().equals("OK")){
List <String> lStr=response.request().url().encodedPathSegments();
...
to receive messages ... which basically works for communication with "real users".
Any ideas welcome ....
According to Bots FAQ
Bots talking to each other could potentially get stuck in unwelcome loops.
To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.
You can connect 2 (or more) bots with a private channel!
Just prompt the bots as admin in the channel.
Then when a bot send a post to the channel, other admin bots can see the message/file/...
Bot wouldn't be able to send message to other bots. in most platform APIs it return an error. kindly go through the documentation for the client(bot) and see its functionalities
Related
I'm trying to integrate Twilio email verification in my application. Here's the code:
public EmailVerificationDto sendVerificationEmail(String recipient) {
Verification verification = Verification.creator(
PATH_SERVICE_SID,
recipient,
"email")
.setChannelConfiguration(
new HashMap<>() {{
put("template_id", TEMPLATE_ID);
put("from", SENDER_EMAIL);
put("from_name", "Puggle");
}})
.create();
return new EmailVerificationDto(
verification.getTo(),
verification.getSid(),
verification.getStatus(),
verification.getDateCreated().toLocalDate()
);
}
I can see the email on the dashboard but it's stuck on processing:
I got the same problem, seems like SendGrid have problem with people using the service for fraudulent use so you need to get verified first. On the top of the page, you probably have a message saying that you need to get verified. You will need to fill a form, then they will contact you via email to gather some more information and accept or deny your access to the service.
I am creating a program that asks the user something like "How are you doing today":
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(new PhoneNumber("+000000"), // To
// number
new PhoneNumber("0000000"), // From number
"How are you doing today?" // SMS body
).create();
System.out.println(message.getSid());
And then then the program will listen for whatever response the user texts back from their phone.
Now, Twilio says this about receiving SMS:
You can associate that phone number with an SMS URL. When someone sends a text message to that phone number, Twilio makes an HTTP request to your URL with the body of the message and the sender's phone number. You can then respond to the SMS by returning a reply message in the HTTP response to Twilio.
Now, I understand that when the user texts back, Twilio makes an HTTP request to my program, like so:
However, in the tutorial, they create an HTTP tunnel using ngrok to allow the HTTP request to go through. My application is supposed to be able to run in anyone's computer without prior configuration. How would you recommend I achieve this?
I'm afraid that without exposing your application to the Net you won't be able to use that particular API.
What you can try to do instead is polling / fetching:
When you send an SMS or MMS message via the REST API, using the
<Message> verb in TwiML, or someone sends a message to one of your
Twilio numbers Twilio creates a Message instance resource. The
Messages list resource represents the set of messages sent from and
received by an account.
Retrieving sent and received messages from history can be achieved by
querying the Messages list resource.
A short example to start with is available here.
I wrote a Telegram Bot in groovy and it was a piece of cake.
Now in order to register propper webhooks I need to get a hold of user's id.
I read, that I should call auth.sendCode method to start that process.
Are there any simpler alternatives to that?
If not, how can I invoke the sendCode with the smallest effort and possibly w/o any additional dependencies? Any examples or pointers using plain java or curl would be good.
After some research I ended up with a simple solution.
Instead of authenticating against the Telegram API over MTProto, I reversed the process. I implemented a new bot-command:
/login {my-user-id}
so that the user sends his id (can be some generated token later) in Telegram bot chat and the bot sends this message - along with Telegram user id! - over webhook to my server, where I do the matching and saving.
The implementation looks like this:
switch( json.message.text ){
case ~/\/login \w+/:
String userId
text.toLowerCase().eachMatch( /\/login (\w+)/ ){ userId = it[ 1 ] }
String telegramUserId = json.message.from.id
saveJoin userId, telegramUserId
break
}
I have this really weird problem and I'm not able to find a solution... I hope you can help me...
I'm working in Google App Engine to build my App (lets call it "MyApp"), to test, I have a cloned app renamed as "sandbox-MyApp".
I need to allow my users send a mail with some data, so I have a form where they can fill some information that will be added to the message.
I've working with this scenario a long time ago, but now I'm having issues, because, for some reason, my out-coming mails are not being received by the recipients...
It's a really weird thing about this, because, I can send one or two mails without problem, but after that, they suddenly stop, and after some code-changes, they work again.
I'm using Java.Mail to do the work,
I'm trying to send a simple HTML,
My "from" address is something like "userName#sandbox-myApp.appspotmail.com"
My Subject its something like: "Hello userName! There is some important message for you"
The message it's really simple, includes an image logo (served by an https://sandbox-myApp.appspot.com/img/logo.png), an invitation text and a single link to my app URL... (https://sandbox-myApp.appspot.com/)
My code it's real simple, based on the Google Documentation.
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(senderAddress, MimeUtility.encodeText(senderLabel, "UTF-8", "B"), "UTF-8"));
msg.addRecipient(javax.mail.internet.MimeMessage.RecipientType.TO, new InternetAddress(receiverAddress, receiverLabel, "UTF-8"));
if(responseAddress != null && !responseAddress.trim().isEmpty()){
msg.setReplyTo(new Address[] {
new InternetAddress(responseAddress, MimeUtility.encodeText(senderLabel, "UTF-8", "B"))
});
}
msg.setSubject(MimeUtility.encodeText(subject, "UTF-8", "B"), "UTF-8");
msg.setContent(msgBody, "text/html;charset=UTF-8");
Transport.send(msg);
I've tried changing "from" to something like "app_admin#mydomain.com" and it works for a while, but after some mails (about 5 or 6), stop working too.
Most shocking thing: There aren't any error message on logs... The Cuota Viewer counts every sent mail (so I suppose it must being blocked somewhere else),
I've modiffied the message to omit any URL on the body and It works better, but I need to include it!.
Problem is tracked on https://code.google.com/p/googleappengine/issues/detail?id=12786
Workaround which worked for my application is to not use appspot.com domain.
Register custom domain for the application and then mails to the application using the custom domain work.
I am using the Twilio java wrapper provided on the website and started making some tests. I am able to send text messages that are successfully received. However, I would like to make sure that the messages have been sent successfully and that no problem has been encountered by Twilio (bad phone number or whatever reason).
I understand that when you make a REST request to Twilio to send a SMS, Twilio responds with the Status. How could I get this response?
Here is the explanation page I found: http://www.twilio.com/docs/howto/sms-notifications-and-alerts
If you specify a StatusCallback URL when you make the request to send an SMS, we will make a request to the callback URL you provided after the message has finished processing, with the parameters either SmsStatus=sent or SmsStatus=failed. You can use this information to do more processing on the SMS message. There's more information here: http://www.twilio.com/docs/api/rest/sending-sms#post-parameters-optional
Alternately, if you hang on to the SMS Message Sid, you should be able to query the API for the message and get the status in the response. So if the sid is SM123, making a GET request to https://api.twilio.com/2010-04-01/Accounts/AC123/SMS/Messages/SM123.json should return a object with the status of the SMS Message.
I recall that the response comes to your url and can be matched up by an ID. In the REST post to SMSMessages you can specify a statuscallback url where Twilio will post a status message to your url.
When you receive that post to your site, you can record it or take any other action you need, such as retrying or using another mode of communication.
In 2020, with the Java SDK, you can now create a MessageFetcher with that SID and then call fetch to ask for the Message instance until its getStatus returns "delivered", "undelivered", or "failed".