Skip to content

weni-ai/weni-webchat-socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weni-webchannel-socket

ci codecov GitHub go.mod Go version

Index

Running

  • Environment Variables

    Variable Required Default
    WWC_PORT false 8080
    WWC_LOG_LEVEL false info
    WWC_S3_ACCESS_KEY true -
    WWC_S3_SECRET_KEY true -
    WWC_S3_ENDPOINT true -
    WWC_S3_REGION true -
    WWC_S3_BUCKET true -
    WWC_S3_DISABLE_SSL false false
    WWC_S3_FORCE_PATH_STYLE false false
    WWC_REDIS_QUEUE_TAG false wwcs-service
    WWC_REDIS_QUEUE_URL false redis://localhost:6379/1
    WWC_REDIS_QUEUE_CONSUMER_PREFETCH_LIMIT false 1000
    WWC_REDIS_QUEUE_CONSUMER_POLL_DURATION false 100
    WWC_REDIS_QUEUE_RETRY_PREFETCH_LIMIT false 1000
    WWC_REDIS_QUEUE_RETRY_POLL_DURATION false 60000
    WWC_APP_SENTRY_DSN false -
    WWC_SESSION_TYPE_TO_STORE false remote
    WWC_DB_URI false mongodb://admin:admin@localhost:27017
    WWC_DB_NAME false weni-webchat
    WWC_DB_CONTEXT_TIMEOUT false 15
  • To execute the project just run:

     go run ./api

Features

  • Send and receive messages
    • text
    • image
    • video
    • audio
    • document
    • location
    • quick replies
    • form
  • Send notifications
    • browser
    • email
    • sound alerts
  • Easy configuration
    • Extremely customizable
    • Easy connection
    • Fast integration
  • Accessibility
    • Multi language
    • Read accessibility
    • Text to speech
  • Save history
  • Send initial form to register
  • Call back methods
  • Metrics

Examples

Incoming (external to socket)

  • Text Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"text", //required
		"timestamp":"1616891274", //required
		"text":"Hello World!", //required
		"quick_replies": ["1","2","3"]
	}
}
  • Image Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"image", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/image.png", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • Video Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"video", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/video.mp4", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • Audio Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"audio", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/audio.mp3", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • File Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"file", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/file.pdf", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • Location Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"location", //required
		"timestamp":"1616891274", //required
		"latitude":"-12.4364187", //required
		"longitude":"-49.5538636", //required
		"quick_replies": ["1","2","3"]
	}
}

Outgoing (socket to external)

  • Text Message
{
	"type":"message", //required
	"from":"Caio", //required
	"message": {
		"type":"text", //required
		"timestamp":"1616891274", //required
		"text":"Hello World!", //required
	}
}
  • Image Message
{
	"type":"message", //required
	"from":"Caio", //required
	"message": {
		"type":"image", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/image.png", //required
		"caption":"My caption",
	}
}
  • Video Message
{
	"type":"message", //required
	"from":"Caio", //required
	"message": {
		"type":"video", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/video.mp4", //required
		"caption":"My caption",
	}
}
  • Audio Message
{
	"type":"message", //required
	"from":"Caio", //required
	"message": {
		"type":"audio", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/audio.mp3", //required
		"caption":"My caption",
	}
}
  • File Message
{
	"type":"message", //required
	"from":"Caio", //required
	"message": {
		"type":"file", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/file.pdf", //required
		"caption":"My caption",
	}
}
  • Location Message
{
	"type":"message", //required
	"from":"Caio", //required
	"message": {
		"type":"location", //required
		"timestamp":"1616891274", //required
		"latitude":"-12.4364187", //required
		"longitude":"-49.5538636", //required
	}
}

Incoming (client to socket)

  • Register (it is mandatory to be the first communication)
{
   "type":"register", //required
   "from":"<uuid>",  //required
   "callback":"<url>",  //required
   "trigger": "<trigger>",
}
  • Text Message
{
	"type":"message", //required
	"message": {
		"type":"text", //required
		"text":"Hello World!", //required
	}
}
  • Image Message
{
	"type":"message", //required
	"message": {
		"type":"image", //required
		"media":"media_content", //required
		"caption":"My caption",
	}
}
  • Video Message
{
	"type":"message", //required
	"message": {
		"type":"video", //required
		"media":"media_content", //required
		"caption":"My caption",
	}
}
  • Audio Message
{
	"type":"message", //required
	"message": {
		"type":"audio", //required
		"media":"media_content", //required
		"caption":"My caption",
	}
}
  • File Message
{
	"type":"message", //required
	"message": {
		"type":"file", //required
		"media":"media_content", //required
		"caption":"My caption",
	}
}
  • Location Message
{
	"type":"message", //required
	"message": {
		"type":"location", //required
		"latitude":"-12.4364187", //required
		"longitude":"-49.5538636", //required
	}
}
  • Get History
{
	"type":"get_history",
	"params":{
		"limit":10,
		"page":1
	}
}

Outgoing (socket to client)

  • Error
{
	"type":"error", //required
	"error":"my_error" //required
}
  • Text Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"text", //required
		"timestamp":"1616891274", //required
		"text":"Hello World!", //required
		"quick_replies": ["1","2","3"]
	}
}
  • Image Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"image", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/image.png", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • Video Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"video", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/video.mp4", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • Audio Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"audio", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/audio.mp3", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • File Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"file", //required
		"timestamp":"1616891274", //required
		"media_url":"https://foo.bar/file.pdf", //required
		"caption":"My caption",
		"quick_replies": ["1","2","3"]
	}
}
  • Location Message
{
	"type":"message", //required
	"to":"Lucas", //required
	"from":"Caio", //required
	"message": {
		"type":"location", //required
		"timestamp":"1616891274", //required
		"latitude":"-12.4364187", //required
		"longitude":"-49.5538636", //required
		"quick_replies": ["1","2","3"]
	}
}
  • History
{
	"type":"history",
	"history": [
		{
			"contact_urn":"Fulano",
			"channel_uuid":"8adf206a-607b-4039-9cac-3de66d084f15",
			"direction":"in||out",
			"timestamp":"1616891274",
			"message": {
				"type":"text||image||audio||file||location",
				"timestamp":"1616891274",
				...
				...
				...
			}
		},
	]
}