The Go SDK from vektorone.co lets you integrate intelligent ad generation into your Go-based chat or web systems. It enables you to:
All SDK functions use idiomatic Go error handling.
Install the SDK:
go get github.com/goodguysoft/adselect-go
Import in your application:
import adselect "github.com/goodguysoft/adselect-go"
Use `SendChatHistory()` to send complete conversation data to the API.
func SendChatHistory(apiId string, apiKey string, userID string, conversationID string, messages []adselect.ChatMessage) error
type ChatMessage struct { Role string // "User" or "Bot" Text string // Message content }
messages := []adselect.ChatMessage{ {Role: "User", Text: "I'm looking for dog food."}, {Role: "Bot", Text: "We have natural dog food options."}, } err := adselect.SendChatHistory("YOUR_API_ID", "YOUR_API_KEY", "user-123", "conv-456", messages) if err != nil { log.Fatalf("failed to send chat history: %v", err) }
Use `GetChatAd()` to fetch an ad based on chat context.
func GetChatAd(apiId string, apiKey string, userID string, conversationID string, adType string, jsFunc string) (string, error)
adHtml, err := adselect.GetChatAd("YOUR_API_ID", "YOUR_API_KEY", "user-123", "conv-456", adselect.AdTypeHtmlTextAd, "") if err != nil { log.Printf("failed to get ad: %v", err) } else { fmt.Println("Ad HTML:", adHtml) }
Use `GetPageAd()` to retrieve an ad based on HTML page content.
func GetPageAd(apiId string, apiKey string, pageContent string, adType adsdk.AdType, jsFunc string) (string, error)
html := "<html><body><h1>Best dog food 2024</h1><p>Our guide covers natural ingredients...</p></body></html>" adScript, err := adsdk.GetPageAd("YOUR_API_ID", "YOUR_API_KEY", html, adsdk.AdTypeJavaScript, "renderAd") if err != nil { log.Printf("ad error: %v", err) } else { fmt.Println("<script>" + adScript + "</script>") }
const ( AdTypeJsonText = "JsonText" AdTypeJsonImage = "JsonImage" AdTypeHtmlText = "HtmlTextAd" AdTypeHtmlImage = "HtmlImageAd" AdTypeJavaScriptText = "JavaScriptTextAd" AdTypeJavaScriptImage = "JavaScriptImageAd" AdTypeBannerMediumRectJson = "BannerMediumRectJson" AdTypeBannerMediumRectHtml = "BannerMediumRectHtml" AdTypeBannerLeaderboardJson = "BannerLeaderboardJson" AdTypeBannerLeaderboardHtml = "BannerLeaderboardHtml" AdTypeBannerWideSkyJson = "BannerWideSkyJson" AdTypeBannerWideSkyHtml = "BannerWideSkyHtml" )
All functions return a standard Go `error` type.
Always validate return values using:
if err != nil { // handle failure }