Search in sources :

Example 1 with User

use of co.aurasphere.botmill.fb.model.base.User in project fb-botmill by BotMill.

the class FbBotMillMockMediator method sendTextMessage.

/**
	 * Sends a text message to all the registered bots. Used to simulate a user
	 * typing in chat with your bot.
	 * 
	 * @param message
	 *            the message to send.
	 */
public void sendTextMessage(String message) {
    MessageEnvelope envelope = new MessageEnvelope();
    ReceivedMessage body = new ReceivedMessage();
    body.setText(message);
    envelope.setMessage(body);
    envelope.setSender(new User(facebookMockId));
    System.out.println("Sending message: [" + message + "] as user : [" + facebookMockId + "].");
    forward(envelope);
    System.out.println("Sent!");
}
Also used : User(co.aurasphere.botmill.fb.model.base.User) ReceivedMessage(co.aurasphere.botmill.fb.model.incoming.callback.ReceivedMessage) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)

Example 2 with User

use of co.aurasphere.botmill.fb.model.base.User in project fb-botmill by BotMill.

the class FbBotMillMockMediator method sendPayload.

/**
	 * Sends a payload to all the registered bots. Used to simulate a user
	 * interacting with buttons.
	 * 
	 * @param payload
	 *            the payload to send.
	 */
public void sendPayload(String payload) {
    MessageEnvelope envelope = new MessageEnvelope();
    Postback postback = new Postback();
    postback.setPayload(payload);
    envelope.setPostback(postback);
    envelope.setSender(new User(facebookMockId));
    System.out.println("Sending payload: [" + payload + "] as user : [" + facebookMockId + "].");
    forward(envelope);
    System.out.println("Sent!");
}
Also used : User(co.aurasphere.botmill.fb.model.base.User) Postback(co.aurasphere.botmill.fb.model.incoming.callback.Postback) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)

Example 3 with User

use of co.aurasphere.botmill.fb.model.base.User in project fb-botmill by BotMill.

the class AttachmentMessageBuilder method build.

/**
	 * {@inheritDoc} Returns a response containing an {@link Attachment}.
	 */
public FbBotMillResponse build(MessageEnvelope envelope) {
    User recipient = getRecipient(envelope);
    Message message = new AttachmentMessage(attachment);
    message.setQuickReplies(quickReplies);
    return new FbBotMillMessageResponse(recipient, message);
}
Also used : User(co.aurasphere.botmill.fb.model.base.User) FbBotMillMessageResponse(co.aurasphere.botmill.fb.model.outcoming.message.FbBotMillMessageResponse) Message(co.aurasphere.botmill.fb.model.outcoming.message.Message) AttachmentMessage(co.aurasphere.botmill.fb.model.outcoming.message.AttachmentMessage) AttachmentMessage(co.aurasphere.botmill.fb.model.outcoming.message.AttachmentMessage)

Example 4 with User

use of co.aurasphere.botmill.fb.model.base.User in project fb-botmill by BotMill.

the class TextMessageBuilder method build.

/**
	 * {@inheritDoc} Returns a response containing a plain text message.
	 */
public FbBotMillResponse build(MessageEnvelope envelope) {
    User recipient = getRecipient(envelope);
    Message message = new TextMessage(messageText);
    message.setQuickReplies(quickReplies);
    return new FbBotMillMessageResponse(recipient, message);
}
Also used : User(co.aurasphere.botmill.fb.model.base.User) FbBotMillMessageResponse(co.aurasphere.botmill.fb.model.outcoming.message.FbBotMillMessageResponse) Message(co.aurasphere.botmill.fb.model.outcoming.message.Message) TextMessage(co.aurasphere.botmill.fb.model.outcoming.message.TextMessage) TextMessage(co.aurasphere.botmill.fb.model.outcoming.message.TextMessage)

Example 5 with User

use of co.aurasphere.botmill.fb.model.base.User in project fb-botmill by BotMill.

the class FbBotMillMockMediator method sendQuickReplyPayload.

/**
	 * Sends a quickreply to all the registered bots. Used to simulate a user
	 * interacting with buttons.
	 * 
	 * @param payload
	 *            the payload to send.
	 */
public void sendQuickReplyPayload(String payload) {
    MessageEnvelope envelope = new MessageEnvelope();
    QuickReply quickReply = new QuickReply("Sample", payload);
    ReceivedMessage message = new ReceivedMessage();
    message.setQuickReply(quickReply);
    envelope.setMessage(message);
    envelope.setSender(new User(facebookMockId));
    System.out.println("Sending quick reply: [" + message + "] as user : [" + facebookMockId + "].");
    forward(envelope);
    System.out.println("Sent!");
}
Also used : User(co.aurasphere.botmill.fb.model.base.User) QuickReply(co.aurasphere.botmill.fb.model.outcoming.quickreply.QuickReply) ReceivedMessage(co.aurasphere.botmill.fb.model.incoming.callback.ReceivedMessage) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)

Aggregations

User (co.aurasphere.botmill.fb.model.base.User)5 MessageEnvelope (co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)3 ReceivedMessage (co.aurasphere.botmill.fb.model.incoming.callback.ReceivedMessage)2 FbBotMillMessageResponse (co.aurasphere.botmill.fb.model.outcoming.message.FbBotMillMessageResponse)2 Message (co.aurasphere.botmill.fb.model.outcoming.message.Message)2 Postback (co.aurasphere.botmill.fb.model.incoming.callback.Postback)1 AttachmentMessage (co.aurasphere.botmill.fb.model.outcoming.message.AttachmentMessage)1 TextMessage (co.aurasphere.botmill.fb.model.outcoming.message.TextMessage)1 QuickReply (co.aurasphere.botmill.fb.model.outcoming.quickreply.QuickReply)1