Skip to content

toanppp/freshgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

freshgo

Freshworks Golang APIs

To do

  • Freshchat
    • User
    • Agent
    • Conversation
  • Freshdesk

Install

go get github.com/toanppp/freshgo

Example

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/toanppp/freshgo/freshchat"
)

func main() {
	f := freshchat.New("url", "accessToken")

	resp, err := f.CreateConversation(context.Background(), freshchat.Conversation{
		Status: freshchat.ConversationStatusNew,
		Messages: []freshchat.Message{
			{
				MessageParts: []freshchat.MessagePart{
					{
						Text: freshchat.Text{
							Content: "Hello World",
						},
					},
				},
				ActorType: freshchat.ActorTypeUser,
				ActorID:   "userID",
			},
		},
		ChannelID: "channelID",
		Users: []freshchat.User{
			{
				ID: "userID",
			},
		},
	})
	if err != nil {
		log.Fatalf("an error occurred: %v", err)
	}

	fmt.Printf("%+v\n", resp)
}