I want to deliver voice message using Twilio. I also use text to voice twimlets as well. Here is the code
TwilioClient.Init(accountSid, authToken);
string responseurl = "http://twimlets.com/echo?Twiml=%3CResponse%3E%0A%3CSay%3EDear%20John%20Smith%3C%2FSay%3E%0A%3CSay%3E%0AThis%20is%20a%20test%20for%20happy%20programing%20IVR.%20Why%20this%20is%20so%20hard%3F%3F%0A%3C%2FSay%3E%0A%3CPlay%3E%0Ahttp%3A%2F%2Fwww.pacdv.com%2Fsounds%2Fpeople_sound_effects%2Fapplause-4.mp3%0A%3C%2FPlay%3E%0A%3CSay%3EGood%20Bye%3C%2FSay%3E%0A%3C%2FResponse%3E&";
var call = CallResource.Create(to,from,url: new Uri(responseurl));
<Response>
<Say>Dear John Smith</Say>
<Say>
This is a test for happy programing IVR. Why this is so hard??
</Say>
<Play>
http://www.pacdv.com/sounds/people_sound_effects/applause-4.mp3
</Play>
<Say>Good Bye</Say>
</Response>
Here is the problem, When I pick up the call, I will hear all voicemail played. When it goes to the voicemail, It will cut the first 7 seconds recording off.
Anyone knows how to solve this problem?
Thanks
Twilio developer evangelist here.
The issue is that when your voicemail answers the phone it starts by reading its own message. At the same time, Twilio is reading the message out too, so when the voicemail starts recording the message is halfway through.
There are two ways you can get around this. Either you build a loop into your message to ensure that it all gets recorded. Or you can use Twilio's Answer Machine Detection to only start the message when it is sure that a human or machine has answered.
To use the AMD you need to pass another parameter when you create the call:
var call = CallResource.Create(
to, from,
url: new Uri(responseurl)
machineDetection: "DetectMessageEnd"
);
machineDetection can be either "Enable" or "DetectMessageEnd". "Enable" will call your webhook URL as soon as Twilio knows if it is human or machine, "DetectMessageEnd" will wait if it is a machine until the voicemail's message has ended, allowing you to play your message and have it fully recorded.
When Twilio requests your webhook URL, it will have an extra parameter too, AnsweredBy. You can use this to decide what course to take depending on whether a human or machine answered.
Let me know if this helps at all.
Related
So I have a pretty extensive discord.net bot. The bot portion is really just going to be a place for the messages to be posted, but ultimately it queries multiple public APIs, deserializes the JSON response, then I do various tasks with the outcome data.
All of this is working just fine, and in fact, it posts to the correct channel, and I am able to swap in parameters for the data returned, etc. The intention of the bot is just to post information as it's updated from a composite of 4 sites that have public, queryable APIs. But this question is just for the wandering mind.
I basically mirrored this code for a simple test:
private static Task ClientOnMessageReceived(SocketMessage arg)
{
if (arg.Content.StartsWith("!helloworld"))
{
arg.Channel.SendMessageAsync("Message Response");
}
Now, the question is, if I send that same !helloworld in a channel, that the bot has access to, it does not respond to it. If I # my bot, it does not respond to it. It will only respond or even indicate that it's listening for DMs. Why? Does the SocketMessage object only work for DMs? If so, how would I listen to the text channels on a particular server and respond whenever any person says '!helloworld', the use for this is not one that I need for the bot. I just want to understand what I am missing. Ideally, I would want to see if someone says a funky phrase, so I can toss out a funkier response just for fun, however even in just my testing I can't figure it out.
So any help would be greatly appreciated, I thought I had a decent grasp on this library, but I am just not connecting the dots on this.
I logged into the discord developers here and then I added the privileged gateway intents > enabled this and the message content intent. I then add the following to my code before I initialized my discord socket:
public static DiscordSocketConfig config = new DiscordSocketConfig() {
GatewayIntents = GatewayIntents.All };
private readonly DiscordSocketClient _client = new DiscordSocketClient(config);
Since this bot is quite literally for myself and my friends, I do not need to worry about the 100 server threshold, unless folks start asking how I get all those cool deal histories and active deals posted in my server! Thanks!
I started to write my own bot for a discord server using Discord.net. I already made the first command (which still doesn't work correctly, but that's for another story), and now that I am testing, it has a chat full of commands I sent. My goal is to instantly delete those messages as I send them (let's say I send .command something, and this should appear in a chat just for a little moment). I tried to look it up in documentation and some tutorials but couldn't find anything. I have only basic knowledge of programming, so I would be happy if you could tell me how to achieve this and explain how it works.
To answer the question of how to delete a message, you use the Context.Channel.DeleteMessageAsync function. It takes a message id as the parameter, so you will need to have the message data in memory at the time.
To answer the question of how to delete a message that you have just sent, you can use the above delete function alongside the Context.Message data which gives you the message data of the message that triggered the command. It will look like the following:
[Command("TestDelete")]
public async TestDeleteCommand()
{
await Context.Channel.DeleteMessageAsync(Context.Message.Id);
}
You can find more information of the DeleteMessageAsync function by looking at the Discord.Net docs
I am sending SMS through Twilio trial account using ASP.NET C#. I registered the numbers in my twilio account as I'm using trial account. Not getting any error but SMS is also not getting sent.But while checking SMS log in account it's showing Sent/Delivered. Any leads?
Please find my code snippet:
public void smsTwilio()
{
const string accountSid = "accountSid";
const string authToken = "authToken";
TwilioClient.Init(accountSid, authToken);
var to = new PhoneNumber("+91XXXXXXXXXX");
var message = MessageResource.Create(
to,
from: new PhoneNumber("+1XXXXXXXXXX"),
body: "This is the ship that made the Kessel Run in fourteen parsecs?");
Console.WriteLine(message.Sid);
}
Twilio developer evangelist here.
With a Twilio Trial account, you should be able to text any numbers anywhere supported by Twilio. However, it's worth making sure you have the correct geo permissions enabled. You can do that by heading to this page and checking the "India" checkbox.
Next up, there are a few limitations when sending SMS messages to Indian mobile devices, which you can read more here. These are limitations established by carriers in the country as opposed to Twilio. The important ones that are likely to be affecting you now are:
They cannot be sent to any phone number in India’s Do Not Call Registry
They are only delivered between the hours of 9 A.M. and 9 P.M. local Indian time
No more than one message every 20 minutes from the same Sender ID to the same destination number with the same message body.
Lastly, from within a phone number, you can click on "Messages Log" and see what's going on with the messages you're trying to send if they've been delivered correctly.
Hope this helps you.
It seems you are trying to send a sms internationally, from a US(+1) number to an India number(+91) . this is blocked by default on trial twilio numbers.
You can try an initiate your twilio trial with an Indian number
I encountered a problem that took me too much time, but without resolving it.soI really want you to help me.
I have an application built with c # wpf, and communicates with ovens via serial port.
the frame I need to send have following form: [EOT] (GID) (UID) (Temp) [ENQ]
gid uid: group identifier and unit identifier (address of the machine).
(eof),(enq) :frames the message.
(temp) means: give me the temperature value.
the only machine that has the same address can answer (master slave architecture).
the form of the response message is: [STX] (Temp) <DATA> [ETX].
the field contain only the temperature value
stx start text. etx end text.
I have no problem with sending and receiving of data, and I can display the value of temperature for a single machine connected.
but when I connect More machines, I do not know which machine has answered the frame that I sent, because the response frame does not have any adress so that I can determine which oven have respond.
So the situation in brief is:
-I send Data to ovens.
- I received data.
- I can not decide which oven answered.
please any one have an idea.
PS: I work with the protocol:EI-BISYNCH of eurotherm EuroTherm
If needed: EI-Bisynch ASCII Sequence Diagrams
In these conditions, the typical solution is:
Send the request to the current device
Wait for an answer for a defined timeout
If we receive an an answer within the timeout, the device responded.
If we do not receive an answer, the device is offline, mark it as such.
Switch to the next device, goto 1
Basically you should be able to wrap into a loop the code described here:
Providing Asynchronous Serial Port Communication
That is a sample that works with an AutoResetEvent. One of the .Net multithreading that allows synchronizing threads (the threads that sends the request in the loop, and the threads that receive the message in the loop)
IN these situations, the machine that you addressed is responding (or at least its assumed to be) Single Master - Multi Slaves. Meaning :-
Master -> Hey #1 tell me your temp -> #1 SIR! YES SIR! 23 degrees!
Master -> Hey #2...
The idea is no other slave will respond. By convention of the protocol.
Its pretty hard to do anything but this kind of system on serial.
In terms of Design if you create something like a command queue. Each command knows what device it wants to talk to, and what question it wants to ask. You process each command, send the serial message, get the response, and give it back to the command. Now you have a command, which knows which device it talked to, and what the response of that device was.
As long as you only have one "in-flight" command to which you are waiting for a response, and you know which device you sent the command to, you can assume that the device that responds next is the device you asked to respond. Now this won't necessarily always be true if it is possible for your device to send un-prompted responses.
i have a program that send ASCII commands to a device via a serial port. The program is a demo and doesn't do what i want.
I am just trying to get the device to respond in c# and I'm not getting anything back.
all the serial port settings are correct.
I am sending exactly the same message as the demo software.
//e.g message <STX>ABC<EOT>
byte[] msg = new byte[5];
msg[0] = 0x02;
msg[1] = 0x41;
msg[2] = 0x42;
msg[3] = 0x43;
msg[4] = 0x04;
comport.write(msg, 0,msg.length)
the device is a monitor. The code was only an example. there isn't a heartbeat just a response for a correct message sent or a error message. the settings are standard 9600-8-N-1. "paperclip between pins 2 and 3 (TX and RX)." yeah i know the cable works because its the same one used with the product software that works. and im getting back what i send. I have used a virtual com program and everything seems alright. "6 bytes but initializing only the first 5. " sorry typo.
the SerialPort.DtrEnable and RtsEnable properties to true. are on by default in c#. i have tried the hyper terminal and am not getting a response with that either. I have sent \r and \n with no luck.
This C# Tutorial on Serial Port Communication should be able to help. I'm not sure if there is an appropriatei intrinsic caste between Hex and Byte through assignment in C#. That may be the source of your problem.
Device Heartbeat
Does the device send a DC2 or DLE response (heartbeat)? If so, try opening a COM port in Hyperterminal using basic 9600-8-N-1 settings and see if you get anything. Is there any STX, SYN, ETX commands sent back when you try to send a command? I'm not sure on the command-set implementation for the hardware you are trying to communicate with.
Checking COM Port Operation
Have you checked if your COM port is working properly? You can create a loopback by inserting a paperclip between pins 2 and 3 (TX and RX). This will loopback your COM port and in Hyper terminal you can open that COM port and type. The characters will echo back.
You can also use a piece of software called com0com to create virtual COM ports to test what you are sending before you actually send it.
It provides pairs of virtual COM ports that are linked via a nullmodem connetion. You can then use your favorite terminal application or whatever you like to send data to one COM port and recieve from the other one
Without anymore specific information, we'll be grasping at straws.
You're allocating and sending 6 bytes but initializing only the first 5.
Also, according to what you write, you're doing everything correctly, exactly as the demo program. Right? Then I can see only one solution: The device is pulling your leg!
Seriously: If one program works and your doesn't, there MUST be some difference.
By far the most common mistake is forgetting to turn on the hardware handshake signals. The device won't send anything if it thinks the host is turned off. Make sure you set the SerialPort.DtrEnable and RtsEnable properties to true.
As mentioned before, fix the array size. Although it probably won't help, the STX character ensures that junk is thrown away.
Check if basic hardware is okay with the Windows Hyperterminal applet. You can send the message you are trying to transmit by typing Ctrl+B, ABC, Ctrl+D
As others have suggested, it is good idea to check what is being sent and received with some kind of terminal software. I have had success with "realterm"-- it has nice displays of ascii or binary/hex views.
Since you are working with ASCII, another issue might be that you are not sending the correct line-terminating character. Some devices expect \r and others \n. Make sure you are setting that correctly.
the device is a monitor. The code was only an example.
there isn't a heartbeat just a response for a correct message sent or a error message.
the settings are standard 9600-8-N-1.
"paperclip between pins 2 and 3 (TX and RX)." yeah i know the cable works because its the same one used with the product software that works. and im getting back what i send. I have used a virtual com program and everything seems alright.
"6 bytes but initializing only the first 5. " sorry typo.
the SerialPort.DtrEnable and RtsEnable properties to true. are on by default in c#.
i have tried the hyper terminal and am not getting a response with that either.
I have sent \r and \n with no luck.