chatbote
chatbote

Reputation: 181

.NET Core 2.2-How to use backchannel to display bot welcome message before user types in Webchat

I am trying to make my chatbot display the initial welcome message without the user having to type first to initiate conversation in webchat.

I have found this solution of using backchannel: here

but since the ApiController class is deprecated in .NET core 2.2 I cannot use this solution.

MessagesController.cs

[BotAuthentication]
public class MessagesController : ApiController

{ 

    public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
    {
        . . .
        if (activity.Type == ActivityTypes.Message)
        {
            await Conversation.SendAsync(activity, () => new  Dialogs.RootDialog());
        }
        . . .
        var response = Request.CreateResponse(HttpStatusCode.OK);
        return response;
}

Because of this, in the above sample code provided in the solution, 'Conversation' and 'Request' do not exist in the current context. I am looking for a version of the above solution that works with .NET core 2.2.

Upvotes: 1

Views: 235

Answers (1)

Dana V
Dana V

Reputation: 1347

Try inheriting from ControllerBase and using the ApiController declaration.

[ApiController]
    public class BotController : ControllerBase

Upvotes: 1

Related Questions