Categorygithub.com/CyCoreSystems/agi
modulepackage
0.6.3
Repository: https://github.com/cycoresystems/agi.git
Documentation: pkg.go.dev

# README

Asterisk AGI library for Go (golang)

Build Status

This is an Asterisk AGI interface library which may be used for both classical AGI, with a standalone executable, or FastAGI, with a TCP server.

package main

import "github.com/CyCoreSystems/agi"

func main() {
   a := agi.NewStdio()

   a.Answer()
   err := a.Set("MYVAR", "foo")
   if err != nil {
      panic("failed to set variable MYVAR")
   }
   a.Hangup()
}

Standalone AGI executable

Use agi.NewStdio() to get an AGI reference when running a standalone executable.

For a TCP server, register a HandlerFunc to a TCP port:

package main

import "github.com/CyCoreSystems/agi"

func main() {
   agi.Listen(":8080", handler)
}

func handler(a *agi.AGI) {
   defer a.Close()

   a.Answer()
   err := a.Set("MYVAR", "foo")
   if err != nil {
      panic("failed to set variable MYVAR")
   }
   a.Hangup()
}

# Functions

Listen binds an AGI HandlerFunc to the given TCP `host:port` address, creating a FastAGI service.
New creates an AGI session from the given reader and writer.
NewConn returns a new AGI session bound to the given net.Conn interface.
NewEAGI returns a new AGI session to stdin, the EAGI stream (FD=3), and stdout.
NewStdio returns a new AGI session to stdin and stdout.
NewWithEAGI returns a new AGI session to the given `os.Stdin` `io.Reader`, EAGI `io.Reader`, and `os.Stdout` `io.Writer`.

# Constants

StateBusy indicates the line is busy.
StateDialing indicates that digits have been dialed.
StateDialingOffHook indicates digits have been dialed while offhook.
StateDown indicates the channel is down and available.
StateOffhook indicates that the channel is offhook.
StatePreRing indicates the channel has detected an incoming call and is waiting for ring.
StateReserved indicates the channel is down but reserved.
StateRing indicates the channel is ringing.
StateRinging indicates the channel's remote end is rining (the channel is receiving ringback).
StateUp indicates the channel is up.
StatusDeadChannel indicates that the command cannot be performed on a dead (hungup) channel.
StatusEndUsage indicates...TODO.
StatusInvalid indicates Asterisk did not understand the command.
StatusOK indicates the AGI command was accepted.

# Variables

ErrHangup indicates the channel hung up during processing.

# Structs

AGI represents an AGI session.
RecognitionInterpretation describes a specific interpretation of speech input.
RecognitionResult describes the result of an MRCP speech recognition action.
RecordOptions describes the options available when recording.
Response represents a response to an AGI request.
SynthResult describes the result of an MRCP Synthesis operation.

# Type aliases

HandlerFunc is a function which accepts an AGI instance.
State describes the Asterisk channel state.