Microsoft Bot Framework :turncontext

Viewed 714

I am new to Microsoft bot framework and have seen the term turncontext many times.

Can some one explain what that actually means and its significance.

eg: turncontext(adapter,activity)

1 Answers

When using a bot, the user and the bot take it in turns to speak. Within the Bot framework a turn is a users incoming activity which the bot responds too. Every message the a bot receives from a new user will be in a new turn.

If the user asks a question "What is the weather like today?", the bot may respond with "Where would you like the weather for?". That is all in one turn. The user then responds with "London", this is in a new turn.

The turnContext is the object that gives you access to the information about the current turn from the user. This includes the current message sent by the user among for example. For a full specification see here. It's also used to send messages back to the user, SendActivityAsync is one to do this.

Take a look at this Microsoft article I used as the basic of this answer which goes into way more detail. Also take a look through the Bot Framework Samples and step through the code to learn more about the turnContext.

Related