Skip to content
/ apiai Public
forked from campoy/apiai

A simple framework for api.ai fulfillment backends

License

Notifications You must be signed in to change notification settings

pinterb/apiai

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc Build Status Go Report Card

apiai

This package provides an easy way to handle webhook requests for api.ai fulfillments.

You can find more in the fulfillment docs.

This is totally experimental for now, so please file let me know what you think about it. File issues!

example

This is a simple example fo an application handling a single intent called number, which it simply doubles as a result.

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"strconv"

	"github.com/campoy/apiai"
)

func main() {
	h := apiai.NewHandler()
	h.Register("double", doubleHandler)
	log.Fatal(http.ListenAndServe("0.0.0.0:8080", h))
}

func doubleHandler(ctx context.Context, req *apiai.Request) (*apiai.Response, error) {
	num, err := strconv.Atoi(req.Param("number"))
	if err != nil {
		return nil, fmt.Errorf("could not parse number %q: %v", req.Param("number"), err)
	}
	return &apiai.Response{
		Speech: fmt.Sprintf("%d times two equals %d", num, 2*num),
	}, nil
}

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

About

A simple framework for api.ai fulfillment backends

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 96.7%
  • Shell 3.3%