From the course: Advanced Python Projects: Build AI Applications

Analyzing sentiment

- [Instructor] Def get_response, and then the brackets, write 'message,' and then type "message = message.lower." And open parentheses. What we're doing here is we're taking the user's message and converting it to lowercase. Why do we do that? This helps make sure that whether the user types an uppercase open or a lowercase open, the bot treats them the same way. In the next line type, "if any," "word in message for word in intent_data," open bracket, "keywords"... And then end it with a colon. And in the next line, type, "return." "intent_data." Open bracket, in parentheses type "response." So what we're doing here is to have the bot check if any of the keywords in the intents matches the user's message. Let's say the user types, "I'd like to make a return." The bot will see the word return and check if it's in any of the predefined intents. So that's what these two lines do. If it finds a match, then it would respond with the response that we've defined over here.

Contents