My first writing job was on a TV show called Get a Life. The show was mostly in the voice of its creators, Chris Elliott and Adam Resnick, who'd worked on the David Letterman Show. Adam's scripts were the best thing about Get a Life – and we all tried to write in Adam's voice. That was the job.

I was frustrated with the results, but it occurred to me that there was no solution as long as my job was trying to imitate someone else's voice. The obvious solution was to find a situation where I was doing me, not someone else. The major obstacle to this is your deeply seated belief that "you" is not interesting.

When I first got the job, I couldn't talk in the writing room. I was working on a sitcom and I could not talk. It wasn't as if I chose not to talk, or I didn't talk – I couldn't open my mouth. No words would come out. And that went on for six weeks. I thought I was going to get fired, and probably should have been.

I wrote Being John Malkovich while I was waiting for [the next sitcom] hiring season. My idea was that I would write a script and use it to get work. I had this idea that someone finds a portal into someone's head, and I had another idea that somebody has a story about someone having an affair with a co-worker. And neither one was going anywhere, so I just decided to combine them.

It got a really positive response. I started to get a little known. People would read it and tell me how funny it was, invite me for meetings, tell me nobody would ever make the movie. I had maybe 15 meetings like that, so I wasn't really expecting it to get made. Then it got to Spike Jonze, and he was in a position to get a movie made. I didn't really expect it to be anything. I don't think Spike did either. I remember it going to the Venice film festival, which was the first exposure it had. I wasn't invited, but they went: Spike and Cameron Diaz and Catherine Keener. I just got a phone call saying that it was this big thing, and then all these articles got written about it. It was exciting.

Storytelling is inherently dangerous. Consider a traumatic event in your life. Think about how you experienced it. Now think about how you told it to someone a year later. Now think about how you told it for the hundredth time. It's not the same thing. Most people think perspective is a good thing: you can figure out characters arcs, you can apply a moral, you can tell it with understanding and context. But this perspective is a misrepresentation: it's a reconstruction with meaning, and as such bears little resemblance to the event.

The other thing that happens is adjustment. You find out which part of the story works, which part to embellish, which to jettison. You fashion it. Your goal is to be entertaining. This is true for a story told at a dinner party, and it's true for stories told through movies. Don't let anyone tell you what a story is, what it needs to include. As an experiment, write a non-story. It will have a chance of being different.

I'll tell you this little story. There's something inherently cinematic about it. I run in my neighbourhood, and one day I ran past this guy running in the other direction: an older guy, a big hulky guy. He was struggling, huffing and puffing. I was going down a slight hill and he was coming up. So he passes me and he says: "Well, sure, it's all downhill that way." I loved that joke. We made a connection. So I had it in my head that this is a cool guy, and he's my friend now.

A few weeks later, I'm passing him again, and I'm thinking: "There's the guy that's cool." As we pass each other, he says: "Well, sure, it's all downhill that way." So I think: "Oh, OK. He's got a repertoire. I'm not that special. He's probably said it to other people, maybe he doesn't remember me ... but OK." I laughed, but this time my laugh was a little forced.

Then I pass him another time, and he says it again. And this time he's going downhill and I'm going uphill, so it doesn't even make sense. And I started to feel pain about this, because I'm embarrassed for him and I think maybe there's something wrong with him. And then it just keeps happening. I probably heard it seven or eight more times. I started to avoid him.

I like the idea that the story changes over time even though nothing has changed on the outside. What's changed is all in my head and has to do with a realisation on my character's part. And the story can only be told in a particular form. It can't be told in a painting. The point is: it's very important that what you do is specific to the medium in which you're doing it, and that you utilise what is specific about that medium to do the work. And if you can't think about why it should be done this way, then it doesn't need to be done.

• This is an edited extract from a lecture given by Charlie Kaufman for Bafta and the BFI. Full series at bafta.org/screenwriters.

• The headline and standfirst were amended on 4 October to more accurately reflect what is said in the article. The original headline was 'Charlie Kaufman: How to write a story' and the standfirst was 'Your goal is to entertain. If it works, it works says the cult film-maker'