'How To Create Multiple-Choice Chatbot with Python
i want to create chatbot that can generate pre defined multiple choice answers like this picture below like yes/no answers.
but after some research in the internet, i could not find the solution that meets my needs. i want to use python to create this chatbot and only simple rule based chatbots.
Many thanks!
Solution 1:[1]
What platform do you wish to make the Chatbot on
Many popular platforms have their own chat api (discord , instagram , reddit)
Or do you want to have it in your own website ?
Discord - You can use the package discord.py Sample bot (Source - discord.py docs)
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content == 'ping':
await message.channel.send('pong')
client = MyClient()
client.run('token')
Instagram - You can use instapy (https://github.com/InstaPy/InstaPy). I personally have no experience with making instagram bots or stuff
Reddit - You can use PRAW. Its a package for reddit automation and stuff (https://praw.readthedocs.io/en/stable/).I have never made a reddit bot either
If you want it in your own website (like the screenshot shows) , there are many tools that can do this WITHOUT you needing to code. If you want to make your own you can either
Write a big if else statement
Use Chatterbot (https://chatterbot.readthedocs.io/en/stable/)
Hope this helps :)
Solution 2:[2]
All applications (like your chatbot) are made of two different parts, frontend and backend. Frontend is responsible for graphical displaying of text, image,buttons,etc to users, which these data are given from backend.
The backend is where the logical processes are done.
For your purpose, for backend, you can use django and write your python codes there. Then for showing text and those pre defined choices, you should know about html, css and javascript.
You can simply send your multiple choice answers from backend to frontend, then frontend interprets them and shows them like the picture you sent above.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Global-Occult |
| Solution 2 |
