0

As the title suggests I'm having trouble integrating the Conversations API with Taskrouter capabilities.

The approach I'm using is essentially what is suggested for integrating SMS and Taskrouter here Using SMS and Taskrouter Together

The idea is that when an SMS hits your twilio number you invoke a webhook which will create a conversation and add the inbound number as an MMS participant and then enqueue a task with the conversation SID as an attribute. Then on client side you accept the reservation and join the conversation. Except this doesn't work because the conversation was created on the server-side and so calling getConversationBySid on client side fails to see the conversation.

I'm a bit at a loss here. If I create the task on the server side and then try to create the conversation on the client side and add both participants I lose any messages that they inbound MMS participant sent while the task was waiting in queue.

I'm sure that there's a more elegant design for this but I'm failing to see it. Any advice would be appreciated.

ztyree
  • 21
  • 3
  • 1
    I don't follow why you can't join the conversation because it was created on the server? Do you need to trigger a request to your server to add your worker to the conversation when they accept the task and then join it from the client side? – philnash Jan 13 '21 at 22:58
  • @philnash apologies, I wasn't specific enough. I can't join the conversation using the clientside SDK. The JS method getConversationBySid fails. I think this is because the conversation was created on the server side and so the client cannot see it. I will edit question to be more specific. – ztyree Jan 14 '21 at 01:21
  • @philnash As I read your comment again I wonder. Are you saying that I should add the worker to the conversation as a participant on the server-side after they accept the reservation? I haven't tried this but if so what is the purpose of the client-side *join* method if not to join the conversation? – ztyree Jan 14 '21 at 01:29
  • 1
    Yes, that's what I'm saying. Since there aren't public channels in the Conversations API, you can't just `join` any conversation as a regular user. There are users with service admin privileges that can join any conversation, so if you were building an admin view you would use the `join` method. For regular users you should add them as a participant on the server and in the client side subscribe to the `conversationJoined` event. – philnash Jan 15 '21 at 00:00
  • 1
    (BTW I had to ask internally myself why there was a `join` method, so I don't blame you for wondering!) – philnash Jan 15 '21 at 00:01

0 Answers0