campoy / Apiai
Licence: apache-2.0
A simple framework for api.ai fulfillment backends
Stars: ✭ 77
Programming Languages
go
31211 projects - #10 most used programming language
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.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].