I am working on a system that allows the user to log their email conversation to our CRM.
This uses MS Graph subscriptions that create a subscription to a given email conversation. We then process the Graph notifications. When creating the subscriptions we set the resource like this:
/users/{id}/mailFolders('inbox')/messages
/users/{id}/mailFolders('sentItems')/messages
This gives us notifications for when the user sends or receives an email on that conversation thread.
This works great, but we discovered that if the user has a rule set up to send items with a certain subject to a different folder, when receiving a new email that they have subscribed to, we don't receive a notification.
I am guessing that this is due to us subscribing to the inbox and sentitems but not the custom folder that they have their rule directed to.
I noticed that there is also a way to set the resource as:
/users/{id}/messages
Can someone tell me whether this will set up the subscription to receive emails from all folders?
If this is the case, we wouldn't want to receive notification for example when the user deletes and email.
Additionally, we currently create 2 separate subscriptions. Is there a way to create a subscription for more than 1 resource (e.g.inbox and sentitems) under the same subscription?
thanks
The resource path users/{id}/messages is just a shortcut to the one with the inbox mark folder. A subscription to it will only notify you of emails going to that folder.
A subscription only allows you to subscribe to one resource at a time. You could use JSON batching to create/maintain multiple subscriptions in the same call, but that would only be beneficial to reduce the number of http requests.
You'll need to subscribe to each folder you want to get notified for, a request to users/{id}/mailFolders should give you a list of the folders for the inbox.
Related
By default, Twilio trial accounts can only send SMS to numbers that are listed as Verified Caller IDs in the Twilio console. These numbers have to be added manually, and require a verification message before they can receive SMS. This is an excellent feature for development, as it prevents accidentally sending SMS to wrong numbers.
My problem, is that I am developing for a client whose account is already out of trial status. I don't want the software in development to be able to send text messages to any number, because there is a risk of sending dev messages to the client's actual customers. However, we need to be able to send to some numbers for testing. Is there any way to turn the trial behavior back on? That is, can we somehow configure Twilio to only allow sending SMS to verfied numbers, even if it is not a trial account?
If this isn't possible, I think I can query the Outgoing Caller IDs resource from my program to verify the recipient number against the list before sending. However, this puts the responsibility back on my development team, and the possibility for mistakes remains. I'd like to be able to block the behavior at the Twilio level.
This behavior is only applied for trial accounts, however I'll pass this feedback on internally.
You'll need to replicate this behavior yourself for your applications using an upgraded account.
As you mentioned, you can query the Outgoing Caller IDs to get the phone numbers you have already verified with Twilio and use that as an accept list.
However, for your use case, you can store and fetch the accept list using whatever way is most convenient for you, like in code, file, database, etc.
Depending on your needs, you could embed this logic directly into your app, or use a single shared library, or create a web API that all other apps have to use to send texts.
Good luck! We can't wait to see what you build!
Update after getting internal feedback.
You can create a new trial account, even with the same Twilio profile, which would give you promotional credits and the same verified Caller ID limits again.
The promotional credit should last you a long time for test scenarios.
I am dev'ing a project where someone creates an event, and a group of people get an sms message inviting them. I want the recipient to be able to rsvp via sms. So if they respond "yes" I want to know what event_id they are responding to0.
I am passing a:
"statusCallback" => "https://cbd5-67-183-175-137.ngrok.io/receive-note/12345"
(not a real event id, just testing)
I don't care about the message status at this point, just if a response comes in. What parameter can I pass to the create message call that will allow me to dynamically track what event this invite was for? Is it a webhook or some kind of grouping?
Twilio developer evangelist here.
There is no concept of replying to a specific message in SMS, messages are just chronological.
The statusCallback URL for an SMS will only report on the status of the message you are sending to the end user, from queuing the message to be sent all the way through to delivery.
When a user sends an SMS to your Twilio number it triggers the incoming message webhook.
The incoming message webhook has no connection to an outbound message at all. So you will have to work out what message you think the user is replying to. A simple way to do this is to assume that they are replying to the last message you sent to them or the last event invite.
You are probably already considering what might happen if a user is sent invites to more than one event at the same time. How can you distinguish which event they are replying about. You have a couple of options here.
You can only ever send one SMS about an invite at a time, up until a timeout of sorts. That way, when a user replies you can always assume it's about the latest message.
Or, you can send invite message from different Twilio numbers. If you then store the outbound number with the invite you can look up replies based on the user's number and the number they replied to and calculate which invite they are responding to. To achieve this, you need more than one Twilio number, but you should only need as many numbers as the maximum estimated number of events a user might be invited to at one time.
Finally, you could ask the user to include an event ID or similar in their reply which you can then parse out, but this is likely to be a difficult ask of users.
This exists in SendGrid and is very useful. I don't understand how it's not implemented in Twilio.
I am building a CRM which handles email exchange in the app by processing emails sent to the Office365 accounts of the users using Microsoft Graph API. What is the best practice to keep track of emails in the actual mailbox? Should I use delta's or subscriptions?
From what I can tell, Delta's are URLs which give data about the current state of the mailbox, but deltas need to be triggered on a regular basis (I'd use a CRON job) but then I'd be running the process a lot more than needed because users don't receive that many emails per day.
Alternatively if I use a subscriptions that will let me know when a new email is received and I can process using a webhook in my app.
From the Microsoft Graph documentation it seems like deltas are the way to keep track of changes, but I feel like since all I need is to know when a new email is received so that it can be processed accordingly, delta's would be overkill in a sense.
You use a combination of the two.
The webhook tells you the mailbox has changed, the delta tells what has changed in the mailbox. When you receive a notification, you pull the delta to retrieve the changes to the mailbox.
There are many reasons for doing this, but the primary one is that the id of an email can change. This is because Message IDs are a composite value that includes the folder it is stored in. So if the message gets moved, the Id you received in the notification will be invalid. Historically this was a somewhat rare race condition, but with the advent of interactive mobile notifications, it is now commonplace for an email to come in and instantly get "archived". By relying on webhooks for notifications and deltas for content, you avoid a CRON job while mitigating the Id changing before you can process the message.
I've got an iOS app backed with ejabberd, with a small extension based on offline_message_hook that uses APNS (Apple Push Notification Service) to deliver push notifications of messages that are sent to offline users. This doesn't work out so well for group chats though, so I'm looking for a strategy that would do the same for offline users that are part of a group chat. Do MUCs even keep track of users that are part of the room but offline? Would I need to extend them in some way to keep track of this? Could I subtract the set of invited users from the set of online users to get the offline users? What hook should I be using to do this?
Any suggestions on this or advice on a better strategy are much appreciated!
The XMPP specification for Multi User Chat define MUC rooms as presence based. Per definition, a user is only in a chat room when it is connected. When he gets offline, users gets out of the chatroom. It means he does not receive message at all. This explains why they are not stored offline.
This is for now a feature of XEP-0045. Some future XMPP specifications (aka MUC 2) may address this issue in the future. Currently, MUC + offline storage of message is not possible in XMPP.
When Users receives email from my domain specific email id he/she receives it in promotion tab.
while it should be delivered in primary email tab of inbox.How it can be done.
The way emails are assigned to a specific tab depends on multiple criteria, including but not limited to the following:
Gmail uses a variety of signals to classify messages into the different categories.
Users are in control of their inboxes - they can disable some or all tabs, they can choose to move particular messages or senders into a particular category manually.
Gmail learns from user corrections, so over time any misclassifications, as users who receive the mail perceive them, will get automatically put into the right category.
It is recommended for commercial mail senders to split promotional mail from notifications/transactional mail - put those in different messages and send then from different email addresses.