I have a c# app and I wish to send an sms to a specfic User whenever I have an update for that User.
I intend to have many different Users.
I heard that it is possible to send SMS via Skype.
I download some sample code but when I run it I got an error saying 'connection refused'.
I also then came across a blog stating that using Skype this way has potential errors like the SMS not getting through or taking days to get through.
I heard also that Skype are not that good with support in this area.
But, I cannot get past this error to find that all out.
If I send the sms directly using Skype's GUI/App then it comes through no problem.
So, is my code correct?
Should I use Skype for this at all?
Has anyone had a similar thing to do and has a better idea?
Thanks.
CODE:
private void button1_Click(object sender, EventArgs e)
{
var sendNumber = "+44-79-7059-0893";
var msgBody = "test message";
SendSMSMessage(sendNumber, msgBody);
}
void SendSMSMessage(string number, string body)
{
try
{
var skype = new SKYPE4COMLib.Skype();
skype.Timeout = 120 * 1000;
var smsType = SKYPE4COMLib.TSmsMessageType.smsMessageTypeOutgoing; //error occurs here
var message = skype.CreateSms(smsType, number);
message.Body = body;
message.Send();
}
catch (Exception ex)
{
}
}
Just in case anyone is following this I got this response from Sjype:
Andrew,
I am guessing your talking about the Desktop API (formally Public API) which was deprecated in December 2013? I would strongly encourage you not to build on this API as anything you build will have a limited shelf life.
Kind regards
Allen Smith
Program Manager
Skype Developer
Related
So I want to make a chat application in C# using the NuGet module "SimpleTCP", I made it work so the clients can send messages to the server and all clients get those messages but what I want now is to make it so I could pass a name string in the client.WriteLine("Message") when I send a message to the server telling a message was sent("client" is my "SimpleTcpClient" variable).
The problem is that the "WriteLine()" function get only ONE argument so it can't get a Message and Name variables.
I have tried searching google for a solution for that but found nothing.
I also tried just doing "client.WriteLine("This is a message", "Tal M")" but it didn't work.
This is some of the code that tells the client to send a message to the server:
private void SendMessageInput_Click(object sender, EventArgs e)
{
client.WriteLine(MessageInput.Text);
}
This is the lines that makes the server get the message and broadcast it to all other(including the client that send the message) clients:
private void Server_DataReceived(object sender, SimpleTCP.Message e)
{
txtStatus.Invoke((MethodInvoker)delegate ()
{
txtStatus.Text += e.MessageString;
server.Broadcast(String.Format(e.MessageString));
});
}
What I expect is to be able to get a message that includes Two arguments; First one for a message(String), and Second one for a name(String). I would really appreciate getting help, Thanks.
So I found a solution for my problem! All I had to do is just format the String that I send so it would include both Name and Message using client.WriteLine(String.Format("{0}: {1}", "Bob", "Hello World")).
This solution isn't great since I might need to change it to actually get the Name and Message as variables. If I would want to do that I would need to send a JSON object which can work really well but I don't want to do it now(This solution was suggested by #Sir Rufo, Thanks for the help.
I was working on creating a Bot, when i found the classes that help you build the cards.
I've also been working on an incoming webhook, but on that front, it seems it has to be done via JSON?
I've tried to put the packages into my other project, but I can't find a way to actually send the attachment.
Is it even possible, to use the card building classes in Microsoft.Bot.Connector assembly, or does other alternative tools exist, that i am not aware off?
My goal is to create cards in the chat, using the incoming webhook.
In my application, I have added the Microsoft.Bot.Connector library.
Right now, I have a script that generates a JSON string, from various parameters, to create a card. This is then sent to an "Incoming Webhook"
When doing with in my bot, I can create classes like theHeroCard, or ThumbnailCard, and use the .ToAttachment() to send it as a reply from the bot, which I feel is much more versatile, and user friendly.
I wish to be able to use the library that I use in the bots, to also create the cards for the incoming webhook (or a similar tool).
Sample Code: https://pastebin.com/9fHS5DWZ
namespace Namespace
{
public class Class()
{
public method()
{
List<CardImage> Images = new List<CardImage>();
Images.Add(new CardImage(url: "http://dev.example.com/cat.png"));
List<CardAction> Buttons = new List<CardAction>();
Buttons.Add(new CardAction()
{
Value = $"http://google.com",
Type = "openUrl",
Title = "Google"
});
ThumbnailCard Card = new ThumbnailCard()
{
Title = "Another Card!",
Subtitle = "Another test card",
Text = "This is just like a hero card, but smaller picture.",
Images = Images,
Buttons = Buttons
};
try
{
PostJsonAsync(MSTeamsCards.Config.WebHook, card.ConvertToJsonSomehow())
.ContinueWith(x =>
{
try
{
Console.Write(x.Result);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
});
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
#PeaceDealer, if I'm understanding you correctly, you know how to write a bot, and to create bot messages with cards. But you aren't doing that, you want to send the same type of cards over an incoming webhook?
The only format that's accepted over an incoming webhook is the Office 365 Connector card schema. You can find rich examples of that in the Message Card Playground site.
For the other card formats, you need to use a real Bot Framework bot or a Custom Bot.
I have a c# console application that I want to use for a game server
the client is being written is as3.
I am going to embed the swf into a c# form later.
I have a couple questions, I'm really hoping someone can help me figure this out.
Currently I have it set up to send a request to log in to the server, at which point the server checks information you put in the username and password fields
and verifies the information.
If you are authenticated you get connected.
My issue is I can't figure out how to send specific information back to flash, such as a string or int.
I want to do this for things like displaying user stats for example.
I looked at many tutorials but most are about using a flash application that is embedded in a c# server application, and does not operate the same way I need it to.
I just want to send a string or int from my c# server to my flash application that I have retrieved from mysql.
so if anyone can just show me how to send a string or int to flash as a raw value please let me know :)
If you can please post a snippet of code... I am still very new as3 c# communication.
also if you need the source please contact me on skype
Skype = Serifaz2
I don't want to just publicly post it ... sorry :(
Nevermind I figured it out. It was actually pretty simple.
C#
Socket socket = TcpClient.Client;
string UserTest = "" + Username;
try
{ // sends the text with timeout 10s
UserInfo.Send(socket, Encoding.UTF8.GetBytes(UserTest), 0, UserTest.Length, 1000000);
}
catch (Exception ex) { /* ... */ }
AS3
while(socket.bytesAvailable)
{
var str:String = this.socket.readUTFBytes(this.socket.bytesAvailable);
trace(str);
myTrace("you have something");
}
I am trying to use the Microsoft Bot Framework DirectLine API to read and add messages to existing conversations between other users and my bot. From what I've read I believe this should be possible when using the master-secret but it's just not working for me. I'm using a WebAPI to try and access two of my existing conversations (on Facebook & Skype) as follows:
[HttpPost]
[Route("remind")]
public string Remind()
{
var secret = System.Configuration.ConfigurationManager.AppSettings["secret"];
var uri = new Uri("https://directline.botframework.com/");
var creds = new DirectLineClientCredentials(secret);
DirectLineClient client = new DirectLineClient(uri, creds);
Conversations convs = new Conversations(client);
var conversationIDs = new string[] { "0000000000000000-0000000000000000", "00:0123456789abcdefghijklmnopqrstuvwxyz0123456789-A-_0123456798ABCDEF" }; // Existing Facebook & Skype conversations
// Send a message to each conversation:
foreach (var conversationID in conversationIDs)
{
Message message = new Message(conversationId: conversationID, fromProperty: "My Bot", text: "Hey dude, remember that thing!");
Console.WriteLine(message.Text);
convs.PostMessage(conversationID, message); // FAILS - This executes but doesn't do anything.
}
// Try reading the messages from a conversation (just to test if it's working):
string waterMark = null;
var set = convs.GetMessages(conversationIDs[0], waterMark); // FAILS - This fails with a 404 not found.
waterMark = set.Watermark;
return "Done :-)";
}
It fails silently calling PostMessage() and fails with a 404 for the GetMessages(). I seem to be doing the right thing, the bot is live etc and works very well in Facebook & Skype separately from the DirectLine API. It only works if I create a new conversation using the DirectLine API, I can then access its messages and post new messages to it.
This question sort of helps but doesn't quite tell me what to do to fix it:
Difficulty accessing messages in an existing conversation in Microsoft Bot Framework
Any help would be much appreciated.
Thanks
For security reasons, you can't use DirectLine to spy on messages from another conversation. For the scenario you describe (escalating to a human) there a number of different ways to approach this. One is to have your bot broker conversations between the accounts (i.e. Facebook End User <-> Your Bot <-> Facebook Support Person). Each is talking to the bot, and the bot passes the message through to the other user. (Could also be Facebook User <-> Your Bot <-> Skype User) Your bot would have to store last n messages to provide context. Alternatively, I've seen folks build their own customer support chat interface using direct line that sits on the far side. Hope this helps
I am developing a Windows8 Metro App using c# xaml and I have to send the app link as an e-mail to someone using the share contract.
What I have tried is
private void RegisterForShare()
{
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.ShareLinkHandler);
}
private void ShareLinkHandler(DataTransferManager sender, DataRequestedEventArgs e) {
DataRequest request = e.Request;
request.Data.Properties.Title = "Sharing My Link";
request.Data.Properties.Description = "Add a link (URI) to share";
var _Uri = new Uri("https://login.live.com/");
Windows.System.Launcher.LaunchUriAsync(_Uri);
}
And also,
void App_QuerySubmitted(Windows.ApplicationModel.DataTransfer.DataTransferManager sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs args)
{
App.SettingsFlyout.Equals(args.Request, ApplicationExecutionState.Running);
}
But it works in a way where the specified link just opens and not a feature where the email of the link could be sent to soemone.
Any suggestions or solutions please?
While you can use the share charm to let the user sent text if you want to the user to definitely send email (as opposed to Twitter / Facebook) then you should use the mailto protocol.
await Launcher.LaunchUri(new Uri("mailto://test#address.com?subject=email"));
There's no built-in API for sending emails. Microsoft recommend to use share charm to send the email. Though if you want to send email via you need to go for commercial library called Mail.dll
Try this
var mailto = new Uri("mailto:?to=recipient#example.com&subject=Your subject&body=Your text");
await Windows.System.Launcher.LaunchUriAsync(mailto);