2

I can simply create a new Conversation using the default Conversation Service using Twilio.Rest.Conversations.V1.Create() but how do I create a new Conversation using a particular (non-default) Conversation Service using the API? I can fetch the Conversation service I want: ServiceResource.Fetch(pathSid: "ISxxxxxxxxxxxxxxxxx") but I can't see how to use that to create a new Conversation.

Is it not supported through programmatic API, and do I need to use the raw json to the URL instead?

philnash
  • 70,667
  • 10
  • 60
  • 88
Law
  • 21
  • 1

2 Answers2

1

Twilio developer evangelist here.

I believe you are talking about using the Twilio API C# library. The docs on creating a conversation seem to miss this, but you can create a conversation for a different service by providing it as the pathChatServiceSid option to the call to create.

using Twilio.Rest.Conversations.V1;

TwilioClient.Init(accountSid, authToken);

var conversation = ConversationResource.Create(
  pathChatServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
);

You can see more of this in the source code for the ConversationResource and ConversationOptions. I'm not a C# developer, so I hope I have interpreted that correctly for you.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Sweet, would be helpful and save time of other devs if mentioned in [Doc](https://www.twilio.com/docs/conversations/api/user-resource#using-the-shortened-base-url) – Chenna Jun 22 '22 at 02:34
0

Thanks philnash, the github links you posted lead me in the right direction.

It turns out that the Twilio library seems to contain multiple namespaces with similar functionality

  • Twilio.Rest.Conversations.V1.Conversation
  • Twilio.Rest.Conversations.V1.Service.Conversation

Where the former one lacks the pathChatServiceSid parameter, but the latter (the one you pointed me to) does.

Thanks

Law
  • 21
  • 1