How to set `You and moderator can reply` in bot when posting proactive message to channels?

New Contributor

Hi there, 

 

I am currently developing a bot that posts proactive message to channels. My client wants me to set `No reply` or `You and moderator can reply` on the message that posted from the bot proactively. 

 

What I tried so far:

// post 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 tried to post the message first, and immediately update the activity and set the type as `ActivityTypes.EndOfConversation`. However, it doesn't work at all.

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

 

Error form above updateActivity code: 

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 any method that allows me to do so? Thanks.

 

3 Replies

@ssywilson, Could you please go through this document for reference and please confirm are you following any sample.

@Ravindra-MSFT Hi, I was following this article to send proactive messages to channels. However, I found that after the bot sends out the proactive message, the channel's chatroom will appear a `Reply` button right below the bot's message.

 

Therefore, I want to ask is there any method to disable the `Reply` button?

 

----

 

Simulation of expected behavior on UI:

2gTTb

 

Simulation of actual behavior on UI:

EnTM2

@ssywilson It is by design, we cannot disable reply button 

www.000webhost.com