O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exposing the agent's information to the client

Now that we've implemented the chat agent, AgentCase, we need a way to expose Case's information to the client, notably, its name, title, and the path to its avatar image.

We create a new Rest API endpoint, GetAgentInfoEndpoint, to expose the chat agent's information to the client-side web application:

func GetAgentInfoEndpoint(env *common.Env, chatbot bot.Bot) http.Handler {  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {    m := make(map[string]string)    m["AgentName"] = chatbot.Name()    m["AgentTitle"] = chatbot.Title()    m["AgentThumbImagePath"] = chatbot.ThumbnailPath()    w.Header().Set("Content-Type", "application/json")    json.NewEncoder(w).Encode(m)  })

Note that in the signature ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required