What steps should be taken to enable the "You and moderator can reply" feature in a bot when sending proactive messages to channels?

A project I am currently working on involves creating a bot that sends proactive messages to channels. The client has requested that I include options like No reply or You and moderator can reply with the messages posted by the bot proactively.

Here is what I have attempted so far:

// posting message to channels
const credentials = new MicrosoftAppCredentials(process.env.MicrosoftAppId, process.env.MicrosoftAppPassword);
const client = new ConnectorClient(credentials, { baseUri: serviceUrl });
const message = MessageFactory.text(inMessage);

let approveResult = false;
let MessageActivityId = "";

const conversationParams = {
    isGroup: true,
    bot: {
        id: process.env.MicrosoftAppId,
        name: process.env.BotName
    },
    conversationType: 'channel',
    channelData: {
        channel: {
            id: teamsChannelId
        }
    },
    activity: message
};

const msRes = await client.conversations.createConversation(conversationParams).catch(e => console.log(e));

I initially tried posting the message and then updating the activity immediately with the type set as ActivityTypes.EndOfConversation. However, this approach did not yield the desired results.

const tmpResult = await client.conversations.updateActivity(teamsChannelId, msRes.activityId, {type: ActivityTypes.EndOfConversation})

Error encountered while using the updateActivity code above: 

RestError: Unknown activity type
at ...(skipped for paths)

{
    code: 'BadArgument',
    statusCode: 400,
    request: WebResource {
        streamResponseBody: false,
        url: 'https://{service_url}/{channel_id}/activities/{messageActivityId}',
        method: 'PUT',
        headers: HttpHeaders {
            _headersMap: [Object]
        },
        body: '{"type":"endOfConversation"}',
        query: undefined,
        formData: undefined,
        withCredentials: false,
        abortSignal: undefined,
        timeout: 0,
        onUploadProgress: undefined,
        onDownloadProgress: undefined,
        proxySettings: undefined,
        keepAlive: undefined,
        agentSettings: undefined,
        operationSpec: {
            httpMethod: 'PUT',
            path: 'v3/conversations/{conversationId}/activities/{activityId}',
            urlParameters: [Array],
            requestBody: [Object],
            responses: [Object],
            serializer: [Serializer]
        }
    },
    response: {
        body: '{"error":{"code":"BadArgument","message":"Unknown activity type"}}',
        headers: HttpHeaders {
            _headersMap: [Object]
        },
        status: 400
    },
    body: {
        error: {
            code: 'BadArgument',
            message: 'Unknown activity type'
        }
    }
}

Is there a different method available to achieve this goal? Any guidance would be greatly appreciated. It would be ideal if I could programmatically disable the reply function in Channels from the bot.


Update on 2021-06-28:

Expected Behavior Simulation: https://i.sstatic.net/2gTTb.png

Actual Behavior Simulation: https://i.sstatic.net/EnTM2.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing an unknown provider in AngularJS constants: a guide

Can anyone help me figure out what's going on with this code snippet? var app = angular.module('myApp', []); app.constant('_START_REQUEST_', '_START_REQUEST_'); app.constant('_END_REQUEST_&ap ...

Utilizing classes as types in TypeScript

