Send WhatsApp messages automatically with Automate-App - whatsapp

I want to send a WhatsApp message to a specific contact with the Automate-app. How can do I do this?
This is the link to the app:
https://play.google.com/store/apps/details?id=com.llamalab.automate

I know this is pretty late reply.
You can make use of below blocks and build
App start block and choose activity class as
com.whatsapp.ContactPicker
Use Interact blocks for searching, selecting and messaging
Extend with Variable for searching contact and for message text

I have been trying different ways but many of them fall short of full automation.
currently, I am using blocks to send a message to (unsaved) contact. This skips the contactPicker window.
the flow blocks:
[start flow] --> [view content] --> [interact]
that's it!
in view content, you will need to specify the content uri (change number and msg):
https://api.whatsapp.com/send?phone=+966xxxxxxxxx&text=msg
in interact block, specify the (proceed) when element appeared.
the (action) is click.
and (XPATH):
fn:reverse((.//[{("android.widget.ImageButton") = null ? "true()" : "fn:choose(#class,string(#class),name())={"android.widget.ImageButton";xpathEncode}"} and {("com.whatsapp:id/send") = null ? "true()" : "#android:id={"#" ++ ("com.whatsapp:id/send");xpathEncode}"}])[1]/ancestor-or-self::)
that's it.

Related

Confirm purchase order from automated action in Odoo

I created an automated action in Odoo that is triggered when a purchase order is updated from state = draft to state = sent. This automated action simply calls a server action that runs the following code:
record.button_confirm()
The idea is I am trying to confirm the purchase order automatically after the RFQ is sent to the vendor.
After sending the RFQ the PO is confirmed as expected. However, the vendor on the PO also receives a notification from the system related to the picking that was created. It will say something like:
"This transfer has been created from: PO00007"
If I disable my automated action and instead confirm the PO manually by clicking the "Confirm Order" button on the PO form, the order is approved, a picking is created, and this notification is not sent.
I would like my automatic approval to mimic the manual approval. Meaning, I do not want this notification to be sent.
After searching the source code, I was able to accomplish what I wanted by passing in a context key like this in the server action:
record.with_context(message_create_from_mail_mail=True).button_confirm()
I came across this solution here in the source code:
https://github.com/odoo/odoo/blob/df60828488a702acb64757f518b4be12b7a95a04/addons/mail/models/mail_message.py#L729
However, I don't understand why this is necessary or if it's even the correct way to solve this problem. I honestly don't even know what it means. I just know it works. I don't see the manual "button_confirm" method passing in this context key anywhere.
Can anyone offer any guidance here as to why this notification email is sent when I simply run button_confirm() from a server action rather than triggering it manually with a button from the UI? Also, is my solution correct or does it have some sort of side effect I am not aware of?

RavenDB Push Notifications: Actual document not included?

I've successfully implemented push notifications with RavenDB (see code below). I was expecting the actual document to be included with the change notification. That way, all the UI clients can display the information. However, it seems that only the Id and Etag properties are available for the changed document.
What am I supposed to do if I want the client to be able to display information about the document? Does the client now need to make a DB call to get the document based on the ID? It seems inefficient to have to make a DB call to get the information. But, is that what is supposed to happen?
documentStore.Changes()
.ForDocumentsStartingWith("LogMessages")
.Subscribe(change =>
{
if (change.Type == DocumentChangeTypes.Put)
{
// Fire event so consumers can display document info
// Uh oh, are change.Id and change.Etag all we have here?
DatabaseItemAdded(null, new EventArgs<string>(change.Id));
}
});
Yes, you need to call the db to get the new document.
The reason for that is that it would be expensive to send the document (which may be very big) if all you need is just the notification on the change).

Kaltura - Force player to stop with API only?

Is there any way to force a Kaltura videoplayer to stop ONLY using code and the Kaltura API?
Currently I have solved it by adding a Access Control Profile named "Free preview" under Settings > Access Control in KMC and then added this profile to the Entries I've choosen.
I then add the session to the players flashvars to restrict non-members to only watch the preview, not the whole clip.
But I would like to restrict ALL, or even better selected Categories of clips by using only code, so I don't need to involve KMC.
Is that possible?
Alt) Can you create a new player in KMC and restrict it to viewing only X seconds, no matter what length of Entry? Then I can do the check if user is valid or not and get the category via API and show it in the "preview-player" och the "default player".
If I use the mediaProxy.mediaPlayTo attribute the clip stops, but is easily started again by presing play.
Would greatly appreciate an answer
I got this answer from a guy named oferc in a different forum:
You can listen to the head move event and pause the clip it goes beyond a certain time (then if someone pressed play, you can stop it again)
function jsCallbackReady(player_id) {
my_kdp = $("#"+player_id).get(0); // document.getElementById(player_id) if you do not use jquery/ prefer pure js
my_kdp.addJsListener("kdpReady", "kdpReady"); // when you load the player with an entry (and the player is ready to begin playing it using doPlay for instance)
}
function kdpReady() {
my_kdp.addJsListener("playerUpdatePlayhead","headMove");
}
function headMove(position) {
if (position > "30") { // Your Time, example 30 seconds
my_kdp.sendNotification('doStop')
}
}
Works like a charm!
fredrik_w - neither of the ways you chosen here are a good option to restrict access.
in both cases, your videos are made public, and can be easily accessible by anyone.
The best way to limit access to a video is by defining an Access Control, and like everything in Kaltura, you can define an ACL using API as well.
Check this out as a reference sample-
http://blog.kaltura.org/turning-profit-online-video-made-easy-using-paypal-html5-digital-goods

