Gosub

Since N/A AGI Commands Found this useful? Upvote it. ×

Cause the [[term:channel|channel]] to execute the specified [[term:dialplan|dialplan]] subroutine.

Last reviewed 2026-08-22

gosub [[term:context|context]] [[term:extension|extension]] priority optional-argument
Description

Cause the channel to execute the specified dialplanThe core call-routing configuration of Asterisk, written mostly in extensions.conf as contexts, extensions, and priorities that decide how every call is handled. Full definition → subroutine, returning to the dialplan with execution of a Return().

Arguments
  • context required
  • extension required
  • priority required
  • optional-argument
User Notes

Know a tip or gotcha for this topic? Share it below and help others.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.