I know using phonecalltask we can make a call programmetically by filling the phonenumber field .
A sample code may be
PhoneCallTask phn = new PhoneCallTask();
phn.PhoneNumber = "9807689,657";
phn.show ();
But my question is,is it possible to send dtmf right at the point when we are initiating calls ?
like in android and iphone we can send dtmf by dividing the number with ",". EX: 9876543,123
Is it also possible in windows phone? if possible is windows phone uses the same format to separate dtmf number or they use other tag other than "," ?
How to call programatically using p and w commands,and most predominantly the dtmf sound must send automatically after call
Just did the test. Your code works, and the DTMF are played right after the callee answers the phone.
p and w are supported as well, looks like the implementation is conform to the RFC 3601.
Related
I want to develop a Microsoft Teams Bot that when a user enters a keyword, such as 'pto' it will show an Adaptive Card form that the user can populate with information which will then get sent to a web service for processing.
Is it possible to display an Adaptive Card based on a user entering a text command?
Yes, absolutely possible. A "Command" is really just a regular message, and it's how you interpret / respond to the message. You can either detect these messages yourself by looking at the content, or you can use a conversational AI engine like LUIS.ai (part of Azure) which can more easily be configured to check for variants (e.g. "pto", "PTO", "POT", "[whatever 'pto' stands for']" etc. In this case, LUIS is basically building a ton of "if" statements to find a match, and the returning you an "intent" (e.g. "User is requesting whatever "PTO" means"). Because it's using AI to generate and maintain this "if" list, language conversational engines like LUIS are widely used in bots, but they're not -required-. It's why you see them in most samples though.
With regards sending an Adaptive Card, that's also pretty standard stuff in Teams bots, and they can be sent in response to a user's message, like you're trying here, as well as other ways to invoke them.
I actually cover both of these topics one after the other in a conference session earlier this year - see the video here: https://www.youtube.com/watch?v=mM7-fYdcJhw&t=1398s (the earlier parts might actually be of interest too).
Bot Framework can't handle the card prompts natively, so the best solution I've come up with is to
Display the card as a standard activity (i.e. before the prompt)
Provide a message indicating you are waiting for prompt input (e.g. waiting for selection...)
Validate that the prompt input is an object (e.g. input.match(/{.+/g))
Use the values from the object in your next step to call the webservice
So in code it ends up like this:
await step.context.sendActivity(CardHelper.datePicker());
return await step.prompt(DATE_PROMPT, `*waiting for selection...*`);
with a validator to make sure you are receiving an object like this:
async validateDateCard(prompt) {
prompt.activeDialog = await this.userDialogStateAccessor;
prompt.context = await prompt.context;
const input = prompt.recognized.value;
if (input.match(/{.+/g)) {
return true;
} else {
await prompt.context.sendActivity(`Please use the calendar widget above to enter the date.`);
return false;
}
}
In my case my widget just has a single field for date, but it works the same regardless of how many fields you have. They will all be in the submitted object. If you try to type something in manually, you are reprompted to use the widget. In general I find prompting for plain text values in sequence instead of using cards works fine and it not too cumbersome for users. But if you have a ton of inputs or need specialized controls like the above date widget, sometimes cards are the only way.
I have a Teams Message extension that returns a Task response which is a medium sized embedded web view iFrame
This is working successfully; including added a custom Tab within the channel and other nice magic calls to Microsoft Graph.
What I am confused about is how to do (and this is probably my not understanding the naming of things)
insert "something" Back into the Message/Post stream which is a link to newly created Tab ... like the what you get when you have a "configureTabs" style Tab created -- there is a friendly Message (Post) in the chat pointing to this new Tab.
do I do this with Microsoft Graph or back through the Bot?
the code that does the communication may be a different service elsewhere that is acting async ... so it needs to communicate with something somewhere with context. Confused if this is the Bot with some params or Microsoft Graph with params.
how to insert an image (rather than a link to the tab) into the Message/Post stream -- but showing the image not a link off to some random URL (ie: )
could not find any samples that do this; again, will be async as per above; but the format of the message will be a Card or something custom?
So just to be clear, a Task Response is NOT the same as a Tab, albeit that they might end up hosted in the same backend web application (and also albeit that your TAB can actual bring up your Task Response popup/iframe using the Teams javascript library).
Aside from that, in order to post something back to the channel, like when the Tab is created, there are two ways to do so:
First is to use Graph Api's Create ChatMessage option (this link is just for a channel though - not sure if your tab/task apply to group chats and/or 1-1 chats as well).
2nd Option is to have a Bot be part of your application as well. Then, when you're ready to send something to the channel, you'd effectively be sending something called a "pro-active messaging". You need to have certain reference data to do this, which you would get when the bot is installed into the channel ("conversation reference", "ServiceUrl", and so on). I describe this more in my answer at Programmatically sending a message to a bot in Microsoft Teams
With regards sending the image, either of the above would work here too, in terms of how to send the image. As to the sending of an image, you'd need to make use of one of the kinds of "Cards" (basically "richer" messages than just raw text). You can learn more about this at Introducing cards and about the types of cards for Teams at Card reference. There are a few that can be used to send an image, depending on perhaps what else you want the card to do. For instance, an Adaptive Card can send an image, some text, and an action button of some sort.
Hope that helps
To close the loop for future readers.
I used the following Microsoft Graph API docs, and the posting above, and this is working: Create chatMessage in a channel and Creating a Custom Microsoft Graph call from the SDK
The custom graph call (as it is not implemented in the .NET SDK at the time of this response) looks something like:
var convoReq = $"https://graph.microsoft.com/beta/teams/{groupId}/channels/{channelId}/messages";
var body = this.TeamsMessageFactory(newCreatedTabUrl, anotherstring).ToJson();
var postMessage = new HttpRequestMessage(HttpMethod.Post, convoReq)
{
Content = new StringContent(body, System.Text.Encoding.UTF8, "application/json")
};
await _graphClient.CurrentGraphClient.AuthenticationProvider.AuthenticateRequestAsync(postMessage);
var response = await _graphClient.CurrentGraphClient.HttpProvider.SendAsync(postMessage);
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
return true;
}
The groupId and channelId are found elsewhere; and the TeamsMessageFactory is just some boilerplate that serialized the C# object graph for the POST request, as detailed in Create chatMessage in a channel
I'd like to simulate 'real' keystrokes in an inactive window. After some research I found the Windows api. Since Im used to Java, I quickly found JNA, which implements the winapi.
I wrote some code, that could simulate keystrokes in a active window with the sendInput() method. The window did not detect virtual keycodes. After some search, windows with directinput need scancodes apparently. And it worked with the following code:
import com.sun.jna.platform.win32.BaseTSD;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinUser;
int KEYEVENT_SCANCODE = 0x0008;
int KEYEVENT_UP = 0x0002;
WinUser.INPUT input = new WinUser.INPUT();
input.type = new WinDef.DWORD(WinUser.INPUT.INPUT_KEYBOARD);
input.input.setType("ki");
input.input.ki.wVk = new WinDef.WORD(0);// 0 cause scancodes are used
input.input.ki.time = new WinDef.DWORD(0);
input.input.ki.dwExtraInfo = new BaseTSD.ULONG_PTR(0);
input.input.ki.wScan = new WinDef.WORD(0x2C); // scancode for 'y'
input.input.ki.dwFlags = new WinDef.DWORD(KEYEVENT_SCANCODE); // keydown
User32.INSTANCE.SendInput(new WinDef.DWORD(1), (WinUser.INPUT[]) input.toArray(1), input.size());
input.input.ki.wScan = new WinDef.WORD(0x2C);
input.input.ki.dwFlags = new WinDef.DWORD(KEYEVENT_SCANCODE | KEYEVENT_UP); // keyup
User32.INSTANCE.SendInput(new WinDef.DWORD(1), (WinUser.INPUT[]) input.toArray(1), input.size());
Now I wanted it to be 'smooth', so that the window could be in the background or minimized. I found the SendMessage() and PostMessage() methods and thought I understood its concepts.
You pass the handler of a window, the message(wm_keydown and wm_keyup seems good for the task) and and its specific params.
I tried this, but it did not work. (same for postMessage).
User32.INSTANCE.SendMessage(handler, WinUser.WM_KEYDOWN, new WinDef.WPARAM(0x5A), new WinDef.LPARAM(0x002C0001));
Thread.sleep(100); //tried with and without
User32.INSTANCE.SendMessage(handler, WinUser.WM_KEYUP, new WinDef.WPARAM(0x5A), new WinDef.LPARAM(0xC02C0001));
Then I tried WM_CHAR and it worked partially. It worked in the chat of the window, but did not trigger hotkeys.
After some research, people say, you have to use directinput hooks(?), since some windows won't recognize messages from the winapi, but mine did apparently from sendInput and sendMessage with WM_CHAR.
Have I passed wrong params? What does it mean, that wm_char is regocnized, but wm_keydown and wm_keyup is not?
I already found lots of examples, stuff on stakeoverflow and the web, but it did not really help.
Thanks for reading and answering.
#update I used a tool for detecting messages. The Messages created by real keystrokes and the ones created from the code are equal:
In both cases there is a WM_keydown, then WM_char and WM_keyup.
Every param of every message is equal. In addition to that, like I said, if the chat is opened, there are characters written, but actions won't perform, when the chat is closed.
I checked, what messages are send with the sendInput() method: they are equal to the both cases above, but action is performed.
I'm not able to inprete this behavior.
I need to implement uvc1.5 spec in my device, I choose linux3.4 as my kernel, and I want to use the drivers/usb/gadget/webcam.c
as my function driver. But it doesn't function properly.
According to the signals captured by wireshark, when the host sends the GET_DEF request to the device, my device answer -ENOENT which results in a failure to the enumeration.
I find out that when the composite.c receives this kind of requests, it will forward them to f->set_up to continue.
The main part of f->set_up is:
uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN);
uvc->event_length = le16_to_cpu(ctrl->wLength);
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_SETUP;
memcpy(&uvc_event->req, ctrl, sizeof(uvc_event->req));
v4l2_event_queue(&uvc->vdev, &v4l2_event);
The call of v4l2_event_queue is what puzzles me: who will handle this event?
I didn't see any code doing such event related initialization work.....
And my question is how to handle this event properly, so I can answer the GET_DEF request ?
It's a V4L2 event you should deal with in another place. You can receive v4l2 event through
rt = ioctl(dev->fd, VIDIOC_DQEVENT,&v4l2_event);
Then you can parse this v4l2_event, it maybe GET_CUR, GER_LEN,etc. So you can response those requests by yourself define.
I'm working on a YRS 2013 project and would like to use Twilio. I already have a Twilio account set up with over $100 worth of funds on it. I am working on a project which uses an external API and finds events near a location and date. The project is written in Ruby using Sinatra (which is going to be deployed to Heroku).
I am wondering whether you guys could guide me on how to approach this scenario: a user texts to the number of my Twilio account (the message would contain the location and date data), we process the body of that sms, and send back the results to the number that asked for them. I'm not sure where to start; for example if Twilio would handle some of that task or I would just use Twilio's API and do checking for smss and returning the results. I thinking about not using a database.
Could you guide me on how to approach this task?
I need to present the project on Friday; so I'm on a tight deadline! Thanks for our help.
They have some great documentation on how to do most of this.
When you receive a text you should parse it into the format you need
Put it into your existing project and when it returns the event or events in the area you need to check how long the string is due to a constraint that twilio has of restricting messages to 160 characters or less.
Ensure that you split the message elegantly and not in the middle of an event. If you were returned "Boston Celtics Game", "The Nut Cracker Play". you want to make sure that if both events cannot be put in one message that the first message says "Boston Celtics Game, Another text coming in 1 second" Or something similar.
In order to receive a text message from a mobile device, you'll have to expose an endpoint that is reachable by Twilio. Here is an example
class ReceiveTextController < ActionController
def index
# let's pretend that we've mapped this action to
# http://localhost:3000/sms in the routes.rb file
message_body = params["Body"]
from_number = params["From"]
SMSLogger.log_text_message from_number, message_body
end
end
In this example, the index action receives a POST from Twilio. It grabs the message body, and the phone number of the sender and logs it. Retrieving the information from the Twilio POST is as simple as looking at the params hash
{
"AccountSid"=>"asdf876a87f87a6sdf876876asd8f76a8sdf595asdD",
"Body"=> body,
"ToZip"=>"94949",
"FromState"=>"MI",
"ToCity"=>"NOVATO",
"SmsSid"=>"asd8676585a78sd5f548a64sd4f64a467sg4g858",
"ToState"=>"CA",
"To"=>"5555992673",
"ToCountry"=>"US",
"FromCountry"=>"US",
"SmsMessageSid"=>"hjk87h9j8k79hj8k7h97j7k9hj8k7",
"ApiVersion"=>"2008-08-01",
"FromCity"=>"GRAND RAPIDS",
"SmsStatus"=>"received",
"From"=>"5555992673",
"FromZip"=>"49507"
}
Source