Yes, something like this. For all we know, everything else might just be a big chemical reaction, with no pain involved. The dog reaction might just be like a reflex.
The only reason why we know it own pain exist is, well, because it hurts :)
(But once again, I think the theory that other people and animals also feel pain is reasonable and probably the truth)
https://en.wikipedia.org/wiki/Solipsism