CAsyncSocketEx + console application ?

I have console applicaiotn that currently uses CAsyncSocket.
I need to implement SSL so after some searching I found this project: http://www.codeproject.com/Articles/3915/CAsyncSslSocketLayer-SSL-layer-class-for-CAsyncSoc
For some reason same simple code that works fine on GUI code does not work in console app.
Has anyone exp. with CAsyncSslSocketLayer ?
Thanks.
CAsyncSocketEx uses a window as a sort of cheap thread to handle the event notifications that come from select(). Unfortunately, if you don't have a message loop, then the window which it creates will not receive these events.
http://support.microsoft.com/kb/90975
This article explains that a call to CreateWindow() needs to be called from a thread which has a message loop. And if you don't, then anything sent via PostMessage() won't get there.
I've recently started to tinker with this -- I want to remove the annoying hidden window and replace it with a normal thread. Their code relies on WSAAsyncSelect() in order to receive socket events... to a window. Yuk!
It's been a while since I had the same problem, but if I remember correctly, to use CAsyncSocket in a console app you need to add something like DECLARE_CONSOLEAPP (first two links shown below) to your console app. This should give your console a message pump to generate the socket notifications (OnReceive, etc.) GUI apps have these pumps but console apps don't, generally. The third (msdn) link below might also apply, it has more info and a different way.
If these still don't work, you should put breakpoints in your socket code and make sure your socket isn't instantiated in a thread or callback other than the main console app (the one that now has the message pump).
I think googling around for 'CAsyncSocket WinApp' or 'CAsyncSocket console app' would show more.
http://www.codeguru.com/cpp/misc/misc/consoleapps/article.php/c243/Console-app-using-MFC.htm
http://troels.knakkergaard.dk/code.htm
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/a6f1b72a-21d8-4046-a3dc-d7d29ece2ef6

Does anyone know of a Cocoa/Obj-C library that can be used to gather application usage data

I would like to be able to gather info like how often certain windows are opened, what types of user data are accessed, how often menu items are clicked, etc. Does anyone know of a 3rd party (open source or commercial) Cocoa/Obj-C library or plugin that would allow me to gather this info?
I have used pinch media in the past, and they merged with Flurry. Library was simple to use and was setup in around 40 minutes.
I don't know any library for that but at least to get informed about when the user switches the front application you can install an event handler like this:
EventTypeSpec eventType;
eventType.eventClass = kEventClassApplication;
eventType.eventKind = kEventAppFrontSwitched;
EventHandlerUPP handlerUPP = NewEventHandlerUPP(FrontAppSwitchedDetector_callback);
OSStatus status=InstallApplicationEventHandler(handlerUPP,1,&eventType,self,&_eventHandlerRef);
... and when receiving an callback you may get the current front application process:
pascal OSStatus FrontAppSwitchedDetector_callback(EventHandlerCallRef nextHandler,EventRef theEvent,void* userData)
{
ProcessSerialNumber newSerial;
GetFrontProcess(&newSerial);
//to something with that ....
return (CallNextEventHandler(nextHandler, theEvent));
}