Client.getConversationByUniqueName and Client.getConversationBySid cannot find conversations created by other users - twilio

Note: I'm using #twilio/conversations version 1.1.0 in node project. I'm transitioning from using Programmable Chat to Conversations.
I'm seeing calls to Client.getConversationByUniqueName and Client.getConversationBySid are not returning existing channels that were created by other users.
Example:
User 'A' (with its own unique identity and token) successfully created conversation 'myConvo1'using the following code:
client.createConversation({
uniqueName: 'myConvo1',
friendlyName: 'myConvo1',
});
User 'B' (with its own unique identity and token) cannot find that conversation using: Client.getConversationByUniqueName('myConvo1') OR Client.getConversationBySid(sid) (just passing in the sid I get from the initial createConversation call).
 
I see these errors respectively:
Not Found  at ​​​Upstream.actualSend​​​
​./node_modules/#twilio/conversations/node_modules/twilsock/lib/services/upstream.js:135
Conversation with SID CHc4565e40a32f4bffaf490bae2cff45db is not found. 
at ​​​conversations.syncListRead.promise.then.then.conversation​​​ ​./node_modules/#twilio/conversations/lib/client.js:283
However, I can access this conversation fine with the same functions if I'm using User A's token/identity.
Also, when I call this from User B's Client:
client.createConversation({
uniqueName: 'myConvo1',
friendlyName: 'myConvo1',
});
I get this error: Conversation with provided unique name already exists. So all of this leads me to believe the conversation is out there, but it's just not available for other users to join.
Note 2: I've been referencing the docs below. I don't see any explicit examples on how to find and join channels, so I may be missing something or approaching this wrong.
https://media.twiliocdn.com/sdk/js/conversations/releases/1.1.0/docs/Client.html
https://www.twilio.com/docs/conversations

Could this be the reason, where Twilio Conversations only supports private channels, not public channels like Programmable Chat?
Public vs. Private Channel Use Cases with Twilio Programmable Chat
Migrating to Conversations from Programmable Chat

I created multiple Service ID's and using one specific(XXXX-Chat-Dev) Chat Service ID, but application took the Default Chat Service ID which I didn't mentioned in backend.
Fixed by deleting the Default Chat Service ID in Twilio.
Cheers!

Related

How to get to invoice link in invoices api

I am interested to have a invoice link/pdf from the api which returns the invoice using new freshbooks api endpoint https://api.freshbooks.com/accounting/account/<accountid>/invoices/<invoiceid>
Even including direct_links I am unable to get the link to the invoice. With direct_links it returns json with fields id, contactid, created_date, type, userid, objectid, token.
I currently work at FreshBooks.
Unfortunately these direct link tokens will only work with old FreshBooks, which isn't mentioned in the documentation -- I'll see if we can fix that.
Poking through, it doesn't look like we've has exposed a way to access a PDF version of the invoice through the public API just yet. But I'll pass that on to the appropriate channels and I'll update this answer if that changes.

How to alert a custom group in slack using incoming webhook

I was trying to alert a custom group using incoming webhook in slack.I can able to alert user using <#user>, but with group any of the following format is not working
<!cgroup>
<#cgroup>
What i am missing here. Thanks in advance.
I got this working by adding a link_names attribute to my JSON payload. For example, POSTing this to my Slack hook URL:
{
"text": "#myusergroup Hello",
"link_names": 1
}
Caused users in #myusergroup to be notified by the message.
From Slack documentation.
For paid account there is an additional command for User Groups that
follows the format <!subteam^ID|handle>. (subteam is literal text. ID
and handle are replaced with the details of the group.) These indicate
a User Group message, and should cause a notification to be displayed
by the client. User Group IDs can be determined from the
usergroups.list API endpoint. For example, if you have a User Group
named happy-peeps with ID of S012345, then you would use the command
<!subteam^S012345|happy-peeps> to mention that user group in a
message.
It is working great

Slack: how to get directmessage channel name

I am creating a slack slash command and I want to know the username of the channel I am executing the command in.
So for example I have a colleague called #steve, I am directly chatting with steve and I execute the command:
/mycommand
when I check back on my application, I see that the POST request only got these values
[
(u'user_id', u'U03NKXXXX'),
(u'channel_id', u'D03QBXXXX'),
(u'text', u''), (u'response_url', u'https://hooks.slack.com/commands/T03ARXXXX/3804397XXXX/nGUTg4zpQrMrRR07scI6XXXX'),
(u'team_id', u'T03ARXXXX'),
(u'channel_name', u'directmessage'),
(u'token', u'XXXXXXXXXXXXXXXXXXX'),
(u'command', u'/mycommand'),
(u'team_domain', u'myteam'),
(u'user_name', u'myusername')
]
I was expecting directmessage to be the name of user (steve on my example), so how can I get the target channel username?
In theory you can take the channel ID you received from the slash request and get the full information of the current channel with conversations.info, which would include the channel owner of a direct message conversation.
However, due to Slack's security architecture your token needs to have access to that direct channel. And it will only have access if it belongs to one of the two participant of that direct message channel.
So unless your app has tokens from every user the best you can do is take the user ID from the Slash command, which must come from one of the two participants of a direct message.

