We have recently implemented group chat functionality for an existing application using Twilio Programmable Chat.
Context: The application allows users to connect with each other and join groups. We are using Twilio to add a real-time chat room within each group so that group members can communicate. So when a user joins a group, he/she accesses the Twilio chat channel, as well as various other group resources.
When a user joins a group (as defined by our app), it seems that they are not considered a member of the group's channel unless they are active in the chatroom (i.e., when app is not in foreground, user is not listed as channel member). We are trying to do find some way to introduce persistent notifications for the group in the Twilio channel (i.e., "John Smith has joined the group" or "Jane Smith has left the group"). In another SO discussion, philnash had mentioned using the Twilio REST API to send system-authored messages with this information, and then manage these messages on the UI side to format them as group "updates". That makes sense!
My questions are:
Do I need to handle sending system-authored messages on our backend? If so, I'll need to add a field to my Groups model to include the Twilio channel SID for the group.
Is it possible to mute notifications for these system-authored messages (which will be formatted as "channel updates")? I.e., is it possible to not send push notifications to users whenever the message being sent is authored by system?
I hope my questions are clear enough. Thanks so much for any answers or guidance anyone can provide for the above!!
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 building a service where we need to create a new phone number to each new account and later act as its Whatsapp intermediary. So every new user can have their own Whatsapp number and see chats (and interract with them) in our external app. Basically a client for whatsapp numbers. Is there a way to do it with Twilio or Vonage? I tried to but it seems like it allows to build such functionalities only with one, WhatsappBusiness account. But it doesn't allow to scale new numbers programmatically.
Twilio developer evangelist here.
We do have an alternative process for creating accounts that service other businesses through WhatsApp if you are an independent software vendor or system integrator. However, it's still not an API process. I believe this is because there is an amount of back and forth between you, Twilio and Facebook to set up, review, and approve each business account and number.
The restrictive nature of this is on Facebook's side, since they have stricter rules for how WhatsApp can be used to engage users. So I don't imagine any partner will be able to offer this process entirely through an API.
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.
The Scenario:
I have a exclusive mobile chat app. Users can communicate with preselected and know groups of people that don't use the app via an SMS bridge. For that purpose currently each user get's her/his own virtual phone number. SMS for an specific user are sent and received via this virtual number. The SMS are distribute to each member of the group she/he communicates with.
The Problem:
A single receiver can be member of more then one group. In this case, when a receiver (R) responds to an SMS message from the user (U), it is not unambiguously clear wich group the response belongs to. Because the only available information is the sender (R) number and receiver (U) number (virtual) we can not be certain wich of the groups that R belongs to the message came from.
Solution Idea:
The only way I can see to get around this problem is to have U use a different phone number to communicate with each group. Assigning each user many phone phone numbers for that case isn't scalable at all because of the costs. But I also would at least initially like to avoid the complexities of managing a vast number pool that automatically assign numbers to individual communications.
Question:
Is there any way at all to add additional digits to the senders virtual number when sending an SMS? So that when he/she replies to that number, the context is transmitted back to the server
Twilio developer evangelist here.
I'm afraid there isn't anything within SMS that does what you need. You were right when you supposed that U should have a different phone number to communicate with each group.
It's not all bad though, because you can set up which users are in a particular group, you can reuse that number for a completely different group. Here's a good article on scaling number pools for group messaging that might help.
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.