1
0
mirror of synced 2024-11-22 04:46:05 +03:00

Add Replies feature (#5)

* add replies payload and method

* clean comment

* improve TextWithReplies and  spelling correction

* fix last typo
This commit is contained in:
Garry POUPIN 2016-07-08 15:49:35 +02:00 committed by Harrison Shoebridge
parent f5aa0f8e1c
commit 5a7a8679ad
2 changed files with 20 additions and 3 deletions

View File

@ -55,6 +55,16 @@ type Attachment struct {
Payload Payload `json:"payload"`
}
// QuickReply is a file which used in a message.
type QuickReply struct {
// ContentType is the type of reply
ContentType string `json:"content_type"`
// Title is the reply title
Title string `json:"title"`
// Payload is the reply information
Payload string `json:"payload"`
}
// Payload is the information on where an attachment is.
type Payload struct {
// URL is where the attachment resides on the internet.

View File

@ -24,10 +24,16 @@ type Response struct {
// Text sends a textual message.
func (r *Response) Text(message string) error {
return r.TextWithReplies(message, nil)
}
// TextWithReplies sends a textual message with some replies
func (r *Response) TextWithReplies(message string, replies []QuickReply) error {
m := SendMessage{
Recipient: r.to,
Message: MessageData{
Text: message,
QuickReplies: replies,
},
}
@ -178,9 +184,10 @@ type SendMessage struct {
Message MessageData `json:"message"`
}
// MessageData is a text message to be sent.
// MessageData is a text message with optional replies to be sent.
type MessageData struct {
Text string `json:"text,omitempty"`
QuickReplies []QuickReply `json:"quick_replies,omitempty"`
}
// SendStructuredMessage is a structured message template.