Why is it possible to use a class as a type in TypeScript, like word: Word in the provided code snippet? class Dict { private words: Words = {}; // I am curious about this specific line add(word: Word) { if (!this.words[word.term]) { this.wor ...

Enable only the current week days on the multiple date picker feature

Can anyone recommend a date picker that only shows the current week and allows for multiple date selections by the user? I found this jsfiddle which limits the display to the current week, but it doesn't support selecting multiple dates. I attempted ...

Utilize NodeJS to dynamically alter the text outputted on an HTML page

For educational purposes, I am designing a website where users can sign in by entering their name on the login page. After signing in, they will be redirected to the home page which displays a personalized welcome message using their name. I have included ...

Guide on integrating buefy (a vue.js component library) into your Laravel blade template

I'm currently integrating buefy into my project, but I'm encountering issues with using vue.js on Laravel 5.8. Can anyone offer assistance? Here is the code snippet from my app.js: require('./bootstrap'); window.Vue = require('v ...

Angular constantly looping due to $watchCollection being triggered repeatedly

I am interested in monitoring the changes of an object, referred to as x, specifically its properties which are checkboxes. When a user checks a box, it alters the checked property (prop1) to 1. Each property contains certain content, and when enabled, it ...

Tips on incorporating CKEditor4 wiris MathML formulas into react JS

I am having trouble displaying MathML in the DOM. When I try to render it, the output is not showing correctly in the Editor. I am utilizing CKEditor4 Let me share the code below to provide more context on what I have attempted so far App.js file: impo ...

view multiple HTML documents simultaneously in a single browser tab

Currently, I am in the process of building a wiki and have included tables in various sections. I want to showcase these tables on the main page as well. Rather than constantly copying and pasting them, I'm looking for a way to have the main page auto ...

Combine two arrays in MongoDB where neither element is null

Issue I am looking to generate two arrays of equal length without any null elements. Solution I have managed to create two arrays, but they contain some null values. When I remove the null values, the arrays are no longer of equal length. aggregate([ ...

Tips for sending a JavaScript variable within a div's ID in a Twig loop?

How can I insert a JavaScript variable into the ID of a div inside a Twig loop? Here is my unsuccessful attempt: <script type="text/javascript"> id = 0; </script> {% for element in parent.elements %} <div id="mydiv"> ...

GROQ: retrieve all items within a given array

Currently working with Sanity/nextjs and I'm looking to retrieve all images along with their details from an array using a unique slug. Despite referring to the cheat sheet and trying multiple methods, nothing is displaying on the page and there are n ...

Conceal div elements containing identical information by utilizing jQuery

I'm dealing with a webpage that pulls in a long section of divs from another application. Unfortunately, I can't filter the divs before they appear, but I urgently need to hide any duplicate data within certain values using jQuery. The duplicate ...

The gradual disappearance and reappearance of a table row

I am struggling with making a row fade out when a specific select value is chosen (such as "termination"), and fade in when any other option is selected. The code works perfectly fine when the div ID is placed outside the table, but once I encapsulate it w ...

What is the best method for fetching data returned by AJAX using PHP?

I have a data structure similar to the one below, which is returned via AJAX to another file: $data = array(); $data['message'] = "You are searching: $domain!"; $data['domain:name'] = "domain.tld"; $data['domain:registrar ...

What is the best method for clearing all session cookies in my React application?

Currently, I am working on a project using React. I am trying to find a method to automatically logout the user by deleting all of the session cookies in my React application. However, I have not been able to come up with a solution yet. Is there a way to ...

On Windows systems, where exactly does npm place its packages during installation when using Node version 10.x

Does anyone know where I can locate the locally installed npm modules when using NodeJS version 10? I have checked under C:\Users\MyUser\AppData\Roaming, but I cannot find the "npm" folder. ...

What is the best way to make a JSONP request using jQuery?

Whenever I try to access this API through the browser, everything works fine and I receive the correct response. However, when I attempt to call the API using jQuery AJAX, I encounter an error. *The script is being refused execution from 'http://api ...

A guide to categorizing and tallying JSON data based on multiple keys within the past 30 days using JavaScript/jQuery

I am facing an issue while trying to display a chart and extract specific data from an array. My goal is to generate a chart based on three columns in a JSON array: Source, Campaign, and Date. The process involves grouping the data, counting it, and then ...

Retrieving User's Theme Preference from Local Storage in Next.js Instantly

As mentioned in various other responses, such as this one, Next.js operates on both the client and server side, requiring a guard to properly fetch from localStorage: if (typeof localStorage !== "undefined") { return localStorage.getItem("theme") } else ...

Calling Functions in JavaScript Through Events: A Beginner's Guide

As I dive into learning JavaScript, one thing that stumps me is figuring out how to call a function from an event. Currently, the only method I am familiar with involves using anonymous functions (as seen in my code example below), but I'm curious if ...