We don't have any information on your vehicle so I am not sure of the system used. If it is s fly-by-wire, meaning not thrittle cables are attached to the throttle body, what you need to do is to clean the throttle body for a start.
Remove the air cleaner nose and use a piece of rag to wipe the throttle body internal bore clean with the aid of carb cleaner. During this process, DO NOT turn the ignition on. You would need to push the throttle open to clean the areas where the throttle p[late s closes when it closes.