Another possible solution that involves tilt switches , get the smallest ones you can find and arrange as many as you can at slightly different angles , as your robot tilts the relevant switches are activated , the main difficulty with this is the accuracy is totally dependent of the quality of workmanship and the amount of switches used .
I really don't no if it would work , its just an idea I thought to put in as I read your question .
In many ways I have just described a type on encoder.
Why stop at detecting a slope , I also would want to measure it .