'Unable to create a new conversation in a channel

I'm attempting to create a new thread in a Teams Channel a bot has been added to after a specific Dialog step. I have attempted to follow the following sample: https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/typescript_nodejs/58.teams-start-new-thread-in-channel, where I use sendMessageToTeamsChannel:

        const activity = MessageFactory.text('test') as Activity;
        const ref = await TeamsInfo.sendMessageToTeamsChannel(turnContext, activity, teamsChannelId, process.env.MICROSOFT_APP_ID);

.

I have also attempted creating a new client with Microsoft App credentials and passing conversation params:

        const credentials = new MicrosoftAppCredentials(process.env.MICROSOFT_APP_ID!, process.env.MICROSOFT_APP_PASSWORD!);
        const client = new ConnectorClient(credentials, { baseUri: serviceUrl });
;
        const conversationParams = {
            bot: channelAccount,
            channelData: {
                channel: {
                    id: teamsChannelId,
                    tenant: tenantId
                }
            },
            isGroup: true,
            activity: message
        } as ConversationParameters;

        const ref = await client.conversations.createConversation(conversationParams);

Both fail with a 404 error code:

DialogContextError: Conversation not found.
   {
    code: 'ConversationNotFound',
    statusCode: 404,
    request: WebResource {
      streamResponseBody: false,
      url: 'https://smba.trafficmanager.net/amer/v3/conversations',
      method: 'POST',
      headers: [HttpHeaders],
      body: BODY_HERE,
      query: undefined,
      formData: undefined,
      withCredentials: false,
      abortSignal: undefined,
      timeout: 0,
      onUploadProgress: undefined,
      onDownloadProgress: undefined,
      proxySettings: undefined,
      keepAlive: undefined,
      agentSettings: undefined,
      operationSpec: [Object]
    },
    response: {
      body: '{"error":{"code":"ConversationNotFound","message":"Conversation not found."}}',
      headers: [HttpHeaders],
      status: 404
    },
    body: { error: [Object] }
  },
  dialogContext: {
    activeDialog: 'WATERFALL_DIALOG',
    parent: 'sampleDialog',
    stack: [ [Object] ]
  }
}

. Is it not possible to start a new conversation/thread in a channel from a 1-on-1 conversation even if the bot is added to the channel and I have the channelId?

Additional information: I've built this bot using the YoTeams Bot scaffold and it is a Dialog based Bot so I have not exactly copied the sample.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source