I've opened up a twilio trial account. I want to use my verified called ID number in my asp.net application instead of buying a new twilio number. But I don't know how to use it. Here are my codes,
public ActionResult SendSms()
{
string ACC_SID = ConfigurationManager.AppSettings["ACC_SID"];
string AUTH_TKN = ConfigurationManager.AppSettings["AUTH_TKN"];
TwilioRestClient client = new TwilioRestClient(ACC_SID, AUTH_TKN);
client.SendMessage("+8801941234567", "+8801671234567", string.Format("This is a test message!"));
return RedirectToAction("SmsView");
}
Nothing happened with it. How can I use my called ID to send sms?
I faced the same scenario while I was working on Twilio first time and at that time I used below steps to make things workable.
1) First of all I would suggest please add Try{} catch{} block in your SendSMS function. this will give you idea like SendMessage worked correctly.
2) In twilio we need to register mobile no before send SMS.
3) if your function works fine(no error occur) then in Twilio there is LOG tab where you can see weather your SMS send correctly or not.
Twilio developer evangelist here.
Jinesh's answer has some useful parts, like using a try/catch block to see errors.
However, the problem is that you are trying to send an SMS from your own number, not from a Twilio number. When sending SMS, you can only send from Twilio numbers. Please see this page for details on why.
You should have got a Twilio number when you signed up. Try using that number as the From number instead.
Related
I'm trying to create a way to check whether a given email (either from Outlook itself or an MSG file) is a sent, received or a draft email. I got the bit to compare if it was sent or received somewhere else and that works fine but it's the part that determines if it's a draft or not that is the issue. Below is what I have currently.
L-EMAIL = Aspose.Email.Mapi.MapiMessage:FromFile(P-FILENAME).
L-EMAIL-FLAG = Integer(L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_MESSAGE_FLAGS]:ToString()).
IF L-EMAIL-FLAG = 8 THEN
L-EMAIL-STATUS = "DRAFT".
ELSE
IF L-EMAIL:Properties[Aspose.Email.Mapi.MapiPropertyTag:PR_RECEIVED_BY_ENTRYID] = ? THEN
L-EMAIL-STATUS = "SENT".
ELSE
L-EMAIL-STATUS = "RECEIVED".
If there's no attachments to the emails, it works fine since the value of a draft email is always 8 but as soon as you add attachments, it gets all weird with the values so I can't get a range down (I've gotten values like 24 and 242613 while a sent email with an attachment has a value of 49). Anyone know a smarter way of telling if it's a draft or not?
I never had a good experience working with Outlook and Progress internally... what I've managed to accomplish on my project was to create a custom DLL with C# and integrated it on my system.
So, I have an char that triggers some procedures inside my DLL and sends and receives emails (saves as .msg), making my Progress code a lot more easier to manage.
In your case, you should try something like this:
Outlook MailItem: How to distinguish whether mail is incoming or outgoing?
Solution I found was to use a C# DLL to convert the email to an Outlook mail item using the interop:
public bool IsDraft(string path)
{
Outlook.Application oApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
Outlook.MailItem email = oApp.Session.OpenSharedItem(path) as Outlook.MailItem;
bool isSent = email.Sent;
Marshal.ReleaseComObject(email);
email = null;
return !isSent;
}
I had to release the email object so that code further on wouldn't break.
The PidTagMessageFlags property value is a bitmask of flags. This means a bitwise operator must be applied to check a specific flag value.
IF L-EMAIL-FLAG = 8 THEN
Please replace above line with following line of code. Hope this helps you.
IF (L-EMAIL-FLAG AND 8) = 8 THEN
I work with Aspose as Developer Evangelist.
I've deployed my Bot to Webchat, Skype and MS Teams.
In OnTurnAsync method I check, if the user input begins with bnr then I call a specific method.
if (turnContext.Activity.Text.ToLower().StartsWith("bnr"))
{
string msg = RequestHandler.BnrCaller(turnContext.Activity.Text);
await turnContext.SendActivityAsync(msg);
return;
}
It works fine with Skype and Webchat but with teams it does not work 100%, It works just sometimes.
[Edit]
I found out, that it does not work if I copied the input into the input field but when I type it, it works fine!
The Messages coming from the Teams are having a different structure.
The message text begins with the words <at>...</at>.
You need to delete this beginning in a Middleware component, etc.
Try to look at your incoming messages through NGROK at localhost:4040 in your web browser.
So, I found out the issue by dint of app-insights.
I've added a middleware, which logs the request body into app-insights and just realized, that when I copy/paste a message like: "Hello", it would be logged in app-insights as something like this "\r\n\n\rHello\r\n\n\r\n". When I type it, it would be logged just fine.
So I jsut remove these symboles from the request and it works!
i find new_chat_participant or left_chat_participant but that work only in group chat.
I've used the new_chat_members event to know weather a new user joined the bot or not. But seems that this event will not be emitted.
But using the message event I will get the below result:
{"message_id":4,"from":{"id":324299944,"is_bot":false,"first_name":"foo","last_name":"bar","language_code":"en"},"chat":{"id":324299944,"first_name":"foo","last_name":"bar","type":"private"},"date":1513786467,"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}]
i write bot with java script and in the google app script .
my oreginal problem is how to find out a user stop or left the bot
For some reason that I was not able to find in the docs telegram doesn't send updates when user leaves the private group. It only does it for public groups (ex supergroups). Another curious thing is that the update message contains "left_chat_participant" and "left_chat_member" objects with the exact same info, probably for some bc
unfortunately currently there is no way to found out the user block the bot. new_chat_participant or left_chat_participant presented in telegram bot API v3 for completely another purpose.
I try really hard to understand howto use Telegram api with telethon. I have some Channels in Telegram, where i want to delete older Messages. Using inputpeerchannel() i need channel_id (No Problem) and channel_hash. I cant findout howto get this channel_hash by channel_id. Thank you from germany
In order to find channel access_hash, you should resolve channel username. Original MTProto method contacts.resolveUsername#f93ccba3 gets #username and returns channel info including access_hash.
In telethon you need to invoke ResolveUsernameRequest to call the above original MTProto method. You may use this code to resolve username to access_hash:
client = TelegramClient(session_file, api_id=00000, api_hash='XXXXX')
client.connect()
response = client.invoke(ResolveUsernameRequest("your_channel_id"))
print(response.chats[0].access_hash)
client.disconnect()
There are 4 ways to get access hash:
From a Group
From username
From contact list
From chats message
So, if you have id only, there is no way to get access hash
suppose i have forum where people post their question and another people post the answer. say for example person A post a question "What is signalr ?" and stand at that page. other person also open that page for answering. if other person post any answer then i want that that answer will be shown in that page open by other users. suppose five user open that page and one of them answer then five user will see that answer.
normally when we like to broadcast any message to all then we use syntax like at server end
Clients.All.broadcastMessage(name, message);
so according to my above situation what kind of syntax i need to use?
here are few guide i found for broad cast message type and those are follows
// Call send on everyone
Clients.All.send(message);
// Call send on everyone except the caller
Clients.Others.send(message);
// Call send on everyone except the specified connection ids
Clients.AllExcept(Context.ConnectionId).send(message);
// Call send on the caller
Clients.Caller.send(message);
// Call send on everyone in group "foo"
Clients.Group("foo").send(message);
// Call send on everyone else but the caller in group "foo"
Clients.OthersInGroup("foo").send(message);
// Call send on everyone in "foo" excluding the specified connection ids
Clients.Group("foo", Context.ConnectionId).send(message);
// Call send on to a specific connection
Clients.Client(Context.ConnectionId).send(message);
which one i need to use ? please explain & thanks.
You could have a div on the page that has an id of the question. So you would have something like:
<div id="theAskedQuestionId"><!-- the answer will be inserted here--></div>
so for example:
<div id="12345"><!-- the answer will be inserted here--></div>
And then you can use jquery to inject the answer into the div. An example of this is:
var messagePublisher = $.connection.yourHubName;
messagePublisher.client.broadcastMessage = function(divId, message){
$(divId).html(message); //note: divId will be something like #12345
};
This will allow you to only show the message to the users that are looking at the specific question instead of broadcasting the message to users looking at any question. I think this is what you were asking for help on.