Server
Go
go get github.com/texadigital/texa-go. The Texa API from Go, standard library only.
Shell
go get github.com/texadigital/texa-go
The standard library only. Source: github.com/texadigital/texa-go.
Go
import texa "github.com/texadigital/texa-go"
c, _ := texa.New("", "") // key from TEXA_API_KEY, the default address
convo, _ := c.OpenConversation(ctx, texa.M{"channel": "web", "customer_ref": "user-1842"},
"open-user-1842")
out, _ := c.SendMessage(ctx, convo.ConversationID,
texa.M{"text": "Where is my transfer?", "message_id": "msg-551"})
events, _ := c.RunActions(ctx, convo.ConversationID, out, map[string]texa.ActionHandler{
"get_transfer_status": func(ctx context.Context, in texa.M) (texa.M, error) {
return texa.M{"status": "paid_out"}, nil
},
})
Webhooks
Go
func webhook(w http.ResponseWriter, r *http.Request) {
raw, _ := io.ReadAll(r.Body)
event, err := texa.ParseWebhook(os.Getenv("TEXA_WEBHOOK_SECRET"), r.Header, raw)
if err != nil {
http.Error(w, "bad signature", http.StatusUnauthorized)
return
}
w.WriteHeader(http.StatusOK)
go handle(event)
}
Methods
Me, Usage, WidgetSession, OpenConversation, ListConversations, GetConversation,
SendMessage, ActionResult, HumanMessage, Handover, Handback, Close, Assist,
VoiceSession, Transcript, Export, Quality, GetCustomer, MergeCustomer, ForgetCustomer,
GetMedia, MediaContent, GetAgent, GetKillSwitch, ListActions, ListDocuments,
AddDocument, Events, EventsPage, PutFixture, DeleteFixture, RunActions. Every method takes
a context.Context first.