new file: .env
new file: bot.db new file: db/db.go new file: go.mod new file: go.sum new file: handlers/dashboard.go new file: handlers/webhook.go new file: main.go new file: services/openrouter.go new file: services/whatsapp.go new file: templates/dashboard.html new file: types/types.go
This commit is contained in:
34
services/openrouter.go
Normal file
34
services/openrouter.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetAIResponse(input string) (string, error) {
|
||||
apiKey := os.Getenv("OPENROUTER_API_KEY")
|
||||
payload := map[string]interface{}{
|
||||
"model": "stepfun/step-3.5-flash:free",
|
||||
"messages": []map[string]string{
|
||||
{"role": "system", "content": "You are a business assistant in Chile. Book appointments or answer FAQs."},
|
||||
{"role": "user", "content": input},
|
||||
},
|
||||
}
|
||||
|
||||
data, _ := json.Marshal(payload)
|
||||
req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/chat/completions", bytes.NewBuffer(data))
|
||||
req.Header.Set("Authorization", "Bearer "+apiKey)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Simplification: You need to parse the JSON response here, seki.
|
||||
// I assume you know how to decode a nested map. Big assumption, I know.
|
||||
return "AI Response Placeholder", nil
|
||||
}
|
||||
1
services/whatsapp.go
Normal file
1
services/whatsapp.go
Normal file
@@ -0,0 +1 @@
|
||||
package services
|
||||
Reference in New Issue
Block a user