verifying a single attendee with email

Is there a method to return a specific attendee's information by sending:
1) the attendee's email address
2) my user_key
3) my app_key
I could do this by searching the returned xml from this "event_list_attendees" method, however, I would prefer to only receive the one result (not hundreds for each call).
Note: I work on the platform team at Eventbrite
Currently there is no way to search for a specific attendee with event_list_attendees.
However, you can cut down on the amount of data returned by paging through the results until you have found the attendee or using the modified_after parameter if you know when the user was last updated: http://developer.eventbrite.com/doc/events/event_list_attendees/
I realize this limitation is non-ideal. We're actively working on building a new API which is more RESTful and does not have issues like this.

Broadcasting to a subset of subscribers in Atmosphere

What I'm trying to do:
Be able to have users subscribed to a number of different 'chat rooms' and use reverse AJAX / comet to send messages from a chat room to everyone logged into that room. (a bit more complicated but this is a similar use case).
What I'm doing:
Using Grails with JMS and Atmosphere. When a message is sent, I'm using JMS to send the message object which is received by a Grails service which is then broadcasted to the atmosphere URL (i.e. atmosphere/messages).
Obviously JMS is a bit redundant there but I though I could use it to help me filter who should retrieve the message although that doesn't really look it'll work (given that the subscriber is basically a singleton service...).
Anyway, what I need to be able to do is only send out a message to the correct subset of people listening to atmosphere/messages. A RESTful-type URL will be perfect here (i.e. atmosphere/messages/* where * is the room ID) however I have no idea how to do that with Atmosphere.
Any ideas / suggestions on how I can achieve what I want? Nothing is concrete at all here so feel free to suggest almost anything. I've even been thinking (based on the response to another question), for example, if I could do something like send out messages to a Node.js server and have that handle the reverse AJAX / comet part.
If I understand your requirements correctly the following should work (jax-rs + scala code):
1) Everyone who wants to get messages from a chat room registers for it:
#GET
#Path(choose/a/path)
def register(#QueryParam("chatroomId") chatroomId: Broadcaster) {
// alternatively, the Suspend annotation can be used
new SuspendResponse.SuspendResponseBuilder[String]()
.resumeOnBroadcast(false).broadcaster(chatroomId).scope(SCOPE.REQUEST)
.period(suspendTimeout, TimeUnit.MINUTES)
.addListener(new AtmosphereEventsLogger()).build
}
2) To broadcast a message for all the registered users, call the following method:
#POST
#Broadcast
#Path(choose/a/path/{chatroomId})
def broadcast(#PathParam("chatroomId") id: String) {
// first find your broadcaster with the BroadcasterFactory
BroadcasterFactory.getDefault().lookupAll() // or maybe there is a find by id?
broadcaster = ...
broadcaster.broadcast(<your message>)
}
I also recommend reading the atmosphere whitepaper, have a look at the mailing list and at Jeanfrancois Arcand's blog.
Hope that helps.
There is a misunderstaning of the concept of comet. Its just another publish/subscribe implementation. If you have multiple chat-rooms, then you need to have multiple "topics", i.e. multiple channels the user can register to. E.g.:
broadcaster['/atmosphere/chatRoom1'].broadcast('Hello world!')
broadcaster['/atmosphere/chatRoom2'].broadcast('Hello world!')
So I would advance you to creaet multiple channels and do not filter manually the set of users, which should retrieve messages (which is definitely not the way it should be done). You do not need to create anything on the server side on this, since the user will just register for a specific channel and receive messages, which anyone is putting into it.
I would recommend you create an AtmosphereHandler for one URL like /atmosphere/chat-room and then use the AtmosphereResource and bind an BroadcastFilter with it, lets say name it ChatRoomBroadcastFilter.
Whenever a user subscribes to a new chat room, a message would be sent to the server (from the client) telling the server about the subscription. Once subscribed, maintain the list of users <> chat room bindings somewhere on the server.
Whenever a message is broadcasted, broadcast it with the chat room id with it. The in the ChatRoomBroadcastFilter (You probably need to make this a PerRequestBroacastFilter) propagate the message to the user only if the user subscribed to the chat room. I am not sure if this clears it out. If you need code example please mention in the comments. I'll put that but that needs some time so ain't putting it right now ;).

Resources