Closed cilim closed 2 years ago
@cilim: Could you please clarify what you are trying to accomplish? The docs you linked has ruby code example to migrate the channels to private and the gem supports that. Kindly let us know what specifically you need help with and provide us an example of your code to work with.
@rakatyal I tried the Ruby example like so:
@client = Twilio::REST::Client.new(account_sid, auth_token)
channel = @client.chat
.channels('my_chat_id')
.update(
type: 'private'
)
and got:
ArgumentError: unknown keyword: :type
I believe it's because the request is sent to the v1 API endpoint, not v3.
Ah, I just looked at the changes and I believe it will be resolved if I bump the gem to 5.66.0
@cilim Is the new version able to help?
@childish-sambino unfortunately, I'm also having issues when 5.66.0 is installed.
Here's some code:
client = Twilio::REST::Client.new(Rails.application.secrets.twilio[:api_key], Rails.application.secrets.twilio[:api_secret], Rails.application.secrets.twilio[:account_sid])
client.chat.channels('CHXXXXXXXX').update(type: 'private', messaging_service_sid: 'MGXXXX')
when the above code is executed, I get this error:
Twilio::REST::RestError: [HTTP 403] 50050 : Unable to update record
Service instance not found
https://www.twilio.com/docs/errors/50050
I pried a bit and landed in Twilio::REST::Chat::V3::ChannelList#update
, where:
payload = @version.update('POST', @uri, data: data, headers: headers)
raises the error.
Here's some background on the variables I used:
sid
of the channel I want to set type to "private"client.messaging.services.list.size
I get 1, and it's the Default Conversations Service, with a sid starting with MG, followed by 32 characters, so I believe that's correct.
@childish-sambino I hope that's enough information to dig up what might be wrong. What "service instance" isn't found?
client.chat.channels
expect 2 arguments: service_sid
and sid
. You'll need to pass the service_sid
for the chat service that the channel belongs to. E.g.,
client.chat.channels('ISXXXXXXXX', 'CHXXXXXXXX').update(type: 'private', messaging_service_sid: 'MGXXXX')
@childish-sambino thank you for your support. That did it!
I'm just left wondering if I'll have to create new Conversation services, or will the current Chat services become Conversation services? That is, I just have to toggle public channels to private ones, and all of my message and message participants will get migrated automatically?
Sorry, I don't know the answer to that. Recommend contacting Customer Support by filing a support ticket.
Thank you anyways for your support! Closing issue
Issue Summary
I'd like to migrate public channels to private channels using the v3 URL mentioned in the docs: https://www.twilio.com/docs/conversations/api/chat-channel-migration-resource#update-channel-type
Is there any planned support for this by the gem itself? That way, consumers could easily create a rake task which they simply run on the live environments. Without it, we're forced to create our own logic for handling the request/response cycle.
Technical details: