Git Product home page Git Product logo

goexoml's Introduction

goexoml GoDoc  Join the chat at https://gitter.im/exotel/goexoml Go Report Card

The ExoML library for golang

What is it?

goexoml is the official ExoML library written in golang.
ExoML (ExotelMarkupLanguage) enables one to add logic to calls.When someone makes a call to an exophone ,Exotel will look up the URL associated with exophone and make a request to that URL. The URL can be configured to respond with ExoMLs Responses,which exotel interprets and executes

For Example

The following will be interpreted by exotel as a request to make a call to the number +919742033616 and makes call

<?xml version="1.0" encoding="UTF-8"?>
<Response>
 <Dial>
   <Number>
     +919742033616
   </Number>
 </Dial>
</Response>

currently supported verbs

  • Dial
  • Hangup
  • Play
  • Record
  • Redirect
  • Say
  • Gather

how to use

Install the latest library using go get

go get github.com/exotel/goexoml

or from the gopkg repo to make sure the version number is maintained all time

go get gopkg.in/exotel/goexoml.v1 //for v1.x.x

sample Code

package main

import (
	"fmt"

	"github.com/exotel/goexoml"
)

//Example - creates a sample response as follows
// <?xml version="1.0" encoding="UTF-8"?>
// <Response>
//     <Say>
//         Please leave a message at the beep.
//         Press the star key when finished.
//     </Say>
//     <Record
//         action="http://example.exotel.in/handleRecording"
//         method="GET"
//         maxLength="20"
//         finishOnKey="*"
//         />
//     <Say>I did not receive a recording</Say>
// </Response>
func Example() (string, error) {
	//create a new response object
	resp := goexoml.NewResponse()

	//create a new say verb and add attributes and values
	say1 := goexoml.NewSay().SetText("Please leave a message at the beep.\n         Press the star key when finished.")

	//create a new say verb and add attributes and values
	say2 := goexoml.NewSay().SetText("I did not receive a recording.")

	//create the record verb and add attributes
	rec := goexoml.NewRecord().SetAction("http://example.exotel.in/handleRecording").SetMethod("GET").SetMaxLength(20)

	//Add the Action verbs to the response object in expected order
	err := resp.Action(say1, rec, say2)
	if err != nil {
		fmt.Println(err.Error())
		return "", err
	}
	// OR
	////Add the Action verbs to the response object in expected order
	// resp.AddSay(say1).AddRecord(rec).AddSay(say2)
	return resp.String(), nil
}

func main() {
	exoml, err := Example()
	if err != nil {
		fmt.Print("Error occured :", err.Error())
		return
	}
	fmt.Println(exoml)
	return
}

What if i don't have go installed ?

Follow the instructions here to install go

Example

example directory contains code demonstrating the library usage

For a quick start you may try the example/server

# install dependencies
go get github.com/exotel/goexoml/example/server

# run server
go run github.com/exotel/goexoml/example/server

By now the exoml server would be running on port 1323

curl http://localhost:1323/dial/+919742033616

This would return an exoml

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>You can't handle the truth</Say>
    <Dial>+919742033616</Dial>
    <Hangup></Hangup>
</Response

Versioning

major version Changes would mean following
  • Removing or renaming any exposed name (function, method, type, etc)
  • Adding, removing or renaming methods in an interface
  • Adding a parameter to a function, method, or interface
  • Changing the type of a parameter or result in a function, method, or interface
  • Changing the number of results in a function, method, or interface
  • Some user facing struct changes
expect these changes even without major version being same
  • Adding exposed names (function, method, type, etc)
  • Renaming a parameter or result of a function, method, or interface*
  • Some struct changes which does not directly affect the functionality of the library [much] but may/maynot add new features to the existing library

contributions

goexoml's People

Contributors

gitter-badger avatar kenkoii avatar marcosnils avatar sarathsp06 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goexoml's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.