Glympse API - Handle Send Ticket Operation - glympse

I want to allow the application to call some method when the User Actually sends the Glympse Ticket
In simple terms I just want to get that is there any method to know whether the user has sent the Glympse after opening the Wizard or he/she has cancelled the wizard.
I have to do some operations when the user selects send Glympse Button
Looking forward for your valuable reply.
Thanks

The easiest way to call a method when the user has sent a Glympse is to register an event listener with the Glympse platform.
Here is an excerpt from the Glympse Send Lite demo showing how to do this:
// Start up the Glympse API
GlympseLiteWrapper.instance().start(this);
// Register this class as a listener for Glympse events
GlympseLiteWrapper.instance().getGlympse().addListener(this);
The parameter passed to addListener must be a class that implements GListenerLite. As a class using this interface, you will need to have an eventsOccured method.
#Override public void eventsOccurred(GGlympseLite glympse, int event, Object param1, Object param2)
{
if (0 != (event & LC.EVENT_TICKET_CREATED))
{
Log.d("", "Ticket created");
onTicketCreated((GTicketLite) param1);
}
}
The LC.EVENT_TICKET_CREATED event sounds like what you are interested in capturing. You can create a method such as onTicketCreated() to do things in response to a ticket being created.

Related

Laravel best practice sending e-mail through API using templates

As you know many e-mail providers have the feature to use e-mail templates. Through their API you can send e-mails, just by setting the template id and passing through the variables. The predefined template will be send to the user.
For my project I want to use Mailjet API for transactional e-mails. What is the best way to call their email API in my project. Because laravel already has lots of email and notification features so I am looking for the best practice to integrate this in my project.
For example I want so make use of notifications. This notification has to call the mailjet email api and pass through the template id and the needed variables. What is the best way to archive this. With a custom notification channel maybe?
Or are there other good alternatives?
You are right, you can use an alternative mailing service while using Laravel's neat notifications feature. You will need to create a custom notification channel where you can define sending logic by hitting Mailjet's API endpoints. When the notification channel is all set up, you can specify it inside a notification itself where you can define the exact request body.
To make things easier, you may use Mailjet's official PHP wrapper so you don't have to work with raw HTTP requests.
Personally I used the same technique for Twilio SMS and Nexmo (Vonage) SMS Verification codes. I will add some of my code so you can see how I organised things:
class PhoneChannel
{
public function send($notifiable, Notification $notification)
{
if ($notification->resend) {
$this->repeatCall();
} else {
$this->initCall();
}
}
...
class VerifyPhone extends Notification
{
use Queueable;
public bool $resend;
public function __construct(bool $resend)
{
$this->resend = $resend;
}
public function via($notifiable): array
{
return [PhoneChannel::class];
}
}
The point is that you can define a request body inside the notification itself in order to access it later in the notification channel. Just add a method called toMailjet inside a notification, specify your variables, and then access it inside a channel via $notification->toMailjet()

app_mention not firing in private message

I have a bot with event scopes app_mention and messages.im. It also has OAuth scopes app_mentions.read, channels.history, chat.write, groups.history, and im.history.
If I # mention my bot in a public channel, a thread off of a public channel, or directly message my bot I get an event. But if I'm in a private message with someone else and # mention my bot, I don't get any events from the #mention.
What is the correct event scope to enable to get the event?
you can't unfortuantly. app_mention only works in conversations the bot would have access to. You would need each user to directly give you access to im history and monitor every message event for a mention of the bot itself (probably either some regex or similar to look for the <#bot_name>.
I know there was a link_names part of the json object being sent for message events but you'd still need to check the message body to make sure its your bot being mentioned and not another user

How to enable bot to find Skype group chat it was added to previously?

I am creating a bot with Microsoft Bot Framework that is supposed to, when receives notification from CI server, notify about build events participants of a particular chat group in Skype.
I don't quite get it, when I've added Skype bot to the chat, it has received an activity that presumably would have allowed me to save some Id at that stage. But since I need the bot to be proactive and post messages based on external stimuli, I would need to know the reference to that group chat permanently, including after re-deployment. But after redeployments, I don't have a conversation reference.
In theory, what bit of data, given that I save it during add time, would enable me to proactively send messages at any given point in time?
If it is ok that all participants "join" the conversation by writing first to the bot and if your bot accepts messages in similar Post method
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
string rawActivity = JsonConvert.SerializeObject(activity);
Save(rawActivity);
}
Then you are able to send messages to that conversation from your bot any time by using following code. You can restart or even redeploy your bot in the meantime. I have tested about one week as maximum time between consecutive messages.
public void MethodInvokedByExternalEvent(string externalMessage)
{
var activity = JsonConvert.DeserializeObject<Activity>(GetStoredActivity());
var replyActivity = activity.CreateReply(externalMessage);
ResourceResponse reply = null;
using (var client = new ConnectorClient(new Uri(activity.ServiceUrl)))
{
reply = client.Conversations.ReplyToActivity(replyActivity);
}
}

How to dynamically create a new a Topic using Events Push plugin

To create a topic for an event I need to declare this in my conf/MyEvents.groovy file as follows:
events = {
"topicName" browser: true
}
I am wanting to use the server push for two things, pushing chat messages to a client and also for pushing notifications to a client.
Using the former as an example, I will need to create a new Topic for each conversation that is instantiated in the chat system at runtime, so that messages can be pushed to each of the conversation participants, so along the lines of
new Event(topic:'anotherTopicName',...)
which will allow me to call from a service :
import grails.events.*
class MyService {
def doSomething(){
...
event(topic:'anotherNewTopic', data:data)
}
}
Is there a method that will allow me to create a new Event topic? Or is there another way to implement this using Events Push
I've just done something similar. I needed to show some notifications based on the user that had logged in, so I set this in MyEvents.groovy:
events = {
'newNotification_*' browser:true
}
And when I need to send the notification:
event topic:"newNotification_${userId}",data:n
Then in my browser I can listen to those notifications with something similar to this:
grailsEvents.on("newNotification_"+myUser,function(data){

How do I determine the mailbox that contains a given item or folder with EWS?

I have a program that subscribes to multiple Exchange 2010 mailboxes using EWS Managed API's streaming notifications.
When I get a notification related to an item, I need to determine whose mailbox that item belongs to. I'm able to get the item's ID and the parent folder's ID, etc., but I don't see any way to determine what mailbox the item belongs to.
Ok, so if I understand your application correctly you are using Impersonation and create subscriptions for all impersonated users. And when you receive event from subscription you want to know for which user this event occurred. If that is the case can't you just keep your subscriptions mapped to user that subscription was created for?
Simple Dictionary<StreamingSubscription, ImpersonateduserId> would be enough
And when you get notification you get subscription object from NotificationEventArgs.Subscription property and find user id that subscription was created for in you map. From ImpersonatedUserId you can get smtp address (property Id) and you know which exatcly user that was.
private void OnNotificationEvent(object sender, NotificationEventArgs args)
{
string fromEmailAddress = args.Subscription.Service.ImpersonatedUserId.Id;
}
That's how you get the Mailbox's Email Address that the item belongs to.

Resources