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:

Actual Behavior Simulation:

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

Stop the webpage from scrolling when clicking on a ui-grid field

Is there a way to prevent page scrolling when clicking on a row field in ui-grid? I'm working with a page that has ui-grid, and each row includes an anchor tag with a URL value linked and target="_blank" to open in a new tab like the example below: ...

Having trouble accessing the URL route by typing it in directly within react-router?

Having some trouble getting dynamic routes to work with react router. Whenever I enter a URL like localhost:3000/5, I receive the error message "cannot GET /5". Here is how my router is configured: class App extends Component { render() { retu ...

Have you considered retrieving POST parameters using Ajax POST in jQuery?

Below is the code snippet: $.ajax({ type: "POST", url: "http://localhost:3000/rcm/global_config/update", data: {k: 'sdfa', v: 'dsfas'}, success: function(data, textStatus, XMLHttpRequest){ alert("Data ...

Uninstalling NPM License Checker version

Utilizing the npm license checker tool found at https://www.npmjs.com/package/license-checker The configuration in license-format.json for the customPath is as follows: { "name": "", "version": false, "description&quo ...

I am attempting to transfer information from one page to another in Next.js, but unfortunately, I am experiencing difficulties in

Encountering the following error message: "Error: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead." Any assistance will be greatly appreciated. export default func ...

Is there a way to access the value variable from a JavaScript file located in the javascript folder and bring it to the routes/index.js file in a Node.js and Express application?

I'm currently working on transferring the input value from an HTML search box to the index route file in Node.js using Express. I have successfully retrieved the value from the search box in the javascript/javascript.js file, and now my objective is t ...

Troubleshooting Node.js TypeScript breakpoints in Visual Studio Code

I've attempted multiple solutions, but none seem to be working for me. Although the code is running, I'm having trouble setting breakpoints and debugging it. Can you offer any assistance? Below is the configuration script I've tried in VSCo ...

Executing a JavaScript function within a React web application

Having trouble calling JS functions from ReactJS? I recently encountered an issue when trying to import and call a JS function in a button onClick event in my React project. Specifically, when trying to use this.abtest.events.on in the handleButtonColor fu ...

Make the textarea larger and bring it to the forefront when it is selected

I would like to make a textarea expand (increase its height) when it is in focus. The expanded textarea should not push the content down, but rather be displayed above other content. Currently, this is the code I am using (check out the example here): $( ...

Sending the value from a for loop through AJAX and populating it into a form field

Currently, I have implemented a piece of JavaScript code that captures user input, sends a request to an endpoint using AJAX, and appends a specific field from the returned results as an option within a datalist. This functionality is working perfectly fin ...

Sustaining component state in NextJS applications

I am facing an issue with my NextJS app where I have two distinct layouts for landscape and portrait modes. The parent page structure is as follows: <NavWrapper> <MyPage> </NavWrapper> The NavWrapper component handles the layout based on ...

Is it feasible to activate an action on a click of a Vimeo video?

Is there a way to activate an event by clicking if a video is set with background=1 and has no controls? This particular video is from Vimeo, using a plus account which allows for setting background=1. The scenario involves a Vimeo video playing on loop ...

Is the node certificate store limited to reading only from a predefined list of certificates?

Is there a way to add a new certificate to the list of certificates node trusts, even after some struggle? It appears that Node only trusts certificates hardcoded in its list located here: https://github.com/nodejs/node/blob/master/src/node_root_certs.h ...

Utilizing diverse values retrieved from HTML data attributes

*UPDATE Within my HTML, I have a list titled "#wordlist" that contains the words for my game, along with corresponding audio and images for each word. Everything is functioning correctly. As there will be multiple versions of the game, I've been tas ...

Clicking on a JQuery element triggers an AJAX function, although the outcome is not aligned with the intended

Instead of using a fiddle for this task, I decided to work on it online since my knowledge of fiddles is limited. However, after multiple attempts and hours spent rewriting the code, I still can't get it right. The issue at hand requires that when cl ...

access the database information within the fullcalendar plugin

I've been exploring the calendar code on arshaw/fullcalendar and made some modifications, but I'm still unsure how to link JavaScript with a database. Here is the original code: $(document).ready(function() { var date = new Date(); var d = dat ...

Is it acceptable to post variables using AJAX for processing?

Is there a way to send data with AJAX using the code provided? It seems like the information is not being sent to the PHP file as intended. Here is the code snippet: $('#send').click(function(){ var pseudo = $('#psd').val(); }) ...

Encountering a client component error with the app router in Next.js version 13.4.9

Encountering an error in Nextjs that persists until the 'use client' directive is removed. Warning: Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Con ...

The error message "TypeError: addNewUser is not a function in React.js onSubmit

What could be causing the error message "TypeError: addNewUser is not a function"? The issue arises when I complete the form and click save, displaying the error that addNewUser is not defined as a function. The problem occurs within the following code ...

How to include a key-value pair to a JSON object within an array using JavaScript

I am looking to include the following functionality in the JSON data provided below: "Check if the key name default exists, and if it does, add another key within the same object => ("pin" : 91)." I have attempted to achieve this using the code snippet b ...