You can give Pandorabot a try.
For a "from scratch" programming, you can start up by building a small database of keywords and store them in a file. Train your bot for basic questions like "Who is your creator?"; "Who is your father?". Then, you can set-up the basic questioning words set, like "What", "Who" and "When".
I haven't created one but one of my friends did. For every question raised, the bot made a Google query about the noun where it settles to by eliminating prepositions and "What" & "When", e.g, for a question like "Who is Brad Pitt?", the bot eliminates the words like "Who" and "is". So all that the bot is left with is "Brad" "Pitt" and a Google query is thus made. He did give preference to Wikipedia though. This is how you can begin.
Note: This is just a hint on how you can begin. The intelligent AIs like IBM's Watson API are much more complicated to code.